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);
}
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();
}
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());
}
}
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);
}
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);
}
Aggregations