use of alien4cloud.model.application.Application in project alien4cloud by alien4cloud.
the class ApplicationVersionController method update.
/**
* Update application version
*
* @param applicationId The id of the application for which to update a version.
* @param applicationVersionId The id of the application version.
* @param request The update request that eventually contains a new name and description.
* @return A void rest response with no error.
*/
@ApiOperation(value = "Updates by merging the given request into the given application version", notes = "Updates by merging the given request into the given application version. Application role required [ APPLICATION_MANAGER ]")
@RequestMapping(value = "/{applicationVersionId:.+}", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@PreAuthorize("isAuthenticated()")
@Audit
public RestResponse<Void> update(@PathVariable String applicationId, @PathVariable String applicationVersionId, @RequestBody UpdateApplicationVersionRequest request) {
Application application = applicationService.getOrFail(applicationId);
AuthorizationUtil.checkAuthorizationForApplication(application, ApplicationRole.APPLICATION_MANAGER);
appVersionService.update(applicationId, applicationVersionId, request.getVersion(), request.getDescription());
return RestResponseBuilder.<Void>builder().build();
}
use of alien4cloud.model.application.Application in project alien4cloud by alien4cloud.
the class ApplicationVersionController method delete.
/**
* Delete an application environment based on it's id. Should not be able to delete a deployed version.
*
* @param applicationId
* @param applicationVersionId
* @return boolean is delete
*/
@ApiOperation(value = "Delete an application 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 = "/{applicationVersionId:.+}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE)
@PreAuthorize("isAuthenticated()")
@Audit
public RestResponse<Boolean> delete(@PathVariable String applicationId, @PathVariable String applicationVersionId) {
Application application = applicationService.getOrFail(applicationId);
AuthorizationUtil.checkAuthorizationForApplication(application, ApplicationRole.APPLICATION_MANAGER);
appVersionService.delete(applicationVersionId);
return RestResponseBuilder.<Boolean>builder().data(true).build();
}
use of alien4cloud.model.application.Application in project alien4cloud by alien4cloud.
the class CsarService method generateTopologiesInfo.
/**
* Generate resources (application or template) related to a topology list
*
* @param topologies
* @return
*/
public List<Usage> generateTopologiesInfo(Topology[] topologies) {
List<Usage> resourceList = Lists.newArrayList();
List<Csar> topologiesCsar = getTopologiesCsar(topologies);
for (Csar csar : topologiesCsar) {
if (Objects.equals(csar.getDelegateType(), ArchiveDelegateType.APPLICATION.toString())) {
// get the related application
Application application = applicationService.checkAndGetApplication(csar.getDelegateId());
resourceList.add(new Usage(application.getName(), csar.getDelegateType(), csar.getDelegateId(), csar.getWorkspace()));
} else {
resourceList.add(new Usage(csar.getName() + "[" + csar.getVersion() + "]", "topologyTemplate", csar.getId(), csar.getWorkspace()));
}
}
return resourceList;
}
use of alien4cloud.model.application.Application in project alien4cloud by alien4cloud.
the class ApplicationStepDefinitions method I_have_applications_with_names_and_description.
@Given("^I have applications with names and descriptions$")
public void I_have_applications_with_names_and_description(DataTable applicationNames) throws Throwable {
CURRENT_APPLICATIONS.clear();
// Create each application and store in CURRENT_APPS
for (List<String> app : applicationNames.raw()) {
doCreateApplication(app.get(0), appToArchName(app.get(0)), app.get(1), null, true);
RestResponse<String> reponse = JsonUtil.read(Context.getInstance().getRestResponse(), String.class);
String applicationJson = getRestClientInstance().get("/rest/v1/applications/" + reponse.getData());
RestResponse<Application> application = JsonUtil.read(applicationJson, Application.class);
CURRENT_APPLICATIONS.put(app.get(0), application.getData());
Context.getInstance().registerApplicationId(application.getData().getName(), application.getData().getId());
setAppEnvironmentIdToContext(application.getData().getName());
}
assertEquals(CURRENT_APPLICATIONS.size(), applicationNames.raw().size());
}
use of alien4cloud.model.application.Application in project alien4cloud by alien4cloud.
the class ApplicationStepDefinitions method I_search_for_application.
@When("^I search for \"([^\"]*)\" application$")
public void I_search_for_application(String applicationName) throws Throwable {
ComponentSearchRequest searchRequest = new ComponentSearchRequest(null, applicationName, 0, 10, null);
String searchResponse = getRestClientInstance().postJSon("/rest/v1/applications/search", JsonUtil.toString(searchRequest));
Context.getInstance().registerRestResponse(searchResponse);
RestResponse<FacetedSearchResult> response = JsonUtil.read(searchResponse, FacetedSearchResult.class);
for (Object appAsObj : response.getData().getData()) {
Application app = JsonUtil.readObject(JsonUtil.toString(appAsObj), Application.class);
if (applicationName.equals(app.getName())) {
CURRENT_APPLICATION = app;
}
}
}
Aggregations