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 void process(String pathToDelete, UserRegistry registry) throws Exception { try { if (RegistryConstants.ROOT_PATH.equals(pathToDelete) || RegistryConstants.SYSTEM_COLLECTION_BASE_PATH.equals(pathToDelete) || RegistryConstants.GOVERNANCE_REGISTRY_BASE_PATH.equals(pathToDelete) || RegistryConstants.CONFIG_REGISTRY_BASE_PATH.equals(pathToDelete) || RegistryConstants.LOCAL_REPOSITORY_BASE_PATH.equals(pathToDelete)) { throw new RegistryException("Unable to delete system collection at " + pathToDelete + "."); } registry.delete(pathToDelete); } catch (RegistryException e) { String msg = "Failed to delete " + pathToDelete + ". " + ((e.getCause() instanceof SQLException) ? "" : e.getMessage()); log.error(msg, e); throw new RegistryException(msg, e); } } }
public static void renameResource( String parentPath, String oldResourcePath, String newResourceName, UserRegistry registry) throws Exception { if (!parentPath.endsWith(RegistryConstants.PATH_SEPARATOR)) { parentPath = parentPath + RegistryConstants.PATH_SEPARATOR; } String newResourcePath; if (newResourceName.startsWith(RegistryConstants.ROOT_PATH)) { newResourcePath = newResourceName; } else { newResourcePath = parentPath + newResourceName; } try { registry.rename(oldResourcePath, newResourcePath); } catch (RegistryException e) { String msg = "Failed to rename the resource: " + oldResourcePath + " to name: " + newResourcePath + ". Caused by: " + ((e.getCause() instanceof SQLException) ? "" : e.getMessage()); log.error(msg, e); throw new RegistryException(msg, e); } } }
public static void addRemoteLink ( UserRegistry userRegistry, String parentPath, String name, String instance, String targetPath) throws Exception { String linkResourcePath; if (RegistryConstants.ROOT_PATH.equals(parentPath)) { linkResourcePath = RegistryConstants.ROOT_PATH + name; } else { linkResourcePath = parentPath + RegistryConstants.PATH_SEPARATOR + name; } try { userRegistry.createLink(linkResourcePath, instance, targetPath); } catch (RegistryException e) { String msg = "Failed to add symbolic link to path " + linkResourcePath + ". " + ((e.getCause() instanceof SQLException) ? "" : e.getMessage()); log.error(msg, e); throw new RegistryException(msg, e); } }
public static void addSymbolicLink ( UserRegistry userRegistry, String parentPath, String name, String targetPath) throws Exception { String linkResourcePath; if (RegistryConstants.ROOT_PATH.equals(parentPath)) { linkResourcePath = RegistryConstants.ROOT_PATH + name; } else { linkResourcePath = parentPath + RegistryConstants.PATH_SEPARATOR + name; } if (RegistryConstants.ROOT_PATH.equals(targetPath)) { String msg = "Unable to create symbolic link to root."; log.error(msg); throw new RegistryException(msg); } try { userRegistry.createLink(linkResourcePath, targetPath); } catch (RegistryException e) { String msg = "Failed to add symbolic link to path " + linkResourcePath + ". " + ((e.getCause() instanceof SQLException) ? "" : e.getMessage()); log.error(msg, e); throw new RegistryException(msg, e); } }
newResourcePath + ". Caused by: " + ((e.getCause() instanceof SQLException) ? "" : e.getMessage()); log.error(msg, e);
String msg = "Failed to move the resource: " + oldResourcePath + " to Destination: " + newResourcePath + ". Caused by: " + ((e.getCause() instanceof SQLException) ? "" : e.getMessage()); log.error(msg, e);
} catch (RegistryException e) { String msg = "Failed to add collection " + path + ". " + ((e.getCause() instanceof SQLException) ? "" : e.getMessage()); log.error(msg, e);
public static String getProperty(UserRegistry registry, String resourcePath, String key) throws RegistryException { try { if (registry.resourceExists(resourcePath)) { Resource resource = registry.get(resourcePath); if (resource != null) { String value = resource.getProperty(key); resource.discard(); return value; } } } catch (RegistryException e) { String msg = "Failed to get the resource information of resource " + resourcePath + " for retrieving a property with key : " + key + ". Error :" + ((e.getCause() instanceof SQLException) ? "" : e.getMessage()); log.error(msg, e); throw e; } return ""; } }
public static String getTextContent(String path, Registry registry) throws Exception { try { if (path != null && path.contains("..")) { path = FilenameUtils.normalize(path); } Resource resource = registry.get(path); byte[] content = (byte[]) resource.getContent(); String contentString = ""; if (content != null) { contentString = RegistryUtils.decodeBytes(content); } resource.discard(); return contentString; } catch (RegistryException e) { String msg = "Could not get the content of the resource " + path + ". Caused by: " + ((e.getCause() instanceof SQLException) ? "" : e.getMessage()); log.error(msg, e); throw new RegistryException(msg, e); } }
((e.getCause() instanceof SQLException) ? "" : e.getMessage()); log.error(msg, e);
public static void updateTextContent(String path, String contentText, Registry registry) throws Exception { try { Resource resource = registry.get(path); String mediaType = resource.getMediaType(); if (resource.getProperty(RegistryConstants.REGISTRY_LINK) != null && (CommonConstants.WSDL_MEDIA_TYPE.equals(mediaType) || CommonConstants.SCHEMA_MEDIA_TYPE.equals(mediaType))) { String description = resource.getDescription(); Properties properties = (Properties) resource.getProperties().clone(); resource = registry.newResource(); resource.setMediaType(mediaType); resource.setDescription(description); resource.setProperties(properties); } resource.setContent(RegistryUtils.encodeString(contentText)); registry.put(path, resource); resource.discard(); } catch (RegistryException e) { String msg = "Could not update the content of the resource " + path + ". Caused by: " + ((e.getCause() instanceof SQLException) ? "" : e.getMessage()); log.error(msg, e); throw new RegistryException(msg, e); } } }
((e.getCause() instanceof SQLException) ? "" : e.getMessage()); log.error(msg, e);
resourcePath + ". " + ((e.getCause() instanceof SQLException) ? "" : e.getMessage()); log.error(msg, e);
resourcePath + ". " + ((e.getCause() instanceof SQLException) ? "" : e.getMessage()); log.error(msg, e);
path + ". " + ((e.getCause() instanceof SQLException) ? "" : e.getMessage()); log.error(msg, e);