if (validatedResponse != null) throw new NoLogWebApplicationException(validatedResponse.status(Response.Status.NOT_MODIFIED).cacheControl(cc).header(HttpHeaders.ETAG, etag).build());
private static Void throwErrorForbidden(String botId, Integer version, IllegalAccessException e) { String message = "Bot deployment is currently in progress! (botId=%s , version=%s)"; message = String.format(message, botId, version); log.error(message, e); throw new NoLogWebApplicationException(new Throwable(message), Response.Status.FORBIDDEN); }
@Override public Response getBotZipArchive(String botFilename) { try { String zipFilePath = FileUtilities.buildPath(tmpPath.toString(), botFilename); return Response.ok(new BufferedInputStream(new FileInputStream(zipFilePath))).build(); } catch (FileNotFoundException e) { throw new NoLogWebApplicationException(Response.Status.NOT_FOUND); } }
@Override public String viewHtml(String path) { try { return resourceFileManager.getResourceAsString("html", "chat.html"); } catch (IResourceFileManager.NotFoundException e) { throw new NoLogWebApplicationException(Response.Status.NOT_FOUND); } }
@Override public void write(OutputStream outputStream) throws IOException, WebApplicationException { try { final RDFWriter writer = Rio.createWriter(format, outputStream); sparqlService.createServiceDescription(writer, request.getRequestURL().toString(), isUpdate); } catch (RDFHandlerException e) { log.warn("Could not send SpaqlServiceDescription", e); throw new NoLogWebApplicationException(e, Response.serverError().entity(e).build()); } } };
@Override public void write(OutputStream outputStream) throws IOException, WebApplicationException { try { final RDFWriter writer = Rio.createWriter(format, outputStream); sparqlService.createServiceDescription(writer, request.getRequestURL().toString(), isUpdate); } catch (RDFHandlerException e) { log.warn("Could not send SpaqlServiceDescription", e); throw new NoLogWebApplicationException(e, Response.serverError().entity(e).build()); } } };
@Override public Response getBinary(String path) { try { String extension = path.contains(".") ? path.substring(path.lastIndexOf(".") + 1) : null; InputStream fileStream = resourceFileManager.getResourceAsInputStream(path); if (fileStream != null) { return Response.ok(fileStream).type(contentTypeProvider.getContentTypeByExtension(extension)).build(); } else { throw new NotFoundException(); } } catch (IResourceFileManager.NotFoundException e) { throw new NoLogWebApplicationException(Response.Status.NOT_FOUND); } } }
@Override public void deleteTestCase(String id) { try { testCaseStore.delete(id, 0); } catch (IResourceStore.ResourceStoreException e) { log.error(e.getLocalizedMessage(), e); throw new InternalServerErrorException(e); } catch (IResourceStore.ResourceModifiedException e) { log.debug(e.getLocalizedMessage(), e); throw new NoLogWebApplicationException(Response.Status.CONFLICT); } catch (IResourceStore.ResourceNotFoundException e) { log.debug(e.getLocalizedMessage(), e); throw new NoLogWebApplicationException(Response.Status.NOT_FOUND); } } }
@Override public TestCase readTestCase(String id) { try { return testCaseStore.read(id, 0); } catch (IResourceStore.ResourceStoreException e) { log.error(e.getLocalizedMessage(), e); throw new InternalServerErrorException(e); } catch (IResourceStore.ResourceNotFoundException e) { throw new NoLogWebApplicationException(Response.Status.NOT_FOUND); } }
@Override public Group readGroup(String groupId) { try { return groupStore.readGroup(groupId); } catch (IResourceStore.ResourceStoreException e) { log.error(e.getLocalizedMessage(), e); throw new InternalServerErrorException(); } catch (IResourceStore.ResourceNotFoundException e) { throw new NoLogWebApplicationException(Response.Status.NOT_FOUND); } }
@Override public String viewHtml(String path) { try { path = preparePath(path); String htmlString = resourceFileManager.getResourceAsString("html", path); htmlString = htmlString.replace("<EDDI-VERSION/>", runtime.getVersion()); return htmlString; } catch (IResourceFileManager.NotFoundException e) { throw new NoLogWebApplicationException(Response.Status.NOT_FOUND); } }
@Override public User readUser(String userId) { try { return userStore.readUser(userId); } catch (IResourceStore.ResourceStoreException e) { log.error(e.getLocalizedMessage(), e); throw new InternalServerErrorException(); } catch (IResourceStore.ResourceNotFoundException e) { throw new NoLogWebApplicationException(Response.Status.NOT_FOUND); } }
@Override public URI updateTestCase(String id, TestCase testCase) { try { testCaseStore.update(id, 0, testCase); return RestUtilities.createURI(resourceURI, id, versionQueryParam, 0); } catch (IResourceStore.ResourceStoreException e) { log.error(e.getLocalizedMessage(), e); throw new InternalServerErrorException(e); } catch (IResourceStore.ResourceNotFoundException e) { log.debug(e.getLocalizedMessage(), e); throw new NoLogWebApplicationException(Response.Status.NOT_FOUND); } catch (IResourceStore.ResourceModifiedException e) { log.debug(e.getLocalizedMessage(), e); throw new NoLogWebApplicationException(Response.Status.CONFLICT); } }
@Override public Permissions readPermissions(String resourceId) { try { return permissionStore.readFilteredPermissions(resourceId); } catch (IResourceStore.ResourceStoreException e) { throw new InternalServerErrorException(e.getLocalizedMessage(), e); } catch (IResourceStore.ResourceNotFoundException e) { throw new NoLogWebApplicationException(Response.Status.NOT_FOUND); } }
@Override public URI searchUser(String username) { try { String id = userStore.searchUser(username); return RestUtilities.createURI(resourceURI, id); } catch (IResourceStore.ResourceStoreException e) { log.error(e.getLocalizedMessage(), e); throw new InternalServerErrorException(); } catch (IResourceStore.ResourceNotFoundException e) { throw new NoLogWebApplicationException(Response.Status.NOT_FOUND); } }
@Override public ConversationState getConversationState(Deployment.Environment environment, String conversationId) { RuntimeUtilities.checkNotNull(environment, "environment"); RuntimeUtilities.checkNotNull(conversationId, "conversationId"); ConversationState conversationState = conversationStateCache.get(conversationId); if (conversationState == null) { conversationState = conversationMemoryStore.getConversationState(conversationId); cacheConversationState(conversationId, conversationState); } if (conversationState == null) { String message = "No conversation found! (conversationId=%s)"; message = String.format(message, conversationId); throw new NoLogWebApplicationException(new Throwable(message), Response.Status.NOT_FOUND); } return conversationState; }
public static NoLogWebApplicationException createConflictException(String containerUri, IResourceStore.IResourceId currentId) { URI resourceUri = RestUtilities.createURI(containerUri, currentId.getId(), versionQueryParam, currentId.getVersion()); ResponseBuilderImpl builder = new ResponseBuilderImpl(); builder.status(Response.Status.CONFLICT); builder.entity(resourceUri.toString()); builder.type(MediaType.TEXT_PLAIN); return new NoLogWebApplicationException(builder.build()); }
@Override public List<String> readExpressions(String packageId, Integer packageVersion, String filter, Integer limit) { List<String> retExpressions = new LinkedList<>(); try { PackageConfiguration packageConfiguration = packageStore.read(packageId, packageVersion); List<IResourceStore.IResourceId> resourceIds = readDictionaryResourceIds(packageConfiguration); for (IResourceStore.IResourceId resourceId : resourceIds) { List<String> expressions = regularDictionaryStore.readExpressions(resourceId.getId(), resourceId.getVersion(), filter, "asc", 0, limit); CollectionUtilities.addAllWithoutDuplicates(retExpressions, expressions); } return retExpressions; } catch (IResourceStore.ResourceNotFoundException e) { throw new NoLogWebApplicationException(Response.Status.NOT_FOUND); } catch (IResourceStore.ResourceStoreException e) { log.error(e.getLocalizedMessage(), e); throw new InternalServerErrorException(e); } }
@Override public Boolean isRedoAvailable(final Deployment.Environment environment, String botId, String conversationId) { RuntimeUtilities.checkNotNull(environment, "environment"); RuntimeUtilities.checkNotNull(botId, "botId"); RuntimeUtilities.checkNotNull(conversationId, "conversationId"); try { var conversationMemory = loadConversationMemory(conversationId); return conversationMemory.isRedoAvailable(); } catch (ResourceStoreException e) { throw new NoLogWebApplicationException(Response.Status.NOT_FOUND); } catch (ResourceNotFoundException e) { log.error(e.getLocalizedMessage(), e); throw new InternalServerErrorException(); } }
@Override public Boolean isUndoAvailable(Deployment.Environment environment, String botId, String conversationId) { RuntimeUtilities.checkNotNull(environment, "environment"); RuntimeUtilities.checkNotNull(botId, "botId"); RuntimeUtilities.checkNotNull(conversationId, "conversationId"); final IConversationMemory conversationMemory; try { conversationMemory = loadConversationMemory(conversationId); return conversationMemory.isUndoAvailable(); } catch (ResourceStoreException e) { log.error(e.getLocalizedMessage(), e); throw new InternalServerErrorException(); } catch (ResourceNotFoundException e) { throw new NoLogWebApplicationException(Response.Status.NOT_FOUND); } }