public WizardPage pushPage(String pageId) { WizardPage page = pages.get(pageId); if (page == null) { throw new WebResourceNotFoundException("No such wizard page: " + pageId); } if (lastPage == null) { lastPage = page; } else { page.prev = lastPage; lastPage = page; } return page; }
@GET public Object doGet(@Context Request request) { Blob blob = getRenditionBlob(); if (blob == null) { throw new WebResourceNotFoundException( String.format("No Blob was found for rendition '%s'", renditionName)); } return blob; } }
@Path("{entryId:((?:(?!/@).)*)}") public Object getEntry(@PathParam("entryId") final String entryId) { return withDirectorySession(directory, new DirectorySessionRunner<Object>() { @Override Object run(Session session) { DocumentModel entry = session.getEntry(entryId); if (entry == null) { throw new WebResourceNotFoundException("Entry not found"); } return newObject("directoryEntry", new DirectoryEntry(directory.getName(), entry), entryId); } }); }
@Path("/") public Object doGetRepository(@PathParam("repo") String repositoryParam) throws DocumentNotFoundException { if (StringUtils.isNotBlank(repositoryParam)) { String repoName = repositoryParam.substring("repo/".length() + 1); try { ctx.setRepositoryName(repoName); } catch (IllegalArgumentException e) { throw new WebResourceNotFoundException(e.getMessage()); } } return newObject("repo"); }
@GET public Object doGet(@Context Request request) { if (blobHolder instanceof DocumentBlobHolder) { // managed by DocumentBlobHolderWriter return blobHolder; } else { // managed by BlobWriter Blob blob; try { blob = blobHolder.getBlob(); } catch (PropertyNotFoundException e) { throw new WebResourceNotFoundException("Invalid xpath"); } return blob; } }
@Path("group/{groupName:((?:(?!(/@)).)*)}") public Object doGetUserToGroup(@PathParam("groupName") String groupName) { NuxeoGroup group = um.getGroup(groupName); if (group == null) { throw new WebResourceNotFoundException("Group not found"); } return newObject("userToGroup", currentArtifact, group); }
public static URL findTemplate(Object owner, String name) { URL url = owner.getClass().getResource(name); if (url == null) { url = Framework.getResourceLoader().getResource(name); if (url == null) { throw new WebResourceNotFoundException("View not found: " + name + " for object " + owner); } } return url; }
@Path("/") public Object doGetRepository(@PathParam("repo") String repositoryParam) throws NoSuchDocumentException { if (StringUtils.isNotBlank(repositoryParam)) { String repoName = repositoryParam.substring("repo/".length() + 1); try { ctx.setRepositoryName(repoName); } catch (final NuxeoException e) { throw new WebResourceNotFoundException(e.getMessage()); } } return newObject("toutatice"); }
@Override public ScriptFile getView(Module module, String name) { ScriptFile file = findView(module, name); if (file == null) { throw new WebResourceNotFoundException("Template " + name + " not found for object of type " + getName()); } return file; }
@Override public ResourceType getType(String typeName) { ResourceType type = getTypeRegistry().getType(typeName); if (type == null) { throw new WebResourceNotFoundException("Type not found: " + typeName); } return type; }
@Override public Resource newObject(String typeName, Object... args) { ResourceType type = module.getType(typeName); if (type == null) { throw new WebResourceNotFoundException("No Such Object Type: " + typeName); } return newObject(type, args); }
@Path("user/{username}") public Object doGetUserToGroup(@PathParam("username") String username) { UserManager um = Framework.getService(UserManager.class); NuxeoPrincipal principal = um.getPrincipal(username); if (principal == null) { throw new WebResourceNotFoundException("User not found"); } return newObject("userToGroup", principal, currentArtifact); }
protected OAuth2Client getClient(String clientId) { OAuth2Client client = Framework.getService(OAuth2ClientService.class).getClient(clientId); if (client == null) { throw new WebResourceNotFoundException("Invalid client: " + clientId); } return client; }
@GET @Path("{id}/poll") public Object doGetConversionStatus(@PathParam("id") String id) { ConversionService conversionService = Framework.getService(ConversionService.class); ConversionStatus conversionStatus = conversionService.getConversionStatus(id); if (conversionStatus == null) { throw new WebResourceNotFoundException("No conversion job for id: " + id); } String serverURL = ctx.getServerURL().toString().replaceAll("/$", ""); String resultURL = String.format("%s%s/conversions/%s/result", serverURL, ctx.getModulePath(), conversionStatus.id); ConversionStatusWithResult conversionStatusWithResult = new ConversionStatusWithResult(conversionStatus, resultURL); return Response.ok(conversionStatusWithResult).build(); }
@Override public void render(String template, Object ctx, Writer writer) { ScriptFile script = getFile(template); if (script != null) { render(script, ctx, writer); } else { throw new WebResourceNotFoundException("Template not found: " + template); } }
@Override public Object runScript(String script, Map<String, Object> args) { ScriptFile sf = getFile(script); if (sf != null) { return runScript(sf, args); } else { throw new WebResourceNotFoundException("Script not found: " + script); } }
protected NuxeoOAuth2ServiceProvider getProvider(String providerId) { OAuth2ServiceProvider provider = Framework.getService(OAuth2ServiceProviderRegistry.class) .getProvider(providerId); if (provider == null || !(provider instanceof NuxeoOAuth2ServiceProvider)) { throw new WebResourceNotFoundException("Invalid provider: " + providerId); } return (NuxeoOAuth2ServiceProvider) provider; }
@Path("user/{user}") public Object searchUsers(@PathParam("user") String user) { UserManager userManager = Framework.getService(UserManager.class); NuxeoPrincipalImpl principal = (NuxeoPrincipalImpl) userManager.getPrincipal(user); if (principal == null) { throw new WebResourceNotFoundException("User not found: " + user); } return newObject("User", principal); }
@Path("group/{group}") public Object searchGroups(@PathParam("group") String group) { UserManager userManager = Framework.getService(UserManager.class); // FIXME: find better name for it NuxeoGroup principal = userManager.getGroup(group); if (principal == null) { throw new WebResourceNotFoundException("Group not found: " + group); } return newObject("Group", principal); }
@GET @Path("{id}/result") public Object doGetConversionResult(@PathParam("id") String id) { ConversionService conversionService = Framework.getService(ConversionService.class); BlobHolder result = conversionService.getConversionResult(id, false); if (result == null || result.getBlob() == null) { throw new WebResourceNotFoundException("No conversion result for id: " + id); } return result.getBlob(); }