public static File resolveLocalFileName(String fileName) { List<File> configDirectories = getVisalloDirectoriesFromMostPriority("config"); if (configDirectories.size() == 0) { throw new VisalloResourceNotFoundException("Could not find any valid config directories."); } for (File directory : configDirectories) { File f = new File(directory, fileName); if (f.exists()) { return f; } } throw new VisalloResourceNotFoundException("Could not find file: " + fileName); }
private void handleNotFound(HttpServletResponse response, VisalloResourceNotFoundException notFoundException) throws IOException { response.sendError(HttpServletResponse.SC_NOT_FOUND, notFoundException.getMessage()); }
@Override public byte[] getMapGlyphIcon() { try { StreamingPropertyValue spv = OntologyProperties.MAP_GLYPH_ICON.getPropertyValue(getVertex()); if (spv == null) { return null; } return IOUtils.toByteArray(spv.getInputStream()); } catch (IOException e) { throw new VisalloResourceNotFoundException("Could not retrieve map glyph icon"); } }
@Override public byte[] getGlyphIconSelected() { try { StreamingPropertyValue spv = OntologyProperties.GLYPH_ICON_SELECTED.getPropertyValue(getVertex()); if (spv == null) { return null; } return IOUtils.toByteArray(spv.getInputStream()); } catch (IOException e) { throw new VisalloResourceNotFoundException("Could not retrieve glyph icon selected"); } }
@Override public byte[] getGlyphIcon() { try { StreamingPropertyValue spv = OntologyProperties.GLYPH_ICON.getPropertyValue(getVertex()); if (spv == null) { return null; } return IOUtils.toByteArray(spv.getInputStream()); } catch (IOException e) { throw new VisalloResourceNotFoundException("Could not retrieve glyph icon"); } }
@Handle public ClientApiProducts handle( @ActiveWorkspaceId String workspaceId, User user ) throws Exception { Collection<Product> products = workspaceRepository.findAllProductsForWorkspace(workspaceId, user); if (products == null) { throw new VisalloResourceNotFoundException("Could not find products for workspace " + workspaceId); } List<String> types = InjectHelper.getInjectedServices(WorkProductService.class, configuration).stream() .map(WorkProductService::getKind) .collect(Collectors.toList()); return ClientApiConverter.toClientApiProducts(types, products); } }
@Handle public DirectoryEntity handle( @Required(name = "id", allowEmpty = false) String id, User user ) { DirectoryEntity directoryEntity = this.directoryRepository.findById(id, user); if (directoryEntity == null) { throw new VisalloResourceNotFoundException("Could not find directory entry with id: " + id); } return directoryEntity; } }
protected void doConfigureLog4j() { String fileName = System.getProperty("logQuiet") == null ? "log4j2.xml" : "log4j2-quiet.xml"; File log4jFile = null; String log4jLocation = null; try { log4jFile = resolveFileName(fileName); } catch (VisalloResourceNotFoundException e) { // OK, try classpath } if (log4jFile == null || !log4jFile.exists()) { URL log4jResource = getClass().getResource(fileName); System.err.println("Could not resolve log4j2.xml, using the fallback: " + log4jResource); try { if (log4jResource != null) { Configurator.initialize((String)null, null, log4jResource.toURI()); log4jLocation = log4jResource.toExternalForm(); } else { throw new VisalloResourceNotFoundException("Could not find log4j2.xml on the classpath"); } } catch (URISyntaxException e) { throw new VisalloException("Unable to load default log42.xml", e); } } else { log4jLocation = log4jFile.getAbsolutePath(); Configurator.initialize((String)null, null, log4jFile.toURI()); } VisalloLogger logger = VisalloLoggerFactory.getLogger(VisalloLoggerFactory.class); logger.info("Using ConfigurationLoader: %s", this.getClass().getName()); logger.info("Using log4j2.xml: %s", log4jLocation); }
throw new VisalloResourceNotFoundException("Could not resize image", e);
response.setContentType("text/html"); } else { throw new VisalloResourceNotFoundException("Only js,ejs,css,html files served from plugin"); throw new VisalloResourceNotFoundException("Could not find file: " + filePath);
throw new VisalloResourceNotFoundException("Error reading InputStream");
@Handle public void handle( @Required(name = "id") String id, User user ) throws Exception { ClientApiSearch savedSearch = this.searchRepository.getSavedSearch(id, user); if (savedSearch == null) { throw new VisalloResourceNotFoundException("Could not find saved search with id " + id); } this.searchRepository.deleteSearch(id, user); } }
@Handle public ClientApiDashboards handle( @ActiveWorkspaceId String workspaceId, User user ) throws Exception { Collection<Dashboard> dashboards = workspaceRepository.findAllDashboardsForWorkspace(workspaceId, user); if (dashboards == null) { throw new VisalloResourceNotFoundException("Could not find dashboards for workspace " + workspaceId); } return ClientApiConverter.toClientApiDashboards(dashboards); } }
@Handle public ClientApiEdge handle( @Required(name = "graphEdgeId") String graphEdgeId, @ActiveWorkspaceId String workspaceId, Authorizations authorizations ) throws Exception { Edge edge = graph.getEdge(graphEdgeId, authorizations); if (edge == null) { throw new VisalloResourceNotFoundException("Could not find edge: " + graphEdgeId); } Vertex outVertex = edge.getVertex(Direction.OUT, authorizations); if (outVertex == null) { throw new VisalloResourceNotFoundException("Could not find outVertex: " + edge.getVertexId(Direction.OUT)); } Vertex inVertex = edge.getVertex(Direction.IN, authorizations); if (inVertex == null) { throw new VisalloResourceNotFoundException("Could not find inVertex: " + edge.getVertexId(Direction.IN)); } return ClientApiConverter.toClientApiEdgeWithVertexData(edge, outVertex, inVertex, workspaceId, authorizations); } }
@Handle public ClientApiSearch handle( @Required(name = "id") String id, @ActiveWorkspaceId String workspaceId, User user ) throws Exception { ClientApiSearch search = this.searchRepository.getSavedSearchOnWorkspace(id, user, workspaceId); if (search == null) { throw new VisalloResourceNotFoundException("Could not find search with id: " + id); } return search; } }
@Handle public ClientApiWorkspaceDiff handle( @ActiveWorkspaceId String workspaceId, FormulaEvaluator.UserContext userContext, User user ) throws Exception { Workspace workspace = workspaceRepository.findById(workspaceId, true, user); if (workspace == null) { throw new VisalloResourceNotFoundException("Cannot find workspace: " + workspaceId); } return this.workspaceRepository.getDiff(workspace, user, userContext); } }
@Handle public ClientApiSuccess handle( @Required(name = "workspaceId") String workspaceId, @Required(name = "user-name") String userName, User me ) throws Exception { User user = userRepository.findByUsername(userName); if (user == null) { throw new VisalloResourceNotFoundException("Could not find user: " + userName); } Workspace workspace = workspaceRepository.findById(workspaceId, user); if (workspace == null) { throw new VisalloResourceNotFoundException("Could not find workspace: " + workspaceId); } workspaceRepository.updateUserOnWorkspace(workspace, me.getUserId(), WorkspaceAccess.WRITE, user); return VisalloResponse.SUCCESS; } }
@Handle public ClientApiDetectedObjects handle( @Required(name = "graphVertexId") String graphVertexId, @Required(name = "propertyName") String propertyName, @Required(name = "workspaceId") String workspaceId, Authorizations authorizations ) throws Exception { Vertex vertex = graph.getVertex(graphVertexId, authorizations); if (vertex == null) { throw new VisalloResourceNotFoundException(String.format("vertex %s not found", graphVertexId)); } ClientApiDetectedObjects detectedObjects = new ClientApiDetectedObjects(); Iterable<Property> detectedObjectProperties = vertex.getProperties(propertyName); if (detectedObjectProperties == null || IterableUtils.count(detectedObjectProperties) == 0) { throw new VisalloResourceNotFoundException(String.format("property %s not found on vertex %s", propertyName, vertex.getId())); } detectedObjects.addDetectedObjects(ClientApiConverter.toClientApiProperties(detectedObjectProperties, workspaceId)); return detectedObjects; }
@Handle public ClientApiVertex handle( @Required(name = "graphVertexId") String graphVertexId, @ActiveWorkspaceId String workspaceId, Authorizations authorizations ) throws Exception { Vertex vertex = graph.getVertex(graphVertexId, authorizations); if (vertex == null) { throw new VisalloResourceNotFoundException("Could not find vertex: " + graphVertexId); } return (ClientApiVertex) ClientApiConverter.toClientApi(vertex, workspaceId, authorizations); } }
@Handle public ClientApiSuccess handle( @Required(name = "notificationId") String notificationId, User user ) throws Exception { SystemNotification notification = systemNotificationRepository.getNotification(notificationId, user); if (notification == null) { throw new VisalloResourceNotFoundException("Could not find notification with id: " + notificationId); } systemNotificationRepository.endNotification(notification, user); workQueueRepository.pushSystemNotificationEnded(notificationId); return VisalloResponse.SUCCESS; } }