Rename Ddi classes

Signed-off-by: SirWayne <dennis.melzer@bosch-si.com>
This commit is contained in:
SirWayne
2016-04-20 13:42:43 +02:00
parent 12cca669fe
commit 3c0e34ee41
23 changed files with 197 additions and 169 deletions

View File

@@ -16,7 +16,7 @@ import javax.servlet.http.HttpServletResponse;
import org.eclipse.hawkbit.artifact.repository.model.DbArtifact;
import org.eclipse.hawkbit.cache.CacheWriteNotify;
import org.eclipse.hawkbit.ddi.api.ArtifactStoreControllerDdiApi;
import org.eclipse.hawkbit.ddi.rest.api.DdiArtifactStoreControllerRestApi;
import org.eclipse.hawkbit.repository.ArtifactManagement;
import org.eclipse.hawkbit.repository.ControllerManagement;
import org.eclipse.hawkbit.repository.model.Action;
@@ -44,7 +44,7 @@ import org.springframework.web.bind.annotation.RestController;
* for legacy controllers that can not be fed with a download URI at runtime.
*/
@RestController
public class ArtifactStoreController implements ArtifactStoreControllerDdiApi {
public class ArtifactStoreController implements DdiArtifactStoreControllerRestApi {
private static final Logger LOG = LoggerFactory.getLogger(ArtifactStoreController.class);

View File

@@ -20,12 +20,12 @@ import javax.servlet.http.HttpServletResponse;
import org.eclipse.hawkbit.api.ArtifactUrlHandler;
import org.eclipse.hawkbit.api.UrlProtocol;
import org.eclipse.hawkbit.ddi.ControllerConstants;
import org.eclipse.hawkbit.ddi.model.Artifact;
import org.eclipse.hawkbit.ddi.model.Chunk;
import org.eclipse.hawkbit.ddi.model.Config;
import org.eclipse.hawkbit.ddi.model.ControllerBase;
import org.eclipse.hawkbit.ddi.model.Polling;
import org.eclipse.hawkbit.ddi.json.model.DdiArtifact;
import org.eclipse.hawkbit.ddi.json.model.DdiChunk;
import org.eclipse.hawkbit.ddi.json.model.DdiConfig;
import org.eclipse.hawkbit.ddi.json.model.DdiControllerBase;
import org.eclipse.hawkbit.ddi.json.model.DdiPolling;
import org.eclipse.hawkbit.ddi.rest.api.DdiRestConstants;
import org.eclipse.hawkbit.repository.model.Action;
import org.eclipse.hawkbit.repository.model.Action.Status;
import org.eclipse.hawkbit.repository.model.LocalArtifact;
@@ -50,10 +50,10 @@ public final class DataConversionHelper {
}
static List<Chunk> createChunks(final String targetid, final Action uAction,
static List<DdiChunk> createChunks(final String targetid, final Action uAction,
final ArtifactUrlHandler artifactUrlHandler) {
return uAction.getDistributionSet().getModules().stream()
.map(module -> new Chunk(mapChunkLegacyKeys(module.getType().getKey()), module.getVersion(),
.map(module -> new DdiChunk(mapChunkLegacyKeys(module.getType().getKey()), module.getVersion(),
module.getName(), createArtifacts(targetid, module, artifactUrlHandler)))
.collect(Collectors.toList());
@@ -79,12 +79,12 @@ public final class DataConversionHelper {
* the software module
* @return a list of artifacts or a empty list. Cannot be <null>.
*/
public static List<Artifact> createArtifacts(final String targetid,
public static List<DdiArtifact> createArtifacts(final String targetid,
final org.eclipse.hawkbit.repository.model.SoftwareModule module,
final ArtifactUrlHandler artifactUrlHandler) {
final List<Artifact> files = new ArrayList<>();
final List<DdiArtifact> files = new ArrayList<>();
module.getLocalArtifacts().forEach(artifact -> {
final Artifact file = new Artifact();
final DdiArtifact file = new DdiArtifact();
file.setHashes(new ArtifactHash(artifact.getSha1Hash(), artifact.getMd5Hash()));
file.setFilename(artifact.getFilename());
file.setSize(artifact.getSize());
@@ -93,18 +93,18 @@ public final class DataConversionHelper {
final String linkHttps = artifactUrlHandler.getUrl(targetid, artifact.getSoftwareModule().getId(),
artifact.getFilename(), artifact.getSha1Hash(), UrlProtocol.HTTPS);
file.add(new Link(linkHttps).withRel("download"));
file.add(new Link(linkHttps + ControllerConstants.ARTIFACT_MD5_DWNL_SUFFIX).withRel("md5sum"));
file.add(new Link(linkHttps + DdiRestConstants.ARTIFACT_MD5_DWNL_SUFFIX).withRel("md5sum"));
file.add(new Link(linkHttp).withRel("download-http"));
file.add(new Link(linkHttp + ControllerConstants.ARTIFACT_MD5_DWNL_SUFFIX).withRel("md5sum-http"));
file.add(new Link(linkHttp + DdiRestConstants.ARTIFACT_MD5_DWNL_SUFFIX).withRel("md5sum-http"));
files.add(file);
});
return files;
}
static ControllerBase fromTarget(final Target target, final List<Action> actions,
static DdiControllerBase fromTarget(final Target target, final List<Action> actions,
final String defaultControllerPollTime, final TenantAware tenantAware) {
final ControllerBase result = new ControllerBase(new Config(new Polling(defaultControllerPollTime)));
final DdiControllerBase result = new DdiControllerBase(new DdiConfig(new DdiPolling(defaultControllerPollTime)));
boolean addedUpdate = false;
boolean addedCancel = false;
@@ -118,19 +118,19 @@ public final class DataConversionHelper {
// response because of eTags.
result.add(linkTo(methodOn(RootController.class, tenantAware.getCurrentTenant())
.getControllerBasedeploymentAction(target.getControllerId(), action.getId(), actions.hashCode(),
null)).withRel(ControllerConstants.DEPLOYMENT_BASE_ACTION));
null)).withRel(DdiRestConstants.DEPLOYMENT_BASE_ACTION));
addedUpdate = true;
} else if (action.isCancelingOrCanceled() && !addedCancel) {
result.add(linkTo(methodOn(RootController.class, tenantAware.getCurrentTenant())
.getControllerCancelAction(target.getControllerId(), action.getId(), null))
.withRel(ControllerConstants.CANCEL_ACTION));
.withRel(DdiRestConstants.CANCEL_ACTION));
addedCancel = true;
}
}
if (target.getTargetInfo().isRequestControllerAttributes()) {
result.add(linkTo(methodOn(RootController.class, tenantAware.getCurrentTenant()).putConfigData(null,
target.getControllerId(), null)).withRel(ControllerConstants.CONFIG_DATA_ACTION));
target.getControllerId(), null)).withRel(DdiRestConstants.CONFIG_DATA_ACTION));
}
return result;
}
@@ -146,7 +146,7 @@ public final class DataConversionHelper {
final StringBuilder header = new StringBuilder();
header.append("attachment;filename=");
header.append(fileName);
header.append(ControllerConstants.ARTIFACT_MD5_DWNL_SUFFIX);
header.append(DdiRestConstants.ARTIFACT_MD5_DWNL_SUFFIX);
response.setContentLength(content.length);
response.setHeader("Content-Disposition", header.toString());

View File

@@ -18,17 +18,17 @@ import javax.validation.Valid;
import org.eclipse.hawkbit.api.ArtifactUrlHandler;
import org.eclipse.hawkbit.artifact.repository.model.DbArtifact;
import org.eclipse.hawkbit.cache.CacheWriteNotify;
import org.eclipse.hawkbit.ddi.api.RootControllerDdiApi;
import org.eclipse.hawkbit.ddi.model.ActionFeedback;
import org.eclipse.hawkbit.ddi.model.Cancel;
import org.eclipse.hawkbit.ddi.model.CancelActionToStop;
import org.eclipse.hawkbit.ddi.model.Chunk;
import org.eclipse.hawkbit.ddi.model.ConfigData;
import org.eclipse.hawkbit.ddi.model.ControllerBase;
import org.eclipse.hawkbit.ddi.model.Deployment;
import org.eclipse.hawkbit.ddi.model.Deployment.HandlingType;
import org.eclipse.hawkbit.ddi.model.DeploymentBase;
import org.eclipse.hawkbit.ddi.model.Result.FinalResult;
import org.eclipse.hawkbit.ddi.json.model.DdiActionFeedback;
import org.eclipse.hawkbit.ddi.json.model.DdiCancel;
import org.eclipse.hawkbit.ddi.json.model.DdiCancelActionToStop;
import org.eclipse.hawkbit.ddi.json.model.DdiChunk;
import org.eclipse.hawkbit.ddi.json.model.DdiConfigData;
import org.eclipse.hawkbit.ddi.json.model.DdiControllerBase;
import org.eclipse.hawkbit.ddi.json.model.DdiDeployment;
import org.eclipse.hawkbit.ddi.json.model.DdiDeployment.HandlingType;
import org.eclipse.hawkbit.ddi.json.model.DdiDeploymentBase;
import org.eclipse.hawkbit.ddi.json.model.DdiResult.FinalResult;
import org.eclipse.hawkbit.ddi.rest.api.DdiRootControllerRestApi;
import org.eclipse.hawkbit.repository.ArtifactManagement;
import org.eclipse.hawkbit.repository.ControllerManagement;
import org.eclipse.hawkbit.repository.SoftwareManagement;
@@ -63,7 +63,7 @@ import org.springframework.web.bind.annotation.RestController;
* Transactional (read-write) as all queries at least update the last poll time.
*/
@RestController
public class RootController implements RootControllerDdiApi {
public class RootController implements DdiRootControllerRestApi {
private static final Logger LOG = LoggerFactory.getLogger(RootController.class);
private static final String GIVEN_ACTION_IS_NOT_ASSIGNED_TO_GIVEN_TARGET = "given action ({}) is not assigned to given target ({}).";
@@ -90,7 +90,7 @@ public class RootController implements RootControllerDdiApi {
private ArtifactUrlHandler artifactUrlHandler;
@Override
public ResponseEntity<List<org.eclipse.hawkbit.ddi.model.Artifact>> getSoftwareModulesArtifacts(
public ResponseEntity<List<org.eclipse.hawkbit.ddi.json.model.DdiArtifact>> getSoftwareModulesArtifacts(
@PathVariable final String targetid, @PathVariable final Long softwareModuleId) {
LOG.debug("getSoftwareModulesArtifacts({})", targetid);
@@ -107,7 +107,7 @@ public class RootController implements RootControllerDdiApi {
}
@Override
public ResponseEntity<ControllerBase> getControllerBase(@PathVariable final String targetid,
public ResponseEntity<DdiControllerBase> getControllerBase(@PathVariable final String targetid,
final HttpServletRequest request) {
LOG.debug("getControllerBase({})", targetid);
@@ -206,7 +206,7 @@ public class RootController implements RootControllerDdiApi {
}
@Override
public ResponseEntity<DeploymentBase> getControllerBasedeploymentAction(
public ResponseEntity<DdiDeploymentBase> getControllerBasedeploymentAction(
@PathVariable @NotEmpty final String targetid, @PathVariable @NotEmpty final Long actionId,
@RequestParam(value = "c", required = false, defaultValue = "-1") final int resource,
final HttpServletRequest request) {
@@ -223,12 +223,12 @@ public class RootController implements RootControllerDdiApi {
if (!action.isCancelingOrCanceled()) {
final List<Chunk> chunks = DataConversionHelper.createChunks(targetid, action, artifactUrlHandler);
final List<DdiChunk> chunks = DataConversionHelper.createChunks(targetid, action, artifactUrlHandler);
final HandlingType handlingType = action.isForce() ? HandlingType.FORCED : HandlingType.ATTEMPT;
final DeploymentBase base = new DeploymentBase(Long.toString(action.getId()),
new Deployment(handlingType, handlingType, chunks));
final DdiDeploymentBase base = new DdiDeploymentBase(Long.toString(action.getId()),
new DdiDeployment(handlingType, handlingType, chunks));
LOG.debug("Found an active UpdateAction for target {}. returning deyploment: {}", targetid, base);
@@ -242,7 +242,7 @@ public class RootController implements RootControllerDdiApi {
}
@Override
public ResponseEntity<Void> postBasedeploymentActionFeedback(@Valid @RequestBody final ActionFeedback feedback,
public ResponseEntity<Void> postBasedeploymentActionFeedback(@Valid @RequestBody final DdiActionFeedback feedback,
@PathVariable final String targetid, @PathVariable @NotEmpty final Long actionId,
final HttpServletRequest request) {
LOG.debug("provideBasedeploymentActionFeedback for target [{},{}]: {}", targetid, actionId, feedback);
@@ -277,7 +277,7 @@ public class RootController implements RootControllerDdiApi {
}
private ActionStatus generateUpdateStatus(final ActionFeedback feedback, final String targetid, final Long actionid,
private ActionStatus generateUpdateStatus(final DdiActionFeedback feedback, final String targetid, final Long actionid,
final Action action) {
final ActionStatus actionStatus = new ActionStatus();
@@ -317,7 +317,7 @@ public class RootController implements RootControllerDdiApi {
return actionStatus;
}
private static void handleDefaultUpdateStatus(final ActionFeedback feedback, final String targetid,
private static void handleDefaultUpdateStatus(final DdiActionFeedback feedback, final String targetid,
final Long actionid, final ActionStatus actionStatus) {
LOG.debug("Controller reported intermediate status (actionid: {}, targetid: {}) as we got {} report.", actionid,
targetid, feedback.getStatus().getExecution());
@@ -325,7 +325,7 @@ public class RootController implements RootControllerDdiApi {
actionStatus.addMessage("Controller reported: " + feedback.getStatus().getExecution());
}
private static void handleClosedUpdateStatus(final ActionFeedback feedback, final String targetid,
private static void handleClosedUpdateStatus(final DdiActionFeedback feedback, final String targetid,
final Long actionid, final ActionStatus actionStatus) {
LOG.debug("Controller reported closed (actionid: {}, targetid: {}) as we got {} report.", actionid, targetid,
feedback.getStatus().getExecution());
@@ -339,7 +339,7 @@ public class RootController implements RootControllerDdiApi {
}
@Override
public ResponseEntity<Void> putConfigData(@Valid @RequestBody final ConfigData configData,
public ResponseEntity<Void> putConfigData(@Valid @RequestBody final DdiConfigData configData,
@PathVariable final String targetid, final HttpServletRequest request) {
controllerManagement.updateLastTargetQuery(targetid,
IpUtil.getClientIpFromRequest(request, securityProperties.getClients().getRemoteIpHeader()));
@@ -350,7 +350,7 @@ public class RootController implements RootControllerDdiApi {
}
@Override
public ResponseEntity<Cancel> getControllerCancelAction(@PathVariable @NotEmpty final String targetid,
public ResponseEntity<DdiCancel> getControllerCancelAction(@PathVariable @NotEmpty final String targetid,
@PathVariable @NotEmpty final Long actionId, final HttpServletRequest request) {
LOG.debug("getControllerCancelAction({})", targetid);
@@ -364,8 +364,8 @@ public class RootController implements RootControllerDdiApi {
}
if (action.isCancelingOrCanceled()) {
final Cancel cancel = new Cancel(String.valueOf(action.getId()),
new CancelActionToStop(String.valueOf(action.getId())));
final DdiCancel cancel = new DdiCancel(String.valueOf(action.getId()),
new DdiCancelActionToStop(String.valueOf(action.getId())));
LOG.debug("Found an active CancelAction for target {}. returning cancel: {}", targetid, cancel);
@@ -379,7 +379,7 @@ public class RootController implements RootControllerDdiApi {
}
@Override
public ResponseEntity<Void> postCancelActionFeedback(@Valid @RequestBody final ActionFeedback feedback,
public ResponseEntity<Void> postCancelActionFeedback(@Valid @RequestBody final DdiActionFeedback feedback,
@PathVariable @NotEmpty final String targetid, @PathVariable @NotEmpty final Long actionId,
final HttpServletRequest request) {
LOG.debug("provideCancelActionFeedback for target [{}]: {}", targetid, feedback);
@@ -405,7 +405,7 @@ public class RootController implements RootControllerDdiApi {
return new ResponseEntity<>(HttpStatus.OK);
}
private static ActionStatus generateActionCancelStatus(final ActionFeedback feedback, final Target target,
private static ActionStatus generateActionCancelStatus(final DdiActionFeedback feedback, final Target target,
final Long actionid, final Action action) {
final ActionStatus actionStatus = new ActionStatus();
@@ -445,7 +445,7 @@ public class RootController implements RootControllerDdiApi {
}
private static void handleClosedCancelStatus(final ActionFeedback feedback, final ActionStatus actionStatus) {
private static void handleClosedCancelStatus(final DdiActionFeedback feedback, final ActionStatus actionStatus) {
if (feedback.getStatus().getResult().getFinished() == FinalResult.FAILURE) {
actionStatus.setStatus(Status.ERROR);
} else {