private static Boolean resourceExists(Registry registry, LogEntry entry) { try { return registry != null && entry != null && entry.getResourcePath() != null && registry.resourceExists(entry.getResourcePath()); } catch (RegistryException ignore) { return false; } }
public static void copyTags(Registry registry, String newPath, String path) throws RegistryException { Tag[] tags = registry.getTags(path); for (Tag tag : tags) { registry.applyTag(newPath, tag.getTagName()); } }
/** * Method to make an aspect to default. * @param path path of the resource * @param aspect the aspect to be removed. * @param registry registry instance to be used */ public static void setDefaultLifeCycle(String path, String aspect, Registry registry) throws RegistryException { Resource resource = registry.get(path); if(resource != null) { resource.setProperty("registry.LC.name", aspect); registry.put(path, resource); } }
@Override public void createLink(RequestContext requestContext) throws RegistryException { String symlinkPath = requestContext.getResourcePath().getPath(); String targetResourcePath = requestContext.getTargetPath(); if (requestContext.getRegistry().resourceExists(targetResourcePath)) { Resource r = requestContext.getRegistry().get(targetResourcePath); r.addProperty("registry.resource.symlink.path", symlinkPath); requestContext.getRegistry().put(targetResourcePath, r); } }
private static void removeEndpointDependencies(String servicePath, Registry registry) throws RegistryException { // update lock check removed from for loop to prevent the database lock Association[] associations = registry.getAllAssociations(servicePath); for (Association association : associations) { String path = association.getDestinationPath(); if (registry.resourceExists(path)) { Resource endpointResource = registry.get(path); if (CommonConstants.ENDPOINT_MEDIA_TYPE.equals(endpointResource.getMediaType())) { registry.removeAssociation(servicePath, path, CommonConstants.DEPENDS); registry.removeAssociation(path, servicePath, CommonConstants.USED_BY); } } } }
private void deleteRecursively(String path,Registry registry) throws RegistryException { Resource currentResource = registry.get(path); if((currentResource instanceof Collection) && ((Collection)currentResource).getChildCount() == 0 ){ registry.delete(path); deleteRecursively(currentResource.getParentPath(),registry); } }
/** * Remove a property from a GREG node */ public static void removeProperty(Registry repository,Resource resource, PropertyData<?> propertyData) throws RegistryException { String id = propertyData.getId(); if(resource.getPropertyValues(id) != null ){ //has property resource.removeProperty(id); repository.put(resource.getPath(), resource); } }
public static String getLifeCycleName(Resource resource) { String lifeCycleName = ""; if (resource.getProperties() != null) { if (resource.getProperty("registry.LC.name") != null) { lifeCycleName = resource.getProperty("registry.LC.name"); } } return lifeCycleName; }
private boolean isIndexablePutOperation(RequestContext requestContext) { return (requestContext.getRegistry().getRegistryContext() == null) || requestContext.getResource() == null || requestContext.getResource().getMediaType() == null || requestContext.getResource() instanceof Collection; }
protected static boolean hasProperty(Resource resource,String propertyName){ String property = resource.getProperty(propertyName); return property != null; }
public RegistryDocument getGregNode(Resource node) throws RegistryException { String version = node.getPath(); String[] versions = repository.getVersions(node.getPath()); if(versions !=null && versions.length != 0){ version = versions[0]; } return new RegistryVersion(repository, node, version, typeManager, pathManager); }
private String getPathWithoutVersion(String pathWithVersion) { ResourcePath path = new ResourcePath(pathWithVersion); return path.getPath(); }
public ResourceContentInputStream(Resource resource) throws RegistryException { this.resource = resource; inputStream = resource.getContentStream(); }
/** * Adds associations for a given source and target * * @param registry registry. * @param source source path. * @param target target path. * @throws RegistryException If fails to add a dependency. */ public static void addDependency(Registry registry, String source, String target) throws RegistryException { registry.addAssociation(source, target, CommonConstants.DEPENDS); registry.addAssociation(target, source, CommonConstants.USED_BY); }
/** * @return the last modifier of the CMIS object represented by this instance * @throws RegistryException */ protected String getLastModifiedBy() throws RegistryException { return resource.getLastUpdaterUserName(); }
public boolean isNew() { boolean isNew = false; try { if (resource != null) { isNew = !(resource instanceof Collection) || (((CollectionImpl) resource).getChildren() != null && ((CollectionImpl) resource).getChildren().length == 0); } } catch (Exception e) { isNew = true; } return isNew; }
public static void copyComments(Registry registry, String newPath, String path) throws RegistryException { Comment[] comments = registry.getComments(path); for (Comment comment : comments) { registry.addComment(newPath, comment); } } /*
public String getCurrentState(Resource resource) { return resource.getProperty(stateProperty); } }
/** * @return Id of the version representing the base of this versions series * @throws RegistryException */ protected String getBaseNodeId() throws RegistryException { String[] versions = getRepository().getVersions(getNode().getPath()); return (versions.length != 0 ? versions[versions.length-1] : getNode().getPath()); }
private void addDependency(String source, String target) throws RegistryException { registry.addAssociation(source, target, CommonConstants.DEPENDS); registry.addAssociation(target, source, CommonConstants.USED_BY); } }