use of com.netflix.spinnaker.kork.web.exceptions.NotFoundException in project front50 by spinnaker.
the class EntityTagsController method tag.
@RequestMapping(value = "/**", method = RequestMethod.GET)
public EntityTags tag(HttpServletRequest request) {
String pattern = (String) request.getAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE);
final String searchTerm = new AntPathMatcher().extractPathWithinPattern(pattern, request.getServletPath());
return taggedEntityDAO.map(it -> it.findById(searchTerm)).orElseThrow(() -> new NotFoundException(format("No tags found for '%s'", searchTerm)));
}
use of com.netflix.spinnaker.kork.web.exceptions.NotFoundException in project front50 by spinnaker.
the class ProjectsController method put.
@ApiOperation(value = "", notes = "Update an existing project")
@RequestMapping(method = RequestMethod.PUT, value = "/{projectId}")
public Project put(@PathVariable final String projectId, @RequestBody final Project project) {
Project existingProject = projectDAO.findById(projectId);
project.setId(existingProject.getId());
project.setCreateTs(existingProject.getCreateTs());
project.setUpdateTs(System.currentTimeMillis());
try {
if (!projectDAO.findByName(project.getName()).getId().equals(projectId)) {
// renamed projects must still be uniquely named
throw new InvalidRequestException(format("A Project named '%s' already exists", project.getName()));
}
} catch (NotFoundException ignored) {
}
projectDAO.update(projectId, project);
return project;
}
use of com.netflix.spinnaker.kork.web.exceptions.NotFoundException in project fiat by spinnaker.
the class AuthorizeController method getUserAuthorization.
@RequestMapping(value = "/{userId:.+}/{resourceType:.+}/{resourceName:.+}/{authorization:.+}", method = RequestMethod.GET)
public void getUserAuthorization(@PathVariable String userId, @PathVariable String resourceType, @PathVariable String resourceName, @PathVariable String authorization, HttpServletResponse response) throws IOException {
Authorization a = Authorization.valueOf(authorization.toUpperCase());
ResourceType r = ResourceType.parse(resourceType);
Set<Authorization> authorizations = new HashSet<>(0);
try {
if (r.equals(ResourceType.ACCOUNT)) {
authorizations = getUserAccount(userId, resourceName).getAuthorizations();
} else if (r.equals(ResourceType.APPLICATION)) {
authorizations = getUserApplication(userId, resourceName).getAuthorizations();
} else {
response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Resource type " + resourceType + " does not contain authorizations");
return;
}
} catch (NotFoundException nfe) {
// Ignore. Will return 404 below.
}
if (authorizations.contains(a)) {
response.setStatus(HttpServletResponse.SC_OK);
return;
}
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
}
use of com.netflix.spinnaker.kork.web.exceptions.NotFoundException in project front50 by spinnaker.
the class ApplicationPermissionsService method update.
private Permission update(@Nonnull String appName, @Nonnull Permission newPermission) {
try {
Permission oldPerm = applicationPermissionDAO().findById(appName);
applicationPermissionDAO().update(appName, newPermission);
syncUsers(newPermission, oldPerm);
} catch (NotFoundException e) {
createApplicationPermission(newPermission);
}
return newPermission;
}
use of com.netflix.spinnaker.kork.web.exceptions.NotFoundException in project front50 by spinnaker.
the class PluginInfoService method upsertRelease.
/**
* Updates (not upserts) a release. Releases are effectively immutable, but this method can be
* used to fixup data
*/
public PluginInfo upsertRelease(@Nonnull String id, @Nonnull PluginInfo.Release release) {
release.setLastModifiedBy(AuthenticatedRequest.getSpinnakerUser().orElse("anonymous"));
release.setLastModified(Instant.now());
PluginInfo pluginInfo = repository.findById(id);
PluginInfo.Release existingRelease = pluginInfo.getReleaseByVersion(release.getVersion()).orElseThrow(() -> new NotFoundException(String.format("Plugin %s with release %s version not found. ", id, release.getVersion())));
pluginInfo.getReleases().remove(existingRelease);
pluginInfo.getReleases().add(release);
if (release.isPreferred()) {
preferRelease(pluginInfo, release);
}
return savePluginInfo(pluginInfo);
}
Aggregations