Search in sources :

Example 11 with NotFoundException

use of alien4cloud.exception.NotFoundException in project alien4cloud by alien4cloud.

the class ApplicationEnvironmentGitController method checkEnvironmentAuthorization.

private void checkEnvironmentAuthorization(String applicationId, String environmentId) {
    ApplicationEnvironment environment = environmentService.getOrFail(environmentId);
    if (!environment.getApplicationId().equals(applicationId)) {
        throw new NotFoundException("Cannot find environement <" + environmentId + "> for application <" + applicationId + ">.");
    }
    Application application = applicationService.getOrFail(applicationId);
    AuthorizationUtil.checkAuthorizationForEnvironment(application, environment);
}
Also used : NotFoundException(alien4cloud.exception.NotFoundException) ApplicationEnvironment(alien4cloud.model.application.ApplicationEnvironment) Application(alien4cloud.model.application.Application)

Example 12 with NotFoundException

use of alien4cloud.exception.NotFoundException in project alien4cloud by alien4cloud.

the class EditorStepDefs method init.

@Before
public void init() throws IOException {
    thrownException = null;
    GetMultipleDataResult<Application> apps = alienDAO.search(Application.class, "", null, 100);
    for (Application application : apps.getData()) {
        applicationService.delete(application.getId());
    }
    FacetedSearchResult<Topology> searchResult = catalogService.search(Topology.class, "", 100, null);
    Topology[] topologies = searchResult.getData();
    for (Topology topology : topologies) {
        try {
            csarService.forceDeleteCsar(topology.getId());
        } catch (NotFoundException e) {
            // Some previous tests may create topology without creating any archive, if so catch the exception
            alienDAO.delete(Topology.class, topology.getId());
        }
    }
    topologyIds.clear();
    editionContextManager.clearCache();
}
Also used : NotFoundException(alien4cloud.exception.NotFoundException) Topology(org.alien4cloud.tosca.model.templates.Topology) Application(alien4cloud.model.application.Application) Before(cucumber.api.java.Before)

Example 13 with NotFoundException

use of alien4cloud.exception.NotFoundException in project alien4cloud by alien4cloud.

the class LocationService method createLocation.

private void createLocation(Orchestrator orchestrator, Location location, String infrastructureType) {
    ensureNameUnicityAndSave(location);
    // TODO checks that the infrastructure type is valid
    location.setInfrastructureType(infrastructureType);
    // TODO add User and Group managed by the Orchestrator security
    Set<CSARDependency> dependencies = locationArchiveIndexer.indexLocationArchives(orchestrator, location);
    location.setDependencies(dependencies);
    // initialize meta properties
    location.setMetaProperties(Maps.<String, String>newHashMap());
    // add existing meta properties to the cloud
    GetMultipleDataResult<MetaPropConfiguration> result = alienDAO.find(MetaPropConfiguration.class, singleKeyFilter("target", MetaPropertyTarget.LOCATION), Integer.MAX_VALUE);
    for (MetaPropConfiguration element : result.getData()) {
        if (Objects.equals(element.getTarget(), MetaPropertyTarget.LOCATION)) {
            // we only support string values for meta properties
            PropertyUtil.setScalarDefaultValueOrNull(location.getMetaProperties(), element.getId(), element.getDefault());
            log.debug("Added meta property [ {} ] to the new location [ {} ] ", element.getName(), location.getName());
        }
    }
    // save the new location
    alienDAO.save(location);
    try {
        autoConfigure(orchestrator, location);
    } catch (UnsupportedOperationException e) {
    // do nothing
    }
    // We call the LocationRessourceService to check the dependencies
    try {
        locationResourceService.getLocationResourcesFromOrchestrator(location);
    } catch (NotFoundException e) {
        // WARN: FIXME we load orch twice !!!!!!!!!!!!!!!!!!!!!!!!!
        delete(orchestrator.getId(), location.getId());
        throw new MissingCSARDependenciesException(e.getMessage());
    }
}
Also used : MetaPropConfiguration(alien4cloud.model.common.MetaPropConfiguration) NotFoundException(alien4cloud.exception.NotFoundException) MissingCSARDependenciesException(alien4cloud.exception.MissingCSARDependenciesException) CSARDependency(org.alien4cloud.tosca.model.CSARDependency)

Example 14 with NotFoundException

use of alien4cloud.exception.NotFoundException in project alien4cloud by alien4cloud.

the class OrchestratorConfigurationService method updateConfiguration.

/**
 * Update the configuration for the given cloud.
 *
 * @param id Id of the orchestrator for which to update the configuration.
 * @param newConfiguration The new configuration.
 */
public synchronized void updateConfiguration(String id, Object newConfiguration) throws PluginConfigurationException, IOException {
    OrchestratorConfiguration configuration = alienDAO.findById(OrchestratorConfiguration.class, id);
    if (configuration == null) {
        throw new NotFoundException("No configuration exists for cloud [" + id + "].");
    }
    Object newConfigurationObj = configurationAsValidObject(id, newConfiguration);
    Object oldConfiguration = configuration.getConfiguration();
    Object oldConfigurationObj = configurationAsValidObject(id, oldConfiguration);
    Map<String, Object> oldConfAsMap = JsonUtil.toMap(JsonUtil.toString(oldConfigurationObj));
    Map<String, Object> newConfAsMap = (Map<String, Object>) newConfiguration;
    // merge the config so that old values are preserved
    ReflectionUtil.mergeObject(newConfigurationObj, oldConfigurationObj, false, Sets.difference(oldConfAsMap.keySet(), newConfAsMap.keySet()));
    configuration.setConfiguration(oldConfigurationObj);
    // Trigger update of the orchestrator's configuration if enabled.
    IOrchestratorPlugin orchestratorInstance = orchestratorPluginService.get(id);
    if (orchestratorInstance != null) {
        orchestratorInstance.setConfiguration(id, oldConfigurationObj);
    }
    alienDAO.save(configuration);
}
Also used : NotFoundException(alien4cloud.exception.NotFoundException) OrchestratorConfiguration(alien4cloud.model.orchestrators.OrchestratorConfiguration) Map(java.util.Map) IOrchestratorPlugin(alien4cloud.orchestrators.plugin.IOrchestratorPlugin)

Example 15 with NotFoundException

use of alien4cloud.exception.NotFoundException in project alien4cloud by alien4cloud.

the class PluginManager method enablePlugin.

/**
 * Enable a plugin in alien.
 *
 * @param pluginId The id of the plugin to load.
 * @throws PluginLoadingException In case plugin loading fails.
 */
public void enablePlugin(String pluginId) throws PluginLoadingException {
    if (this.pluginContexts.get(pluginId) != null) {
        log.info("Plugin <" + pluginId + "> is already loaded.");
        return;
    }
    Plugin plugin = alienDAO.findById(Plugin.class, pluginId);
    if (plugin == null) {
        throw new NotFoundException("The plugin <" + pluginId + "> doesn't exists in alien.");
    }
    enablePlugin(plugin);
}
Also used : NotFoundException(alien4cloud.exception.NotFoundException) ManagedPlugin(alien4cloud.plugin.model.ManagedPlugin)

Aggregations

NotFoundException (alien4cloud.exception.NotFoundException)88 NodeTemplate (org.alien4cloud.tosca.model.templates.NodeTemplate)17 PropertyDefinition (org.alien4cloud.tosca.model.definitions.PropertyDefinition)12 Map (java.util.Map)10 Workflow (org.alien4cloud.tosca.model.workflow.Workflow)10 AlreadyExistException (alien4cloud.exception.AlreadyExistException)9 AbstractPropertyValue (org.alien4cloud.tosca.model.definitions.AbstractPropertyValue)9 Capability (org.alien4cloud.tosca.model.templates.Capability)9 NodeType (org.alien4cloud.tosca.model.types.NodeType)9 ApplicationEnvironment (alien4cloud.model.application.ApplicationEnvironment)8 SubstitutionTarget (org.alien4cloud.tosca.model.templates.SubstitutionTarget)8 Topology (org.alien4cloud.tosca.model.templates.Topology)7 Deployment (alien4cloud.model.deployment.Deployment)6 ApiOperation (io.swagger.annotations.ApiOperation)6 RelationshipTemplate (org.alien4cloud.tosca.model.templates.RelationshipTemplate)6 CapabilityType (org.alien4cloud.tosca.model.types.CapabilityType)6 InvalidNameException (alien4cloud.exception.InvalidNameException)5 DeploymentTopology (alien4cloud.model.deployment.DeploymentTopology)5 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)5 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)5