use of alien4cloud.exception.NotFoundException in project alien4cloud by alien4cloud.
the class ArtifactProcessorService method processLocalArtifact.
private void processLocalArtifact(AbstractArtifact artifact) {
try {
Path csarPath = repository.getExpandedCSAR(artifact.getArchiveName(), artifact.getArchiveVersion());
Path resolvedPath = csarPath.resolve(artifact.getArtifactRef());
if (!Files.exists(resolvedPath)) {
throw new UnresolvableArtifactException("Artifact could not be accessed " + artifact);
}
artifact.setArtifactPath(resolvedPath.toString());
} catch (NotFoundException e) {
throw new UnresolvableArtifactException("Artifact could not be found " + artifact, e);
}
}
use of alien4cloud.exception.NotFoundException in project alien4cloud by alien4cloud.
the class UserService method updateUserGroupRoles.
/**
* Regenerate the group roles in the user.
*
* @param user the user for which to regenerate the group roles
*/
public void updateUserGroupRoles(User user) {
if (CollectionUtils.isEmpty(user.getGroups())) {
user.setGroupRoles(null);
} else {
Set<String> groupRolesSet = Sets.newHashSet();
for (String groupId : user.getGroups()) {
Group group = alienGroupDao.find(groupId);
if (group == null) {
throw new NotFoundException("Group [" + groupId + "] cannot be found");
}
if (CollectionUtils.isNotEmpty(group.getRoles())) {
groupRolesSet.addAll(group.getRoles());
}
}
user.setGroupRoles(groupRolesSet);
}
alienUserDao.save(user);
}
use of alien4cloud.exception.NotFoundException in project alien4cloud by alien4cloud.
the class AuditController method enableMethodAudit.
private void enableMethodAudit(Map<Method, Boolean> auditedMethodsMap, AuditedMethod method) {
if (method.getMethod() == null) {
throw new InvalidArgumentException("Method's path or http method is null");
}
Method auditedMethodKey = new Method(method.getSignature(), method.getMethod(), method.getCategory(), method.getAction(), method.getBodyHiddenFields());
if (!auditedMethodsMap.containsKey(auditedMethodKey)) {
throw new NotFoundException("Method " + method + " does not exist ");
}
auditedMethodsMap.put(auditedMethodKey, method.isEnabled());
}
use of alien4cloud.exception.NotFoundException in project alien4cloud by alien4cloud.
the class NodeInstanceService method updateCapabilities.
private void updateCapabilities(NodeTemplate nodeTemplate, Map<String, Capability> nodeCapabilities) throws ConstraintValueDoNotMatchPropertyTypeException, ConstraintViolationException {
for (Map.Entry<String, Capability> entry : nodeCapabilities.entrySet()) {
if (entry != null) {
Capability patchCapability = PatchUtil.realValue(entry.getValue());
if (patchCapability == null) {
throw new IllegalArgumentException("It is not allowed to set null to a capability.");
} else {
Capability targetCapability = nodeTemplate.getCapabilities().get(entry.getKey());
if (targetCapability == null) {
throw new NotFoundException("Capability <" + entry.getKey() + "> doesn't exists on the node.");
}
CapabilityType capabilityType = ToscaContext.get(CapabilityType.class, targetCapability.getType());
updateCapabilitiesProperties(capabilityType, targetCapability, patchCapability);
}
}
}
}
use of alien4cloud.exception.NotFoundException in project alien4cloud by alien4cloud.
the class ServiceResourceService method updateLocations.
private void updateLocations(ServiceResource serviceResource, String[] locations) {
if (locations == null) {
return;
}
// Check what elements have changed.
Set<String> removedLocations = CollectionUtils.safeNewHashSet(serviceResource.getLocationIds());
Set<String> addedLocations = Sets.newHashSet();
Set<String> newLocations = Sets.newHashSet();
for (String locationId : locations) {
if (removedLocations.contains(locationId)) {
// This location was already affected
removedLocations.remove(locationId);
newLocations.add(locationId);
} else {
// This is an added element.
if (!alienDAO.exist(Location.class, locationId)) {
throw new NotFoundException("Location with id <" + locationId + "> does not exist.");
}
addedLocations.add(locationId);
newLocations.add(locationId);
}
}
serviceResource.setLocationIds(newLocations.toArray(new String[newLocations.size()]));
// Dispatch location changed events (not a big deal if the save is actually canceled as it just changed the update date).
for (String locationId : addedLocations) {
publisher.publishEvent(new OnLocationResourceChangeEvent(this, locationId));
}
for (String locationId : removedLocations) {
publisher.publishEvent(new OnLocationResourceChangeEvent(this, locationId));
}
}
Aggregations