use of alien4cloud.model.application.Application in project alien4cloud by alien4cloud.
the class ApplicationTopologyVersionController method delete.
@ApiOperation(value = "Delete an application topology version from its id", notes = "The logged-in user must have the application manager role for this application. Application role required [ APPLICATION_MANAGER ]")
@RequestMapping(value = "/{topologyVersion:.+}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE)
@PreAuthorize("isAuthenticated()")
@Audit
public RestResponse<Void> delete(@PathVariable String applicationId, @PathVariable String applicationVersionId, @PathVariable String topologyVersion) {
Application application = applicationService.getOrFail(applicationId);
AuthorizationUtil.checkAuthorizationForApplication(application, ApplicationRole.APPLICATION_MANAGER);
applicationVersionService.deleteTopologyVersion(applicationId, applicationVersionId, topologyVersion);
return RestResponseBuilder.<Void>builder().build();
}
use of alien4cloud.model.application.Application in project alien4cloud by alien4cloud.
the class ApplicationVersionController method search.
/**
* Search application versions for a given application id
*
* @param applicationId the targeted application id
* @param searchRequest
* @return A rest response that contains a {@link FacetedSearchResult} containing application versions for an application id sorted by version
*/
@ApiOperation(value = "Search application versions", notes = "Returns a search result with that contains application versions matching the request. A application version is returned only if the connected user has at least one application role in [ APPLICATION_MANAGER | APPLICATION_USER | APPLICATION_DEVOPS | DEPLOYMENT_MANAGER ]")
@RequestMapping(value = "/search", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@PreAuthorize("isAuthenticated()")
public RestResponse<GetMultipleDataResult<ApplicationVersion>> search(@PathVariable String applicationId, @RequestBody FilteredSearchRequest searchRequest) {
Application application = applicationService.getOrFail(applicationId);
AuthorizationUtil.checkAuthorizationForApplication(application, ApplicationRole.values());
GetMultipleDataResult<ApplicationVersion> searchResult = appVersionService.search(applicationId, searchRequest.getQuery(), searchRequest.getFrom(), searchRequest.getSize());
return RestResponseBuilder.<GetMultipleDataResult<ApplicationVersion>>builder().data(searchResult).build();
}
use of alien4cloud.model.application.Application in project alien4cloud by alien4cloud.
the class ApplicationVersionController method create.
/**
* Create a new application version for an application.
*
* @param request data to create an application environment
* @return application environment id
*/
@ApiOperation(value = "Create a new application version.", notes = "If successfull returns a rest response with the id of the created application version in data. If not successful a rest response with an error content is returned. Application role required [ APPLICATIONS_MANAGER ]. " + "By default the application version creator will have application roles [APPLICATION_MANAGER]")
@RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(value = HttpStatus.CREATED)
@PreAuthorize("isAuthenticated()")
@Audit
public RestResponse<String> create(@PathVariable String applicationId, @RequestBody CreateApplicationVersionRequest request) {
Application application = applicationService.getOrFail(applicationId);
AuthorizationUtil.checkAuthorizationForApplication(application, ApplicationRole.APPLICATION_MANAGER);
String originalId = request.getTopologyTemplateId();
boolean originalIsAppVersion = false;
if (originalId == null) {
originalId = request.getFromVersionId();
originalIsAppVersion = true;
} else if (request.getFromVersionId() != null) {
throw new IllegalArgumentException("topologyTemplateId and fromVersionId are mutually exclusive.");
}
ApplicationVersion appVersion = appVersionService.createApplicationVersion(applicationId, request.getVersion(), request.getDescription(), originalId, originalIsAppVersion);
return RestResponseBuilder.<String>builder().data(appVersion.getId()).build();
}
use of alien4cloud.model.application.Application in project alien4cloud by alien4cloud.
the class ApplicationVersionController method get.
/**
* Get most recent snapshot application version for an application
*
* @param applicationId The application id.
*/
@ApiOperation(value = "Get the first snapshot application version for an application.", notes = "Return the first snapshot application version for an application. Application role required [ APPLICATION_MANAGER | APPLICATION_USER | APPLICATION_DEVOPS | DEPLOYMENT_MANAGER ]")
@RequestMapping(method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@PreAuthorize("isAuthenticated()")
public RestResponse<ApplicationVersion> get(@PathVariable String applicationId) {
Application application = alienDAO.findById(Application.class, applicationId);
AuthorizationUtil.checkAuthorizationForApplication(application, ApplicationRole.values());
return RestResponseBuilder.<ApplicationVersion>builder().data(appVersionService.getLatestSnapshot(applicationId)).build();
}
use of alien4cloud.model.application.Application in project alien4cloud by alien4cloud.
the class ApplicationsDeploymentStepDefinitions method I_should_not_get_a_deployment_if_I_ask_one_for_application.
@Then("^I should not get a deployment if I ask one for application \"([^\"]*)\" on orchestrator \"([^\"]*)\"$")
public void I_should_not_get_a_deployment_if_I_ask_one_for_application(String applicationName, String orchestrator) throws Throwable {
String orchestratorId = Context.getInstance().getOrchestratorId(orchestrator);
assertNotNull(ApplicationStepDefinitions.CURRENT_APPLICATIONS);
Application app = ApplicationStepDefinitions.CURRENT_APPLICATIONS.get(applicationName);
NameValuePair nvp = new BasicNameValuePair("sourceId", app.getId());
NameValuePair nvp1 = new BasicNameValuePair("orchestratorId", orchestratorId);
String responseString = Context.getRestClientInstance().getUrlEncoded("/rest/v1/deployments", Lists.newArrayList(nvp, nvp1));
RestResponse<?> response = JsonUtil.read(responseString);
assertNull(response.getError());
List<DeploymentDTO> deployments = JsonUtil.toList(JsonUtil.toString(response.getData()), DeploymentDTO.class, Application.class, Context.getJsonMapper());
Assert.assertTrue(CollectionUtils.isEmpty(deployments));
}
Aggregations