Search in sources :

Example 26 with Application

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();
}
Also used : Application(alien4cloud.model.application.Application) Audit(alien4cloud.audit.annotation.Audit) ApiOperation(io.swagger.annotations.ApiOperation) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 27 with Application

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();
}
Also used : Application(alien4cloud.model.application.Application) Audit(alien4cloud.audit.annotation.Audit) ApiOperation(io.swagger.annotations.ApiOperation) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 28 with Application

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;
}
Also used : Csar(org.alien4cloud.tosca.model.Csar) Usage(alien4cloud.model.common.Usage) Application(alien4cloud.model.application.Application)

Example 29 with Application

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());
}
Also used : TestUtils.nullAsString(alien4cloud.it.utils.TestUtils.nullAsString) Application(alien4cloud.model.application.Application) Given(cucumber.api.java.en.Given)

Example 30 with Application

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;
        }
    }
}
Also used : ComponentSearchRequest(alien4cloud.rest.component.ComponentSearchRequest) TestUtils.nullAsString(alien4cloud.it.utils.TestUtils.nullAsString) Application(alien4cloud.model.application.Application) FacetedSearchResult(alien4cloud.dao.model.FacetedSearchResult) When(cucumber.api.java.en.When)

Aggregations

Application (alien4cloud.model.application.Application)103 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)45 ApiOperation (io.swagger.annotations.ApiOperation)43 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)39 ApplicationEnvironment (alien4cloud.model.application.ApplicationEnvironment)38 Audit (alien4cloud.audit.annotation.Audit)28 List (java.util.List)14 Topology (org.alien4cloud.tosca.model.templates.Topology)14 Set (java.util.Set)12 DeploymentTopology (alien4cloud.model.deployment.DeploymentTopology)11 RestResponse (alien4cloud.rest.model.RestResponse)11 Collectors (java.util.stream.Collectors)11 Map (java.util.Map)10 ApplicationEnvironmentService (alien4cloud.application.ApplicationEnvironmentService)9 ApplicationTopologyVersion (alien4cloud.model.application.ApplicationTopologyVersion)9 Arrays (java.util.Arrays)9 When (cucumber.api.java.en.When)8 Deployment (alien4cloud.model.deployment.Deployment)7 RestResponseBuilder (alien4cloud.rest.model.RestResponseBuilder)7 ApplicationEnvironmentAuthorizationDTO (alien4cloud.rest.orchestrator.model.ApplicationEnvironmentAuthorizationDTO)7