Skip to content

Commit

Permalink
Merge pull request eclipse-hawkbit#291 from bsinno/fix_mgmt_feign
Browse files Browse the repository at this point in the history
Adapt DDI interfaces to new feign version
  • Loading branch information
kaizimmerm authored Sep 14, 2016
2 parents d59065a + e7ee5ee commit b50fa13
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@
package org.eclipse.hawkbit.ddi.client.resource;

import org.eclipse.hawkbit.ddi.dl.rest.api.DdiDlArtifactStoreControllerRestApi;
import org.eclipse.hawkbit.ddi.dl.rest.api.DdiDlRestConstants;
import org.springframework.cloud.netflix.feign.FeignClient;

/**
* Client binding for the artifact store controller resource of the DDI-DL API.
*/
@FeignClient(url = "${hawkbit.url:localhost:8080}/" + DdiDlRestConstants.ARTIFACTS_V1_REQUEST_MAPPING)
@FeignClient(name = "DdiDlArtifactStoreControllerClient", url = "${hawkbit.url:localhost:8080}")
public interface DdiDlArtifactStoreControllerResourceClient extends DdiDlArtifactStoreControllerRestApi {

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@
*/
package org.eclipse.hawkbit.ddi.client.resource;

import org.eclipse.hawkbit.ddi.rest.api.DdiRestConstants;
import org.eclipse.hawkbit.ddi.rest.api.DdiRootControllerRestApi;
import org.springframework.cloud.netflix.feign.FeignClient;

/**
* Client binding for the Rootcontroller resource of the DDI API.
*/
@FeignClient(url = "${hawkbit.url:localhost:8080}/" + DdiRestConstants.BASE_V1_REQUEST_MAPPING)
@FeignClient(name = "RootControllerClient", url = "${hawkbit.url:localhost:8080}")
public interface RootControllerResourceClient extends DdiRootControllerRestApi {

}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public interface DdiRootControllerRestApi {
@RequestMapping(method = RequestMethod.GET, value = "/{targetid}/softwaremodules/{softwareModuleId}/artifacts", produces = {
"application/hal+json", MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<List<org.eclipse.hawkbit.ddi.json.model.DdiArtifact>> getSoftwareModulesArtifacts(
@PathVariable("targetid") final String targetid,
@PathVariable("tenant") final String tenant, @PathVariable("targetid") final String targetid,
@PathVariable("softwareModuleId") final Long softwareModuleId);

/**
Expand All @@ -61,7 +61,8 @@ ResponseEntity<List<org.eclipse.hawkbit.ddi.json.model.DdiArtifact>> getSoftware
*/
@RequestMapping(method = RequestMethod.GET, value = "/{targetid}", produces = { "application/hal+json",
MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<DdiControllerBase> getControllerBase(@PathVariable("targetid") final String targetid);
ResponseEntity<DdiControllerBase> getControllerBase(@PathVariable("tenant") final String tenant,
@PathVariable("targetid") final String targetid);

/**
* Handles GET {@link DdiArtifact} download request. This could be full or
Expand All @@ -83,7 +84,8 @@ ResponseEntity<List<org.eclipse.hawkbit.ddi.json.model.DdiArtifact>> getSoftware
* {@link HttpStatus#PARTIAL_CONTENT}.
*/
@RequestMapping(method = RequestMethod.GET, value = "/{targetid}/softwaremodules/{softwareModuleId}/artifacts/{fileName}")
ResponseEntity<InputStream> downloadArtifact(@PathVariable("targetid") final String targetid,
ResponseEntity<InputStream> downloadArtifact(@PathVariable("tenant") final String tenant,
@PathVariable("targetid") final String targetid,
@PathVariable("softwareModuleId") final Long softwareModuleId,
@PathVariable("fileName") final String fileName);

Expand All @@ -106,7 +108,8 @@ ResponseEntity<InputStream> downloadArtifact(@PathVariable("targetid") final Str
*/
@RequestMapping(method = RequestMethod.GET, value = "/{targetid}/softwaremodules/{softwareModuleId}/artifacts/{fileName}"
+ DdiRestConstants.ARTIFACT_MD5_DWNL_SUFFIX, produces = MediaType.TEXT_PLAIN_VALUE)
ResponseEntity<Void> downloadArtifactMd5(@PathVariable("targetid") final String targetid,
ResponseEntity<Void> downloadArtifactMd5(@PathVariable("tenant") final String tenant,
@PathVariable("targetid") final String targetid,
@PathVariable("softwareModuleId") final Long softwareModuleId,
@PathVariable("fileName") final String fileName);

Expand All @@ -128,7 +131,7 @@ ResponseEntity<Void> downloadArtifactMd5(@PathVariable("targetid") final String
*/
@RequestMapping(value = "/{targetid}/" + DdiRestConstants.DEPLOYMENT_BASE_ACTION
+ "/{actionId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
ResponseEntity<DdiDeploymentBase> getControllerBasedeploymentAction(
ResponseEntity<DdiDeploymentBase> getControllerBasedeploymentAction(@PathVariable("tenant") final String tenant,
@PathVariable("targetid") @NotEmpty final String targetid,
@PathVariable("actionId") @NotEmpty final Long actionId,
@RequestParam(value = "c", required = false, defaultValue = "-1") final int resource);
Expand All @@ -149,8 +152,9 @@ ResponseEntity<DdiDeploymentBase> getControllerBasedeploymentAction(
*/
@RequestMapping(value = "/{targetid}/" + DdiRestConstants.DEPLOYMENT_BASE_ACTION + "/{actionId}/"
+ DdiRestConstants.FEEDBACK, method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
ResponseEntity<Void> postBasedeploymentActionFeedback(@Valid final DdiActionFeedback feedback,
@PathVariable("targetid") final String targetid, @PathVariable("actionId") @NotEmpty final Long actionId);
ResponseEntity<Void> postBasedeploymentActionFeedback(@PathVariable("tenant") final String tenant,
@Valid final DdiActionFeedback feedback, @PathVariable("targetid") final String targetid,
@PathVariable("actionId") @NotEmpty final Long actionId);

/**
* This is the feedback channel for the config data action.
Expand All @@ -166,8 +170,8 @@ ResponseEntity<Void> postBasedeploymentActionFeedback(@Valid final DdiActionFeed
*/
@RequestMapping(value = "/{targetid}/"
+ DdiRestConstants.CONFIG_DATA_ACTION, method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE)
ResponseEntity<Void> putConfigData(@Valid final DdiConfigData configData,
@PathVariable("targetid") final String targetid);
ResponseEntity<Void> putConfigData(@PathVariable("tenant") final String tenant,
@Valid final DdiConfigData configData, @PathVariable("targetid") final String targetid);

/**
* RequestMethod.GET method for the {@link DdiCancel} action.
Expand All @@ -183,7 +187,8 @@ ResponseEntity<Void> putConfigData(@Valid final DdiConfigData configData,
*/
@RequestMapping(value = "/{targetid}/" + DdiRestConstants.CANCEL_ACTION
+ "/{actionId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
ResponseEntity<DdiCancel> getControllerCancelAction(@PathVariable("targetid") @NotEmpty final String targetid,
ResponseEntity<DdiCancel> getControllerCancelAction(@PathVariable("tenant") final String tenant,
@PathVariable("targetid") @NotEmpty final String targetid,
@PathVariable("actionId") @NotEmpty final Long actionId);

/**
Expand All @@ -204,8 +209,8 @@ ResponseEntity<DdiCancel> getControllerCancelAction(@PathVariable("targetid") @N

@RequestMapping(value = "/{targetid}/" + DdiRestConstants.CANCEL_ACTION + "/{actionId}/"
+ DdiRestConstants.FEEDBACK, method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
ResponseEntity<Void> postCancelActionFeedback(@Valid final DdiActionFeedback feedback,
@PathVariable("targetid") @NotEmpty final String targetid,
ResponseEntity<Void> postCancelActionFeedback(@PathVariable("tenant") final String tenant,
@Valid final DdiActionFeedback feedback, @PathVariable("targetid") @NotEmpty final String targetid,
@PathVariable("actionId") @NotEmpty final Long actionId);

}
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ public interface DdiDlArtifactStoreControllerRestApi {
@RequestMapping(method = RequestMethod.GET, value = DdiDlRestConstants.ARTIFACT_DOWNLOAD_BY_FILENAME
+ "/{fileName}")
@ResponseBody
public ResponseEntity<InputStream> downloadArtifactByFilename(@PathVariable("fileName") final String fileName,
@AuthenticationPrincipal final String targetid);
public ResponseEntity<InputStream> downloadArtifactByFilename(@PathVariable("tenant") final String tenant,
@PathVariable("fileName") final String fileName, @AuthenticationPrincipal final String targetid);

/**
* Handles GET MD5 checksum file download request.
Expand All @@ -54,6 +54,7 @@ public ResponseEntity<InputStream> downloadArtifactByFilename(@PathVariable("fil
@RequestMapping(method = RequestMethod.GET, value = DdiDlRestConstants.ARTIFACT_DOWNLOAD_BY_FILENAME + "/{fileName}"
+ DdiDlRestConstants.ARTIFACT_MD5_DWNL_SUFFIX)
@ResponseBody
public ResponseEntity<Void> downloadArtifactMD5ByFilename(@PathVariable("fileName") final String fileName);
public ResponseEntity<Void> downloadArtifactMD5ByFilename(@PathVariable("tenant") final String tenant,
@PathVariable("fileName") final String fileName);

}
Original file line number Diff line number Diff line change
Expand Up @@ -115,24 +115,27 @@ static DdiControllerBase fromTarget(final Target target, final Optional<Action>

if (action.isPresent()) {
if (action.get().isCancelingOrCanceled()) {
result.add(linkTo(methodOn(DdiRootController.class, tenantAware.getCurrentTenant())
.getControllerCancelAction(target.getControllerId(), action.get().getId()))
.withRel(DdiRestConstants.CANCEL_ACTION));
result.add(linkTo(
methodOn(DdiRootController.class, tenantAware.getCurrentTenant()).getControllerCancelAction(
tenantAware.getCurrentTenant(), target.getControllerId(), action.get().getId()))
.withRel(DdiRestConstants.CANCEL_ACTION));
} else {
// we need to add the hashcode here of the actionWithStatus
// because the action might
// have changed from 'soft' to 'forced' type and we need to
// change the payload of the
// response because of eTags.
result.add(linkTo(methodOn(DdiRootController.class, tenantAware.getCurrentTenant())
.getControllerBasedeploymentAction(target.getControllerId(), action.get().getId(),
calculateEtag(action.get()))).withRel(DdiRestConstants.DEPLOYMENT_BASE_ACTION));
.getControllerBasedeploymentAction(tenantAware.getCurrentTenant(), target.getControllerId(),
action.get().getId(), calculateEtag(action.get())))
.withRel(DdiRestConstants.DEPLOYMENT_BASE_ACTION));
}
}

if (target.getTargetInfo().isRequestControllerAttributes()) {
result.add(linkTo(methodOn(DdiRootController.class, tenantAware.getCurrentTenant()).putConfigData(null,
target.getControllerId())).withRel(DdiRestConstants.CONFIG_DATA_ACTION));
result.add(linkTo(methodOn(DdiRootController.class, tenantAware.getCurrentTenant())
.putConfigData(tenantAware.getCurrentTenant(), null, target.getControllerId()))
.withRel(DdiRestConstants.CONFIG_DATA_ACTION));
}
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ public class DdiArtifactStoreController implements DdiDlArtifactStoreControllerR
private EntityFactory entityFactory;

@Override
public ResponseEntity<InputStream> downloadArtifactByFilename(@PathVariable("fileName") final String fileName,
@AuthenticationPrincipal final String targetid) {
public ResponseEntity<InputStream> downloadArtifactByFilename(@PathVariable("tenant") final String tenant,
@PathVariable("fileName") final String fileName, @AuthenticationPrincipal final String targetid) {
final List<LocalArtifact> foundArtifacts = artifactManagement.findLocalArtifactByFilename(fileName);

if (foundArtifacts.isEmpty()) {
Expand Down Expand Up @@ -110,7 +110,8 @@ public ResponseEntity<InputStream> downloadArtifactByFilename(@PathVariable("fil
}

@Override
public ResponseEntity<Void> downloadArtifactMD5ByFilename(@PathVariable("fileName") final String fileName) {
public ResponseEntity<Void> downloadArtifactMD5ByFilename(@PathVariable("tenant") final String tenant,
@PathVariable("fileName") final String fileName) {
final List<LocalArtifact> foundArtifacts = artifactManagement.findLocalArtifactByFilename(fileName);

if (foundArtifacts.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public class DdiRootController implements DdiRootControllerRestApi {

@Override
public ResponseEntity<List<org.eclipse.hawkbit.ddi.json.model.DdiArtifact>> getSoftwareModulesArtifacts(
@PathVariable("targetid") final String targetid,
@PathVariable("tenant") final String tenant, @PathVariable("targetid") final String targetid,
@PathVariable("softwareModuleId") final Long softwareModuleId) {
LOG.debug("getSoftwareModulesArtifacts({})", targetid);

Expand All @@ -116,7 +116,8 @@ public ResponseEntity<List<org.eclipse.hawkbit.ddi.json.model.DdiArtifact>> getS
}

@Override
public ResponseEntity<DdiControllerBase> getControllerBase(@PathVariable("targetid") final String targetid) {
public ResponseEntity<DdiControllerBase> getControllerBase(@PathVariable("tenant") final String tenant,
@PathVariable("targetid") final String targetid) {
LOG.debug("getControllerBase({})", targetid);

final Target target = controllerManagement.findOrRegisterTargetIfItDoesNotexist(targetid, IpUtil
Expand All @@ -136,7 +137,8 @@ public ResponseEntity<DdiControllerBase> getControllerBase(@PathVariable("target
}

@Override
public ResponseEntity<InputStream> downloadArtifact(@PathVariable("targetid") final String targetid,
public ResponseEntity<InputStream> downloadArtifact(@PathVariable("tenant") final String tenant,
@PathVariable("targetid") final String targetid,
@PathVariable("softwareModuleId") final Long softwareModuleId,
@PathVariable("fileName") final String fileName) {
ResponseEntity<InputStream> result;
Expand Down Expand Up @@ -194,7 +196,8 @@ private static boolean checkModule(final String fileName, final SoftwareModule m
}

@Override
public ResponseEntity<Void> downloadArtifactMd5(@PathVariable("targetid") final String targetid,
public ResponseEntity<Void> downloadArtifactMd5(@PathVariable("tenant") final String tenant,
@PathVariable("targetid") final String targetid,
@PathVariable("softwareModuleId") final Long softwareModuleId,
@PathVariable("fileName") final String fileName) {
controllerManagement.updateLastTargetQuery(targetid, IpUtil
Expand All @@ -220,7 +223,8 @@ public ResponseEntity<Void> downloadArtifactMd5(@PathVariable("targetid") final

@Override
public ResponseEntity<DdiDeploymentBase> getControllerBasedeploymentAction(
@PathVariable("targetid") final String targetid, @PathVariable("actionId") final Long actionId,
@PathVariable("tenant") final String tenant, @PathVariable("targetid") final String targetid,
@PathVariable("actionId") final Long actionId,
@RequestParam(value = "c", required = false, defaultValue = "-1") final int resource) {
LOG.debug("getControllerBasedeploymentAction({},{})", targetid, resource);

Expand Down Expand Up @@ -254,8 +258,9 @@ public ResponseEntity<DdiDeploymentBase> getControllerBasedeploymentAction(
}

@Override
public ResponseEntity<Void> postBasedeploymentActionFeedback(@Valid @RequestBody final DdiActionFeedback feedback,
@PathVariable("targetid") final String targetid, @PathVariable("actionId") @NotEmpty final Long actionId) {
public ResponseEntity<Void> postBasedeploymentActionFeedback(@PathVariable("tenant") final String tenant,
@Valid @RequestBody final DdiActionFeedback feedback, @PathVariable("targetid") final String targetid,
@PathVariable("actionId") @NotEmpty final Long actionId) {
LOG.debug("provideBasedeploymentActionFeedback for target [{},{}]: {}", targetid, actionId, feedback);

final Target target = controllerManagement.updateLastTargetQuery(targetid, IpUtil
Expand Down Expand Up @@ -349,8 +354,8 @@ private static void handleClosedUpdateStatus(final DdiActionFeedback feedback, f
}

@Override
public ResponseEntity<Void> putConfigData(@Valid @RequestBody final DdiConfigData configData,
@PathVariable("targetid") final String targetid) {
public ResponseEntity<Void> putConfigData(@PathVariable("tenant") final String tenant,
@Valid @RequestBody final DdiConfigData configData, @PathVariable("targetid") final String targetid) {
controllerManagement.updateLastTargetQuery(targetid, IpUtil
.getClientIpFromRequest(requestResponseContextHolder.getHttpServletRequest(), securityProperties));

Expand All @@ -360,7 +365,7 @@ public ResponseEntity<Void> putConfigData(@Valid @RequestBody final DdiConfigDat
}

@Override
public ResponseEntity<DdiCancel> getControllerCancelAction(
public ResponseEntity<DdiCancel> getControllerCancelAction(@PathVariable("tenant") final String tenant,
@PathVariable("targetid") @NotEmpty final String targetid,
@PathVariable("actionId") @NotEmpty final Long actionId) {
LOG.debug("getControllerCancelAction({})", targetid);
Expand Down Expand Up @@ -390,7 +395,8 @@ public ResponseEntity<DdiCancel> getControllerCancelAction(
}

@Override
public ResponseEntity<Void> postCancelActionFeedback(@Valid @RequestBody final DdiActionFeedback feedback,
public ResponseEntity<Void> postCancelActionFeedback(@PathVariable("tenant") final String tenant,
@Valid @RequestBody final DdiActionFeedback feedback,
@PathVariable("targetid") @NotEmpty final String targetid,
@PathVariable("actionId") @NotEmpty final Long actionId) {
LOG.debug("provideCancelActionFeedback for target [{}]: {}", targetid, feedback);
Expand Down

0 comments on commit b50fa13

Please sign in to comment.