public static UserRegistry getUserRegistry(HttpServletRequest request) throws RegistryException { UserRegistry userRegistry = (UserRegistry)request.getSession().getAttribute(RegistryConstants.REGISTRY_USER); if (userRegistry == null) { String msg = "User's Registry instance is not found. " + "Users have to login to retrieve a registry instance. "; log.error(msg); throw new RegistryException(msg); } return userRegistry; }
public void createDirectory(String path) throws RegistryException { File directory = new File(baseDir, path); if (directory.exists()) { return; } try { FileUtils.forceMkdir(directory); } catch (IOException e) { throw new RegistryException("Unable to create directory at path: " + directory.getAbsolutePath(), e); } }
public void copy(String source, String destination) throws RegistryException { File sourceFile = new File(baseDir, source); File destinationFile = new File(baseDir, destination); try { FileUtils.copyFile(sourceFile, destinationFile); } catch (IOException e) { throw new RegistryException("Unable to copy file at path: " + sourceFile.getAbsolutePath() + " to path: " + destinationFile.getAbsolutePath(),e); } }
private static List<OMElement> getOmElements(OMElement serviceElement) throws RegistryException { List<OMElement> serviceEndpointEntryElements; try { serviceEndpointEntryElements = evaluateXPathToElements(SERVICE_ENDPOINT_ENTRY_EXPR, serviceElement); } catch (Exception e) { String msg = "Error in evaluating xpath expressions to extract endpoints"; log.error(msg, e); throw new RegistryException(msg, e); } return serviceEndpointEntryElements; }
public void delete(String path) throws RegistryException { try { stub.delete(path); } catch (Exception e) { String msg = "Failed to perform delete operation."; log.error(msg, e); throw new RegistryException(msg, e); } }
public String move(String currentPath, String newPath) throws RegistryException { try { return stub.move(currentPath,newPath); } catch (Exception e) { String msg = "Failed to perform move operation."; log.error(msg, e); throw new RegistryException(msg, e); } }
public void createVersion(String path) throws RegistryException { try { stub.createVersion(path); } catch (Exception e) { String msg = "Failed to perform createVersion operation."; log.error(msg, e); throw new RegistryException(msg, e); } }
public void removeAssociation(String resourcePath, String targetPath, String associationType) throws RegistryException { try { stub.removeAssociation(resourcePath,targetPath,associationType); } catch (Exception e) { String msg = "Failed to perform removeAssociation operation."; log.error(msg, e); throw new RegistryException(msg, e); } }
public void rateResource(String resourcePath, int rating) throws RegistryException { try { stub.rateResource(resourcePath,rating); } catch (Exception e) { String msg = "Failed to perform rateResource operation."; log.error(msg, e); throw new RegistryException(msg, e); } } public float getAverageRating(String resourcePath) throws RegistryException {
public int getRating(String path, String username) throws RegistryException { try { return stub.getRating(path,username); } catch (Exception e) { String msg = "Failed to perform getRating operation."; log.error(msg, e); throw new RegistryException(msg, e); } } public Collection executeQuery(String path, Map parameters) throws RegistryException {
public boolean removeAspect(String name) throws RegistryException { try { return stub.removeAspect(name); } catch (Exception e) { String msg = "Failed to perform removeAspect operation."; log.error(msg, e); throw new RegistryException(msg, e); } }
public static void restoreVersion(UserRegistry userRegistry, String versionPath) throws Exception { try { userRegistry.restoreVersion(versionPath); } catch (RegistryException e) { String msg = "Failed to restore the version " + versionPath; log.error(msg, e); throw new RegistryException(msg, e); } } }
public void createOrUpdateFile(String path, byte[] content) throws RegistryException { File file = new File(baseDir, path); try { createDirectory(file.getParentFile().getAbsolutePath().substring( baseDir.getAbsolutePath().length())); FileUtils.writeByteArrayToFile(file, content); } catch (IOException e) { throw new RegistryException("Unable to write content to file at path: " + file.getAbsolutePath(), e); } }
public static void setSessionResourcePath(String path) throws RegistryException { MessageContext messageContext = MessageContext.getCurrentMessageContext(); if (messageContext == null) { String msg = "Could not get the user's Registry session. Message context not found."; log.error(msg); throw new RegistryException(msg); } HttpServletRequest request = (HttpServletRequest) messageContext.getProperty("transport.http.servletRequest"); request.getSession().setAttribute(RegistryConstants.SESSION_RESOURCE_PATH, path); }
public String[] getDirectoryContent(String path) throws RegistryException { File directory = new File(baseDir, path); if (!directory.exists() || !directory.isDirectory()) { throw new RegistryException("A directory does not exist at path: " + directory.getAbsolutePath()); } return directory.list(new AndFileFilter(HiddenFileFilter.VISIBLE, new OrFileFilter(DirectoryFileFilter.INSTANCE, FileFileFilter.FILE))); }
public String addComment(String resourcePath, Comment comment) throws RegistryException { try { WSComment wsComment = WSRegistryClientUtils.RegistryCommenttoWSComment(comment); return stub.wSaddComment(resourcePath,wsComment); } catch (Exception e) { String msg = "Failed to perform addComment operation."; log.error(msg, e); throw new RegistryException(msg, e); } } public void editComment(String commentPath, String text) throws RegistryException {
public static void process(String path, long snapshotId, UserRegistry registry) throws Exception { try { registry.removeVersionHistory(path, snapshotId); } catch (RegistryException e) { String msg = "Failed to delete the version of the " + snapshotId + " shapshot of " + path + ". " + ((e.getCause() instanceof SQLException) ? "" : e.getMessage()); log.error(msg, e); throw new RegistryException(msg, e); } } }
public static UserRegistry getUserRegistry(RegistryService registryService) throws RegistryException { MessageContext messageContext = MessageContext.getCurrentMessageContext(); if (messageContext == null) { String msg = "Could not get the user's Registry session. Message context not found."; log.error(msg); throw new RegistryException(msg); } HttpServletRequest request = (HttpServletRequest) messageContext.getProperty("transport.http.servletRequest"); return getUserRegistry(registryService, request); }
private void checkWriteLock(String path, RequestContext requestContext) throws RegistryException { String owner; if ((owner = checkRetentionLock(requestContext.getRegistry(), path, CommonConstants.RETENTION_WRITE_LOCKED_PROP_NAME)) != null) { requestContext.setProcessingComplete(true); throw new RegistryException("Resource Retention does not allow this operation. " + "Resource at path " + path + " is write locked by " + owner); } }
private void checkDeleteLock(String path, RequestContext requestContext) throws RegistryException { String owner; if ((owner = checkRetentionLock(requestContext.getRegistry(), path, CommonConstants.RETENTION_DELETE_LOCKED_PROP_NAME)) != null) { requestContext.setProcessingComplete(true); throw new RegistryException("Resource Retention does not allow this operation. " + "Resource at path: " + path + " is delete locked by " + owner); } }