Removed http servlet response and request form method signature
Signed-off-by: Jonathan Philip Knoblauch <JonathanPhilip.Knoblauch@bosch-si.com>
This commit is contained in:
@@ -10,7 +10,7 @@ package org.eclipse.hawkbit.app;
|
||||
|
||||
import org.eclipse.hawkbit.RepositoryApplicationConfiguration;
|
||||
import org.eclipse.hawkbit.autoconfigure.security.EnableHawkbitManagedSecurityConfiguration;
|
||||
import org.eclipse.hawkbit.ddi.annotation.EnableDdiApi;
|
||||
import org.eclipse.hawkbit.ddi.EnableDdiApi;
|
||||
import org.eclipse.hawkbit.mgmt.annotation.EnableMgmtApi;
|
||||
import org.eclipse.hawkbit.system.annotation.EnableSystemApi;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
|
||||
@@ -3,9 +3,13 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.ddi.client;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.cloud.netflix.feign.EnableFeignClients;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
||||
import feign.Contract;
|
||||
|
||||
/**
|
||||
* @author Jonathan Knoblauch
|
||||
@@ -15,8 +19,31 @@ import org.springframework.cloud.netflix.feign.EnableFeignClients;
|
||||
@EnableFeignClients
|
||||
public class Application {
|
||||
|
||||
@Autowired
|
||||
private DdiClient ddiClient;
|
||||
|
||||
public static void main(final String[] args) {
|
||||
new SpringApplicationBuilder().showBanner(false).sources(Application.class).run(args);
|
||||
|
||||
// TODO .encoder(new JacksonEncoder())
|
||||
// .decoder(new ResponseEntityDecoder(new JacksonDecoder()));
|
||||
|
||||
}
|
||||
|
||||
// @Bean
|
||||
// public BasicAuthRequestInterceptor basicAuthRequestInterceptor() {
|
||||
// return new BasicAuthRequestInterceptor(configuration.getUsername(),
|
||||
// configuration.getPassword());
|
||||
// }
|
||||
|
||||
@Bean
|
||||
public ApplicationJsonRequestHeaderInterceptor jsonHeaderInterceptor() {
|
||||
return new ApplicationJsonRequestHeaderInterceptor();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Contract feignContract() {
|
||||
return new IgnoreMultipleConsumersProducersSpringMvcContract();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,15 +3,12 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.ddi.client;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.eclipse.hawkbit.ddi.client.resource.RootControllerResourceClient;
|
||||
import org.eclipse.hawkbit.ddi.json.model.DdiControllerBase;
|
||||
import org.eclipse.hawkbit.ddi.rest.api.DdiRestConstants;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cloud.netflix.feign.support.ResponseEntityDecoder;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import feign.Feign;
|
||||
import feign.Logger;
|
||||
@@ -19,13 +16,12 @@ import feign.Logger.Level;
|
||||
import feign.jackson.JacksonDecoder;
|
||||
import feign.jackson.JacksonEncoder;
|
||||
|
||||
@Component
|
||||
public class DdiClient {
|
||||
|
||||
@Autowired
|
||||
private HttpServletRequest request;
|
||||
|
||||
@Autowired
|
||||
private HttpServletResponse response;
|
||||
//
|
||||
// @Autowired
|
||||
// private HttpServletResponse response;
|
||||
|
||||
private final String controllerId;
|
||||
private final String name;
|
||||
@@ -65,14 +61,7 @@ public class DdiClient {
|
||||
|
||||
public void startDdiClient() {
|
||||
|
||||
// final HttpServletRequest request;
|
||||
|
||||
// final HttpSession mySession = request.getSession();
|
||||
|
||||
// final HttpServletRequest request = new;
|
||||
|
||||
final ResponseEntity<DdiControllerBase> response = rootControllerResourceClient.getControllerBase("test",
|
||||
request);
|
||||
final ResponseEntity<DdiControllerBase> response = rootControllerResourceClient.getControllerBase("test");
|
||||
final DdiControllerBase controllerBase = response.getBody();
|
||||
|
||||
// TODO notify every 10 seconds on the rollout server
|
||||
|
||||
@@ -11,7 +11,7 @@ public class AppTest {
|
||||
@Test
|
||||
public void AppTest() {
|
||||
|
||||
final DdiClient ddiClient = new DdiClient("localhost:8080", "mytest", "mytest", "desc", "DEFAULT");
|
||||
final DdiClient ddiClient = new DdiClient("http://localhost:8080", "mytest", "mytest", "desc", "DEFAULT");
|
||||
ddiClient.startDdiClient();
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.autoconfigure.web;
|
||||
|
||||
import org.eclipse.hawkbit.ddi.annotation.EnableDdiApi;
|
||||
import org.eclipse.hawkbit.ddi.EnableDdiApi;
|
||||
import org.eclipse.hawkbit.mgmt.annotation.EnableMgmtApi;
|
||||
import org.eclipse.hawkbit.system.annotation.EnableSystemApi;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
|
||||
@@ -8,9 +8,6 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.ddi.rest.api;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.eclipse.hawkbit.ddi.json.model.DdiArtifact;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
@@ -43,11 +40,10 @@ public interface DdiArtifactStoreControllerRestApi {
|
||||
* {@link HttpStatus#OK} or in case of partial download
|
||||
* {@link HttpStatus#PARTIAL_CONTENT}.
|
||||
*/
|
||||
@RequestMapping(method = RequestMethod.GET, value = DdiRestConstants.ARTIFACT_DOWNLOAD_BY_FILENAME
|
||||
+ "/{fileName}")
|
||||
@RequestMapping(method = RequestMethod.GET, value = DdiRestConstants.ARTIFACT_DOWNLOAD_BY_FILENAME + "/{fileName}")
|
||||
@ResponseBody
|
||||
public ResponseEntity<Void> downloadArtifactByFilename(@PathVariable("fileName") final String fileName,
|
||||
final HttpServletResponse response, final HttpServletRequest request,
|
||||
|
||||
@AuthenticationPrincipal final String targetid);
|
||||
|
||||
/**
|
||||
@@ -60,10 +56,9 @@ public interface DdiArtifactStoreControllerRestApi {
|
||||
*
|
||||
* @return response of the servlet
|
||||
*/
|
||||
@RequestMapping(method = RequestMethod.GET, value = DdiRestConstants.ARTIFACT_DOWNLOAD_BY_FILENAME
|
||||
+ "/{fileName}" + DdiRestConstants.ARTIFACT_MD5_DWNL_SUFFIX)
|
||||
@RequestMapping(method = RequestMethod.GET, value = DdiRestConstants.ARTIFACT_DOWNLOAD_BY_FILENAME + "/{fileName}"
|
||||
+ DdiRestConstants.ARTIFACT_MD5_DWNL_SUFFIX)
|
||||
@ResponseBody
|
||||
public ResponseEntity<Void> downloadArtifactMD5ByFilename(@PathVariable("fileName") final String fileName,
|
||||
final HttpServletResponse response);
|
||||
public ResponseEntity<Void> downloadArtifactMD5ByFilename(@PathVariable("fileName") final String fileName);
|
||||
|
||||
}
|
||||
|
||||
@@ -6,8 +6,6 @@ package org.eclipse.hawkbit.ddi.rest.api;
|
||||
import java.lang.annotation.Target;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
|
||||
import org.eclipse.hawkbit.ddi.json.model.DdiActionFeedback;
|
||||
@@ -60,8 +58,7 @@ public interface DdiRootControllerRestApi {
|
||||
*/
|
||||
@RequestMapping(method = RequestMethod.GET, value = "/{targetid}", produces = { "application/hal+json",
|
||||
MediaType.APPLICATION_JSON_VALUE })
|
||||
ResponseEntity<DdiControllerBase> getControllerBase(@PathVariable("targetid") final String targetid,
|
||||
final HttpServletRequest request);
|
||||
ResponseEntity<DdiControllerBase> getControllerBase(@PathVariable("targetid") final String targetid);
|
||||
|
||||
/**
|
||||
* Handles GET {@link DdiArtifact} download request. This could be full or
|
||||
@@ -85,8 +82,7 @@ public interface DdiRootControllerRestApi {
|
||||
@RequestMapping(method = RequestMethod.GET, value = "/{targetid}/softwaremodules/{softwareModuleId}/artifacts/{fileName}")
|
||||
ResponseEntity<Void> downloadArtifact(@PathVariable("targetid") final String targetid,
|
||||
@PathVariable("softwareModuleId") final Long softwareModuleId,
|
||||
@PathVariable("fileName") final String fileName, final HttpServletResponse response,
|
||||
final HttpServletRequest request);
|
||||
@PathVariable("fileName") final String fileName);
|
||||
|
||||
/**
|
||||
* Handles GET {@link DdiArtifact} MD5 checksum file download request.
|
||||
@@ -109,8 +105,7 @@ public interface DdiRootControllerRestApi {
|
||||
+ DdiRestConstants.ARTIFACT_MD5_DWNL_SUFFIX, produces = MediaType.TEXT_PLAIN_VALUE)
|
||||
ResponseEntity<Void> downloadArtifactMd5(@PathVariable("targetid") final String targetid,
|
||||
@PathVariable("softwareModuleId") final Long softwareModuleId,
|
||||
@PathVariable("fileName") final String fileName, final HttpServletResponse response,
|
||||
final HttpServletRequest request);
|
||||
@PathVariable("fileName") final String fileName);
|
||||
|
||||
/**
|
||||
* Resource for {@link SoftwareModule} {@link UpdateAction}s.
|
||||
@@ -134,8 +129,7 @@ public interface DdiRootControllerRestApi {
|
||||
ResponseEntity<DdiDeploymentBase> getControllerBasedeploymentAction(
|
||||
@PathVariable("targetid") @NotEmpty final String targetid,
|
||||
@PathVariable("actionId") @NotEmpty final Long actionId,
|
||||
@RequestParam(value = "c", required = false, defaultValue = "-1") final int resource,
|
||||
final HttpServletRequest request);
|
||||
@RequestParam(value = "c", required = false, defaultValue = "-1") final int resource);
|
||||
|
||||
/**
|
||||
* This is the feedback channel for the {@link DdiDeploymentBase} action.
|
||||
@@ -155,8 +149,7 @@ public interface DdiRootControllerRestApi {
|
||||
@RequestMapping(value = "/{targetid}/" + DdiRestConstants.DEPLOYMENT_BASE_ACTION + "/{actionId}/"
|
||||
+ DdiRestConstants.FEEDBACK, method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
ResponseEntity<Void> postBasedeploymentActionFeedback(@Valid @RequestBody final DdiActionFeedback feedback,
|
||||
@PathVariable("targetid") final String targetid, @PathVariable("actionId") @NotEmpty final Long actionId,
|
||||
final HttpServletRequest request);
|
||||
@PathVariable("targetid") final String targetid, @PathVariable("actionId") @NotEmpty final Long actionId);
|
||||
|
||||
/**
|
||||
* This is the feedback channel for the config data action.
|
||||
@@ -173,7 +166,7 @@ public interface DdiRootControllerRestApi {
|
||||
@RequestMapping(value = "/{targetid}/"
|
||||
+ DdiRestConstants.CONFIG_DATA_ACTION, method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
ResponseEntity<Void> putConfigData(@Valid @RequestBody final DdiConfigData configData,
|
||||
@PathVariable("targetid") final String targetid, final HttpServletRequest request);
|
||||
@PathVariable("targetid") final String targetid);
|
||||
|
||||
/**
|
||||
* {@link RequestMethod.GET} method for the {@link DdiCancel} action.
|
||||
@@ -190,7 +183,7 @@ public interface DdiRootControllerRestApi {
|
||||
@RequestMapping(value = "/{targetid}/" + DdiRestConstants.CANCEL_ACTION
|
||||
+ "/{actionId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
ResponseEntity<DdiCancel> getControllerCancelAction(@PathVariable("targetid") @NotEmpty final String targetid,
|
||||
@PathVariable("actionId") @NotEmpty final Long actionId, final HttpServletRequest request);
|
||||
@PathVariable("actionId") @NotEmpty final Long actionId);
|
||||
|
||||
/**
|
||||
* {@link RequestMethod.POST} method receiving the {@link DdiActionFeedback}
|
||||
@@ -212,6 +205,6 @@ public interface DdiRootControllerRestApi {
|
||||
+ DdiRestConstants.FEEDBACK, method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
ResponseEntity<Void> postCancelActionFeedback(@Valid @RequestBody final DdiActionFeedback feedback,
|
||||
@PathVariable("targetid") @NotEmpty final String targetid,
|
||||
@PathVariable("actionId") @NotEmpty final Long actionId, final HttpServletRequest request);
|
||||
@PathVariable("actionId") @NotEmpty final Long actionId);
|
||||
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.ddi.annotation;
|
||||
package org.eclipse.hawkbit.ddi;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
@@ -118,12 +118,12 @@ public final class DataConversionHelper {
|
||||
// change the payload of the
|
||||
// response because of eTags.
|
||||
result.add(linkTo(methodOn(DdiRootController.class, tenantAware.getCurrentTenant())
|
||||
.getControllerBasedeploymentAction(target.getControllerId(), action.getId(), actions.hashCode(),
|
||||
null)).withRel(DdiRestConstants.DEPLOYMENT_BASE_ACTION));
|
||||
.getControllerBasedeploymentAction(target.getControllerId(), action.getId(),
|
||||
actions.hashCode())).withRel(DdiRestConstants.DEPLOYMENT_BASE_ACTION));
|
||||
addedUpdate = true;
|
||||
} else if (action.isCancelingOrCanceled() && !addedCancel) {
|
||||
result.add(linkTo(methodOn(DdiRootController.class, tenantAware.getCurrentTenant())
|
||||
.getControllerCancelAction(target.getControllerId(), action.getId(), null))
|
||||
.getControllerCancelAction(target.getControllerId(), action.getId()))
|
||||
.withRel(DdiRestConstants.CANCEL_ACTION));
|
||||
addedCancel = true;
|
||||
}
|
||||
@@ -131,7 +131,7 @@ public final class DataConversionHelper {
|
||||
|
||||
if (target.getTargetInfo().isRequestControllerAttributes()) {
|
||||
result.add(linkTo(methodOn(DdiRootController.class, tenantAware.getCurrentTenant()).putConfigData(null,
|
||||
target.getControllerId(), null)).withRel(DdiRestConstants.CONFIG_DATA_ACTION));
|
||||
target.getControllerId())).withRel(DdiRestConstants.CONFIG_DATA_ACTION));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -35,6 +35,8 @@ import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.web.bind.annotation.AuthenticationPrincipal;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
/**
|
||||
* The {@link DdiArtifactStoreController} of the HawkBit server controller API
|
||||
@@ -61,10 +63,18 @@ public class DdiArtifactStoreController implements DdiArtifactStoreControllerRes
|
||||
@Autowired
|
||||
private HawkbitSecurityProperties securityProperties;
|
||||
|
||||
private HttpServletResponse getResponse() {
|
||||
return ((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes()).getResponse();
|
||||
}
|
||||
|
||||
private HttpServletRequest getRequest() {
|
||||
return ((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes()).getRequest();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Void> downloadArtifactByFilename(@PathVariable("fileName") final String fileName,
|
||||
final HttpServletResponse response, final HttpServletRequest request,
|
||||
@AuthenticationPrincipal final String targetid) {
|
||||
|
||||
ResponseEntity<Void> result;
|
||||
|
||||
final List<LocalArtifact> foundArtifacts = artifactManagement.findLocalArtifactByFilename(fileName);
|
||||
@@ -79,7 +89,7 @@ public class DdiArtifactStoreController implements DdiArtifactStoreControllerRes
|
||||
|
||||
final LocalArtifact artifact = foundArtifacts.get(0);
|
||||
|
||||
final String ifMatch = request.getHeader("If-Match");
|
||||
final String ifMatch = getRequest().getHeader("If-Match");
|
||||
if (ifMatch != null && !RestResourceConversionHelper.matchesHttpHeader(ifMatch, artifact.getSha1Hash())) {
|
||||
result = new ResponseEntity<>(HttpStatus.PRECONDITION_FAILED);
|
||||
} else {
|
||||
@@ -88,11 +98,12 @@ public class DdiArtifactStoreController implements DdiArtifactStoreControllerRes
|
||||
// we set a download status only if we are aware of the
|
||||
// targetid, i.e. authenticated and not anonymous
|
||||
if (targetid != null && !"anonymous".equals(targetid)) {
|
||||
final Action action = checkAndReportDownloadByTarget(request, targetid, artifact);
|
||||
result = RestResourceConversionHelper.writeFileResponse(artifact, response, request, file,
|
||||
final Action action = checkAndReportDownloadByTarget(getRequest(), targetid, artifact);
|
||||
result = RestResourceConversionHelper.writeFileResponse(artifact, getResponse(), getRequest(), file,
|
||||
cacheWriteNotify, action.getId());
|
||||
} else {
|
||||
result = RestResourceConversionHelper.writeFileResponse(artifact, response, request, file);
|
||||
result = RestResourceConversionHelper.writeFileResponse(artifact, getResponse(), getRequest(),
|
||||
file);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -101,8 +112,7 @@ public class DdiArtifactStoreController implements DdiArtifactStoreControllerRes
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Void> downloadArtifactMD5ByFilename(@PathVariable("fileName") final String fileName,
|
||||
final HttpServletResponse response) {
|
||||
public ResponseEntity<Void> downloadArtifactMD5ByFilename(@PathVariable("fileName") final String fileName) {
|
||||
final List<LocalArtifact> foundArtifacts = artifactManagement.findLocalArtifactByFilename(fileName);
|
||||
|
||||
if (foundArtifacts.isEmpty()) {
|
||||
@@ -113,7 +123,7 @@ public class DdiArtifactStoreController implements DdiArtifactStoreControllerRes
|
||||
}
|
||||
|
||||
try {
|
||||
DataConversionHelper.writeMD5FileResponse(fileName, response, foundArtifacts.get(0));
|
||||
DataConversionHelper.writeMD5FileResponse(fileName, getResponse(), foundArtifacts.get(0));
|
||||
} catch (final IOException e) {
|
||||
LOG.error("Failed to stream MD5 File", e);
|
||||
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
|
||||
@@ -54,6 +54,8 @@ import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
/**
|
||||
* The {@link DdiRootController} of the hawkBit server DDI API that is queried
|
||||
@@ -89,12 +91,22 @@ public class DdiRootController implements DdiRootControllerRestApi {
|
||||
@Autowired
|
||||
private ArtifactUrlHandler artifactUrlHandler;
|
||||
|
||||
private HttpServletResponse getResponse() {
|
||||
return ((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes()).getResponse();
|
||||
}
|
||||
|
||||
private HttpServletRequest getRequest() {
|
||||
return ((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes()).getRequest();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<List<org.eclipse.hawkbit.ddi.json.model.DdiArtifact>> getSoftwareModulesArtifacts(
|
||||
@PathVariable("targetid") final String targetid,
|
||||
@PathVariable("softwareModuleId") final Long softwareModuleId) {
|
||||
LOG.debug("getSoftwareModulesArtifacts({})", targetid);
|
||||
|
||||
// SecurityContextHolder.getContext().getAuthentication().
|
||||
|
||||
final SoftwareModule softwareModule = softwareManagement.findSoftwareModuleById(softwareModuleId);
|
||||
|
||||
if (softwareModule == null) {
|
||||
@@ -108,18 +120,17 @@ public class DdiRootController implements DdiRootControllerRestApi {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<DdiControllerBase> getControllerBase(@PathVariable("targetid") final String targetid,
|
||||
final HttpServletRequest request) {
|
||||
public ResponseEntity<DdiControllerBase> getControllerBase(@PathVariable("targetid") final String targetid) {
|
||||
LOG.debug("getControllerBase({})", targetid);
|
||||
|
||||
final Target target = controllerManagement.findOrRegisterTargetIfItDoesNotexist(targetid,
|
||||
IpUtil.getClientIpFromRequest(request, securityProperties.getClients().getRemoteIpHeader()));
|
||||
IpUtil.getClientIpFromRequest(getRequest(), securityProperties.getClients().getRemoteIpHeader()));
|
||||
|
||||
if (target.getTargetInfo().getUpdateStatus() == TargetUpdateStatus.UNKNOWN) {
|
||||
LOG.debug("target with {} extsisted but was in status UNKNOWN -> REGISTERED)", targetid);
|
||||
controllerManagement.updateTargetStatus(target.getTargetInfo(), TargetUpdateStatus.REGISTERED,
|
||||
System.currentTimeMillis(),
|
||||
IpUtil.getClientIpFromRequest(request, securityProperties.getClients().getRemoteIpHeader()));
|
||||
IpUtil.getClientIpFromRequest(getRequest(), securityProperties.getClients().getRemoteIpHeader()));
|
||||
}
|
||||
|
||||
return new ResponseEntity<>(
|
||||
@@ -131,12 +142,11 @@ public class DdiRootController implements DdiRootControllerRestApi {
|
||||
@Override
|
||||
public ResponseEntity<Void> downloadArtifact(@PathVariable("targetid") final String targetid,
|
||||
@PathVariable("softwareModuleId") final Long softwareModuleId,
|
||||
@PathVariable("fileName") final String fileName, final HttpServletResponse response,
|
||||
final HttpServletRequest request) {
|
||||
@PathVariable("fileName") final String fileName) {
|
||||
ResponseEntity<Void> result;
|
||||
|
||||
final Target target = controllerManagement.updateLastTargetQuery(targetid,
|
||||
IpUtil.getClientIpFromRequest(request, securityProperties.getClients().getRemoteIpHeader()));
|
||||
IpUtil.getClientIpFromRequest(getRequest(), securityProperties.getClients().getRemoteIpHeader()));
|
||||
final SoftwareModule module = softwareManagement.findSoftwareModuleById(softwareModuleId);
|
||||
|
||||
if (checkModule(fileName, module)) {
|
||||
@@ -146,12 +156,12 @@ public class DdiRootController implements DdiRootControllerRestApi {
|
||||
final LocalArtifact artifact = module.getLocalArtifactByFilename(fileName).get();
|
||||
final DbArtifact file = artifactManagement.loadLocalArtifactBinary(artifact);
|
||||
|
||||
final String ifMatch = request.getHeader("If-Match");
|
||||
final String ifMatch = getRequest().getHeader("If-Match");
|
||||
if (ifMatch != null && !RestResourceConversionHelper.matchesHttpHeader(ifMatch, artifact.getSha1Hash())) {
|
||||
result = new ResponseEntity<>(HttpStatus.PRECONDITION_FAILED);
|
||||
} else {
|
||||
final Action action = checkAndLogDownload(request, target, module);
|
||||
result = RestResourceConversionHelper.writeFileResponse(artifact, response, request, file,
|
||||
final Action action = checkAndLogDownload(getRequest(), target, module);
|
||||
result = RestResourceConversionHelper.writeFileResponse(artifact, getResponse(), getRequest(), file,
|
||||
cacheWriteNotify, action.getId());
|
||||
}
|
||||
}
|
||||
@@ -185,10 +195,9 @@ public class DdiRootController implements DdiRootControllerRestApi {
|
||||
@Override
|
||||
public ResponseEntity<Void> downloadArtifactMd5(@PathVariable("targetid") final String targetid,
|
||||
@PathVariable("softwareModuleId") final Long softwareModuleId,
|
||||
@PathVariable("fileName") final String fileName, final HttpServletResponse response,
|
||||
final HttpServletRequest request) {
|
||||
@PathVariable("fileName") final String fileName) {
|
||||
controllerManagement.updateLastTargetQuery(targetid,
|
||||
IpUtil.getClientIpFromRequest(request, securityProperties.getClients().getRemoteIpHeader()));
|
||||
IpUtil.getClientIpFromRequest(getRequest(), securityProperties.getClients().getRemoteIpHeader()));
|
||||
|
||||
final SoftwareModule module = softwareManagement.findSoftwareModuleById(softwareModuleId);
|
||||
|
||||
@@ -198,7 +207,7 @@ public class DdiRootController implements DdiRootControllerRestApi {
|
||||
}
|
||||
|
||||
try {
|
||||
DataConversionHelper.writeMD5FileResponse(fileName, response,
|
||||
DataConversionHelper.writeMD5FileResponse(fileName, getResponse(),
|
||||
module.getLocalArtifactByFilename(fileName).get());
|
||||
} catch (final IOException e) {
|
||||
LOG.error("Failed to stream MD5 File", e);
|
||||
@@ -211,12 +220,11 @@ public class DdiRootController implements DdiRootControllerRestApi {
|
||||
@Override
|
||||
public ResponseEntity<DdiDeploymentBase> getControllerBasedeploymentAction(
|
||||
@PathVariable("targetid") final String targetid, @PathVariable("actionId") final Long actionId,
|
||||
@RequestParam(value = "c", required = false, defaultValue = "-1") final int resource,
|
||||
final HttpServletRequest request) {
|
||||
@RequestParam(value = "c", required = false, defaultValue = "-1") final int resource) {
|
||||
LOG.debug("getControllerBasedeploymentAction({},{})", targetid, resource);
|
||||
|
||||
final Target target = controllerManagement.updateLastTargetQuery(targetid,
|
||||
IpUtil.getClientIpFromRequest(request, securityProperties.getClients().getRemoteIpHeader()));
|
||||
IpUtil.getClientIpFromRequest(getRequest(), securityProperties.getClients().getRemoteIpHeader()));
|
||||
|
||||
final Action action = findActionWithExceptionIfNotFound(actionId);
|
||||
if (!action.getTarget().getId().equals(target.getId())) {
|
||||
@@ -246,12 +254,11 @@ public class DdiRootController implements DdiRootControllerRestApi {
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Void> postBasedeploymentActionFeedback(@Valid @RequestBody final DdiActionFeedback feedback,
|
||||
@PathVariable("targetid") final String targetid, @PathVariable("actionId") @NotEmpty final Long actionId,
|
||||
final HttpServletRequest request) {
|
||||
@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.getClientIpFromRequest(request, securityProperties.getClients().getRemoteIpHeader()));
|
||||
IpUtil.getClientIpFromRequest(getRequest(), securityProperties.getClients().getRemoteIpHeader()));
|
||||
|
||||
if (!actionId.equals(feedback.getId())) {
|
||||
LOG.warn(
|
||||
@@ -343,9 +350,9 @@ public class DdiRootController implements DdiRootControllerRestApi {
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Void> putConfigData(@Valid @RequestBody final DdiConfigData configData,
|
||||
@PathVariable("targetid") final String targetid, final HttpServletRequest request) {
|
||||
@PathVariable("targetid") final String targetid) {
|
||||
controllerManagement.updateLastTargetQuery(targetid,
|
||||
IpUtil.getClientIpFromRequest(request, securityProperties.getClients().getRemoteIpHeader()));
|
||||
IpUtil.getClientIpFromRequest(getRequest(), securityProperties.getClients().getRemoteIpHeader()));
|
||||
|
||||
controllerManagement.updateControllerAttributes(targetid, configData.getData());
|
||||
|
||||
@@ -355,11 +362,11 @@ public class DdiRootController implements DdiRootControllerRestApi {
|
||||
@Override
|
||||
public ResponseEntity<DdiCancel> getControllerCancelAction(
|
||||
@PathVariable("targetid") @NotEmpty final String targetid,
|
||||
@PathVariable("actionId") @NotEmpty final Long actionId, final HttpServletRequest request) {
|
||||
@PathVariable("actionId") @NotEmpty final Long actionId) {
|
||||
LOG.debug("getControllerCancelAction({})", targetid);
|
||||
|
||||
final Target target = controllerManagement.updateLastTargetQuery(targetid,
|
||||
IpUtil.getClientIpFromRequest(request, securityProperties.getClients().getRemoteIpHeader()));
|
||||
IpUtil.getClientIpFromRequest(getRequest(), securityProperties.getClients().getRemoteIpHeader()));
|
||||
|
||||
final Action action = findActionWithExceptionIfNotFound(actionId);
|
||||
if (!action.getTarget().getId().equals(target.getId())) {
|
||||
@@ -385,11 +392,11 @@ public class DdiRootController implements DdiRootControllerRestApi {
|
||||
@Override
|
||||
public ResponseEntity<Void> postCancelActionFeedback(@Valid @RequestBody final DdiActionFeedback feedback,
|
||||
@PathVariable("targetid") @NotEmpty final String targetid,
|
||||
@PathVariable("actionId") @NotEmpty final Long actionId, final HttpServletRequest request) {
|
||||
@PathVariable("actionId") @NotEmpty final Long actionId) {
|
||||
LOG.debug("provideCancelActionFeedback for target [{}]: {}", targetid, feedback);
|
||||
|
||||
final Target target = controllerManagement.updateLastTargetQuery(targetid,
|
||||
IpUtil.getClientIpFromRequest(request, securityProperties.getClients().getRemoteIpHeader()));
|
||||
IpUtil.getClientIpFromRequest(getRequest(), securityProperties.getClients().getRemoteIpHeader()));
|
||||
|
||||
if (!actionId.equals(feedback.getId())) {
|
||||
LOG.warn(
|
||||
|
||||
Reference in New Issue
Block a user