use of alien4cloud.model.application.Application in project alien4cloud by alien4cloud.
the class EsQuickSearchTest method before.
@Before
public void before() throws Exception {
super.before();
prepareToscaElement();
saveDataToES(true);
Application app = new Application();
app.setName("application-1");
Map<String, Set<String>> userRoles = Maps.newHashMap();
userRoles.put("Igor", Sets.newHashSet("APPLICATION_MANAGER"));
app.setUserRoles(userRoles);
alienDAO.save(app);
applcationDataTest.add(app);
}
use of alien4cloud.model.application.Application in project alien4cloud by alien4cloud.
the class DeploymentTopologyController method updatePolicySubstitution.
/**
* Update policy substitution.
*
* @param appId id of the application.
* @param environmentId id of the environment.
* @return response containing the deployment topology dto {@link DeploymentTopologyDTO}.
*/
@ApiOperation(value = "Substitute a specific policy by a location policy resource template in the topology of an application, given an environment.", notes = "Application role required [ APPLICATION_MANAGER | APPLICATION_DEVOPS ] and Application environment role required [ DEPLOYMENT_MANAGER ]")
@RequestMapping(value = "/policies/{policyId}/substitution", method = RequestMethod.POST)
@PreAuthorize("isAuthenticated()")
@Audit
public RestResponse<DeploymentTopologyDTO> updatePolicySubstitution(@PathVariable String appId, @PathVariable String environmentId, @PathVariable String policyId, @RequestParam String locationResourceTemplateId) {
Application application = applicationService.getOrFail(appId);
ApplicationEnvironment environment = appEnvironmentService.getOrFail(environmentId);
AuthorizationUtil.checkAuthorizationForEnvironment(application, environment);
ApplicationTopologyVersion topologyVersion = applicationVersionService.getOrFail(Csar.createId(environment.getApplicationId(), environment.getVersion()), environment.getTopologyVersion());
Topology topology = topologyServiceCore.getOrFail(topologyVersion.getArchiveId());
DeploymentTopologyDTO dto = deploymentTopologyDTOBuilder.prepareDeployment(topology, () -> policyMatchingSubstitutionService.updateSubstitution(application, environment, topology, policyId, locationResourceTemplateId));
return RestResponseBuilder.<DeploymentTopologyDTO>builder().data(dto).build();
}
use of alien4cloud.model.application.Application in project alien4cloud by alien4cloud.
the class DeploymentTopologyController method updatePolicySubstitutionProperty.
@ApiOperation(value = "Update policy substitution's property.", authorizations = { @Authorization("ADMIN") })
@RequestMapping(value = "/policies/{nodeId}/substitution/properties", method = RequestMethod.POST)
@PreAuthorize("isAuthenticated()")
@Audit
public RestResponse<?> updatePolicySubstitutionProperty(@PathVariable String appId, @PathVariable String environmentId, @PathVariable String nodeId, @RequestBody UpdatePropertyRequest updateRequest) {
try {
Application application = applicationService.getOrFail(appId);
ApplicationEnvironment environment = appEnvironmentService.getOrFail(environmentId);
AuthorizationUtil.checkAuthorizationForEnvironment(application, environment);
ApplicationTopologyVersion topologyVersion = applicationVersionService.getOrFail(Csar.createId(environment.getApplicationId(), environment.getVersion()), environment.getTopologyVersion());
Topology topology = topologyServiceCore.getOrFail(topologyVersion.getArchiveId());
DeploymentTopologyDTO dto = deploymentTopologyDTOBuilder.prepareDeployment(topology, () -> matchedPolicyPropertiesConfigService.updateProperty(application, environment, topology, nodeId, updateRequest.getPropertyName(), updateRequest.getPropertyValue()));
return RestResponseBuilder.<DeploymentTopologyDTO>builder().data(dto).build();
} catch (ConstraintTechnicalException e) {
if (e.getCause() instanceof ConstraintFunctionalException) {
return RestConstraintValidator.fromException((ConstraintFunctionalException) e.getCause(), updateRequest.getPropertyName(), updateRequest.getPropertyValue());
}
throw e;
}
}
use of alien4cloud.model.application.Application in project alien4cloud by alien4cloud.
the class DeploymentTopologyController method execute.
private DeploymentTopologyDTO execute(String applicationId, String environmentId, IDeploymentConfigAction action) {
Application application = applicationService.getOrFail(applicationId);
ApplicationEnvironment environment = appEnvironmentService.getOrFail(environmentId);
AuthorizationUtil.checkAuthorizationForEnvironment(application, environment);
ApplicationTopologyVersion topologyVersion = applicationVersionService.getOrFail(Csar.createId(environment.getApplicationId(), environment.getVersion()), environment.getTopologyVersion());
Topology topology = topologyServiceCore.getOrFail(topologyVersion.getArchiveId());
// This method prepares the deployment and create a Deployment Topology DTO object.
return deploymentTopologyDTOBuilder.prepareDeployment(topology, application, environment, topologyVersion, action);
}
use of alien4cloud.model.application.Application in project alien4cloud by alien4cloud.
the class DeploymentTopologyController method getDeploymentTopology.
/**
* Get the deployment topology of an application given an environment
*
* @param appId application Id
* @param environmentId environment Id
* @return the deployment topology DTO
*/
@ApiOperation(value = "Get the deployment topology of an application given an environment.", notes = "Application role required [ APPLICATION_MANAGER | APPLICATION_DEVOPS ] and Application environment role required [ DEPLOYMENT_MANAGER ]")
@RequestMapping(value = "", method = RequestMethod.GET)
@PreAuthorize("isAuthenticated()")
public RestResponse<DeploymentTopologyDTO> getDeploymentTopology(@PathVariable String appId, @PathVariable String environmentId) {
Application application = applicationService.getOrFail(appId);
ApplicationEnvironment environment = appEnvironmentService.getOrFail(environmentId);
AuthorizationUtil.checkAuthorizationForEnvironment(application, environment);
ApplicationTopologyVersion topologyVersion = applicationVersionService.getOrFail(Csar.createId(environment.getApplicationId(), environment.getVersion()), environment.getTopologyVersion());
Topology topology = topologyServiceCore.getOrFail(topologyVersion.getArchiveId());
// This method prepares the deployment and create a Deployment Topology DTO object.
DeploymentTopologyDTO dto = deploymentTopologyDTOBuilder.prepareDeployment(topology, application, environment);
return RestResponseBuilder.<DeploymentTopologyDTO>builder().data(dto).build();
}
Aggregations