@Override public String toString() { return resource.getPath(); }
public String jsGet_path() { return this.resource.getPath(); }
/** * Determines whether a Registry <code>Node</code> is the root node wrt. to this * <code>PathManager</code> instance. That is, whether the path of the node is * equal to this instance's Registry root path. * * @param node * @return <code>true</code> iff <code>node</code> is the root node wrt. to * this <code>PathManager</code> instance. */ public boolean isRoot(Resource node) { return node.getPath().equals(gregRootPath); }
protected String getVersionSeriesId() throws RegistryException { //TODO Think on this later String path = resource.getPath(); if(path.endsWith(CMISConstants.PWC_SUFFIX)){ int endIndex = path.indexOf(CMISConstants.PWC_SUFFIX); return path.substring(0, endIndex); } else if(path.contains(";")){ int endIndex = path.indexOf(';'); return path.substring(0, endIndex); } return resource.getPath(); }
/** * Determine the CMIS path given a Registry <code>Node</code>. * * @param node * @return * @throws IllegalArgumentException when <code>node</code> is not part of the hierarchy */ public String getPath(Resource node) { if (gregRootPath.length() > node.getPath().length()) { throw new IllegalArgumentException("Node is not part of the hierarchy: " + node.getPath()); } String path = node.getPath().substring(gregRootPath.length()); return path.startsWith("/") ? path : '/' + path; }
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 boolean isCheckedOut(Resource node){ if(node.getPath().endsWith(CMISConstants.PWC_SUFFIX)){ String path = node.getPath(); try { node = getRepository().get( path.substring(0, path.indexOf(CMISConstants.PWC_SUFFIX))); } catch (RegistryException e) { String msg = "Failed to retrieve the resource at " + path; log.error(msg, e); throw new CmisObjectNotFoundException(msg, e); } } String property = node.getProperty(CMISConstants.GREG_IS_CHECKED_OUT); return (property != null && property.equals("true")); }
/** * See CMIS 1.0 section 2.2.4.14 deleteObject * * @throws CmisRuntimeException */ public void delete(boolean allVersions, boolean isPwc) { try { String path = resource.getPath(); repository.delete(path); } catch (RegistryException e) { String msg = "Failed to delete the object "; log.error(msg, e); throw new CmisRuntimeException(msg, e); } }
/** * @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()); }
@Override protected RegistryObject create(Resource resource) { DocumentTypeHandler documentTypeHandler = new DocumentTypeHandler(getRepository(), pathManager, typeManager); try { return documentTypeHandler.getGregNode(resource); } catch (RegistryException e) { log.error("Cannot create the object for the path " + resource.getPath(), e); } return null; }
public static String getServiceNamespace(Resource resource) throws RegistryException { String serviceInfo = convertContentToString(resource); try { XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new StringReader(serviceInfo)); StAXOMBuilder builder = new StAXOMBuilder(reader); OMElement serviceInfoElement = builder.getDocumentElement(); return getNamespaceFromContent(serviceInfoElement); } catch (Exception e) { String msg = "Error in getting the service namespace. service path: " + resource.getPath() + "."; log.error(msg, e); throw new RegistryException(msg, e); } }
private boolean isPrivateWorkingCopy(RegistryObject node) { String checkedOutProperty = node.getNode().getProperty(CMISConstants.GREG_IS_CHECKED_OUT); String createdAsPwcProperty = node.getNode().getProperty(CMISConstants.GREG_CREATED_AS_PWC); boolean checkedOut = checkedOutProperty != null && checkedOutProperty.equals("true"); boolean createdAsPwc = createdAsPwcProperty != null && createdAsPwcProperty.equals("true"); boolean endsWithPwc = node.getNode().getPath().endsWith(CMISConstants.PWC_SUFFIX); return (checkedOut || createdAsPwc || endsWithPwc); }
public static String getServiceName(Resource resource) throws RegistryException { String serviceInfo = convertContentToString(resource); try { XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new StringReader(serviceInfo)); StAXOMBuilder builder = new StAXOMBuilder(reader); OMElement serviceInfoElement = builder.getDocumentElement(); return getNameFromContent(serviceInfoElement); } catch (Exception e) { String msg = "Error in getting the service name. service path: " + resource.getPath() + "."; log.error(msg, e); throw new RegistryException(msg, e); } }
/** * Get the private working copy of the versions series or throw an exception if not checked out. * * @return a {@link RegistryPrivateWorkingCopy} instance * @throws CmisObjectNotFoundException if not checked out * @throws CmisRuntimeException */ public RegistryPrivateWorkingCopy getPwc(Resource node) { if (node.getPath().endsWith("_pwc")) { return new RegistryPrivateWorkingCopy(getRepository(), node, typeManager, pathManager); } else { throw new CmisObjectNotFoundException("Not checked out document has no private working copy"); } }
/** * @return <code>true</code> iff <code>versionName</code> is the name of private working copy. * @see RegistryPrivateWorkingCopy#PWC_NAME */ public static boolean denotesPwc(Registry registry, String versionName) { try { Resource resource = registry.get(versionName); String property = resource.getProperty(CMISConstants.GREG_CREATED_AS_PWC); String checkedOut = resource.getProperty(CMISConstants.GREG_IS_CHECKED_OUT); if(resource.getPath().endsWith(CMISConstants.PWC_SUFFIX) || ( property != null && property.equals("true") ) || ( checkedOut != null && checkedOut.equals("true") )){ return true; } } catch (RegistryException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } return false; }
private void encodeProperty(Resource resource, String propKey) { try { if (resource.getProperty(propKey) != null) { resource.setProperty(propKey, CryptoUtil.getDefaultCryptoUtil().encryptAndBase64Encode( resource.getProperty(propKey).getBytes())); } } catch (CryptoException e) { log.error("Unable to encrypt property key: " + propKey + " for resource " + "path: " + resource.getPath(), e); } }
private void decodeProperty(Resource resource, String propKey) { try { if(resource.getProperty(propKey)!=null){ resource.setProperty(propKey, new String(CryptoUtil.getDefaultCryptoUtil().base64DecodeAndDecrypt( resource.getProperty(propKey)))); } } catch (CryptoException e) { log.error("Unable to decrypt property key: " + propKey + " for resource " + "path: " + resource.getPath(), e); } } }
/** * 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 void removeRetentionPolicies(RegistrySession session) throws RepositoryException { try { if(session.getUserRegistry().resourceExists("/jcr_system/workspaces/default_workspace/testroot")) { Resource r = session.getUserRegistry().get("/jcr_system/workspaces/default_workspace/testroot"); r.removeProperty("org.wso2.carbon.registry.jcr.retention.policy"); r.removeProperty("org.wso2.carbon.registry.jcr.retention.holds"); session.getUserRegistry().put(r.getPath(),r); } } catch (RegistryException e) { throw new RepositoryException("Unable to remove TCK retention test data"); } } }