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); }
@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; } }
@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 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 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; } }
@Handle public ClientApiSuccess handle( @Required(name = "dashboardItemId") String dashboardItemId, @ActiveWorkspaceId String workspaceId, User user ) throws Exception { DashboardItem dashboardItem = workspaceRepository.findDashboardItemById(workspaceId, dashboardItemId, user); if (dashboardItem == null) { throw new VisalloResourceNotFoundException("Could not find dashboard item with id " + dashboardItemId); } workspaceRepository.deleteDashboardItem(workspaceId, dashboardItemId, user); return VisalloResponse.SUCCESS; } }
@Handle public ClientApiSuccess handle( @Required(name = "dashboardId") String dashboardId, @ActiveWorkspaceId String workspaceId, User user ) throws Exception { Dashboard dashboard = workspaceRepository.findDashboardById(workspaceId, dashboardId, user); if (dashboard == null) { throw new VisalloResourceNotFoundException("Could not find dashboard with id " + dashboardId); } workspaceRepository.deleteDashboard(workspaceId, dashboardId, user); return VisalloResponse.SUCCESS; } }
@Handle public ClientApiEdgeDetails handle( @Required(name = "edgeId") String edgeId, Authorizations authorizations ) throws Exception { Edge edge = this.graph.getEdge(edgeId, authorizations); if (edge == null) { throw new VisalloResourceNotFoundException("Could not find edge with id: " + edgeId, edgeId); } ClientApiSourceInfo sourceInfo = termMentionRepository.getSourceInfoForEdge(edge, authorizations); ClientApiEdgeDetails result = new ClientApiEdgeDetails(); result.sourceInfo = sourceInfo; return result; } }
@Handle public ClientApiSuccess handle( User authUser, @Required(name = "longRunningProcessId") String longRunningProcessId ) throws Exception { LOGGER.info("Attempting to cancel long running process: %s", longRunningProcessId); JSONObject longRunningProcess = longRunningProcessRepository.findById(longRunningProcessId, authUser); if (longRunningProcess == null) { throw new VisalloResourceNotFoundException("Could not find long running process: %s", longRunningProcessId); } else { longRunningProcessRepository.cancel(longRunningProcessId, authUser); return VisalloResponse.SUCCESS; } } }
@Handle public JSONObject handle( User authUser, @Required(name = "longRunningProcessId") String longRunningProcessId ) throws Exception { LOGGER.info("Attempting to retrieve long running process: %s", longRunningProcessId); JSONObject longRunningProcess = longRunningProcessRepository.findById(longRunningProcessId, authUser); if (longRunningProcess == null) { throw new VisalloResourceNotFoundException("Could not find long running process: %s", longRunningProcessId); } else { LOGGER.debug("Successfully found long running process"); return longRunningProcess; } } }
@Handle public ClientApiSuccess handle( User authUser, @Required(name = "longRunningProcessId") String longRunningProcessId ) throws Exception { LOGGER.info("deleting long running process: %s", longRunningProcessId); JSONObject longRunningProcess = longRunningProcessRepository.findById(longRunningProcessId, authUser); if (longRunningProcess == null) { throw new VisalloResourceNotFoundException("Could not find long running process: %s", longRunningProcessId); } else { LOGGER.debug("Successfully found long running process"); longRunningProcessRepository.delete(longRunningProcessId, authUser); return VisalloResponse.SUCCESS; } } }
@Handle public ClientApiSuccess handle( @Required(name = "user-name") String userName ) throws Exception { User user = userRepository.findByUsername(userName); if (user == null) { throw new VisalloResourceNotFoundException("Could find user: " + userName); } LOGGER.info("deleting user %s", user.getUserId()); userRepository.delete(user); this.graph.flush(); return VisalloResponse.SUCCESS; } }
@Handle public JSONObject handle( @Required(name = "user-name") String userName, @Required(name = "privileges") String privilegesParameter, User authUser ) throws Exception { Set<String> privileges = Privilege.stringToPrivileges(privilegesParameter); User user = userRepository.findByUsername(userName); if (user == null) { throw new VisalloResourceNotFoundException("Could not find user: " + userName); } privilegeRepository.setPrivileges(user, privileges, authUser); return userRepository.toJsonWithAuths(user); } }