protected Path collectPath(Path path) { String name = getName(); if (parent != null) { if (parent.isList()) { int i = ((ListProperty) parent).children.indexOf(this); name = name + '[' + i + ']'; } path = ((AbstractProperty) parent).collectPath(path); } return path.append(name); }
String schema = getSchema().getName(); String originalXpath = collectPath(new Path("/")).append(name).toString().substring(1); String xpath;
public Path removeFileExtension() { String extension = getFileExtension(); if (extension == null || extension.equals("")) { //$NON-NLS-1$ return this; } String lastSegment = lastSegment(); int index = lastSegment.lastIndexOf(extension) - 1; return removeLastSegments(1).append(lastSegment.substring(0, index)); }
protected AbstractVirtualBackend(String name, String rootUrl, CoreSession session, RealBackendFactory realBackendFactory) { super(session); this.backendDisplayName = name; this.rootUrl = new Path(rootUrl).append(this.backendDisplayName).toString(); this.realBackendFactory = realBackendFactory; }
protected String computeOldPathUserWorkspaceRoot() throws ClientException { Path path = new Path("/" + oldTargetDomainName); path = path.append(oldTargetUserWorkspaceRoot); return path.toString(); }
public String resolvePath(String relative) { return doc.getPath().append(relative).toString(); }
public String resolvePath(String relative) { return doc.getPath().append(relative).toString(); }
protected static String getCacheEntryPath(String key) { Path path = new Path(ConversionServiceImpl.getCacheBasePath()); List<String> subPath = getSubPathFromKey(key); for (String subPart : subPath) { path = path.append(subPart); new File(path.toString()).mkdir(); } // path = path.append(key); return path.toString(); }
public DocumentRef resolvePathAsRef(String relative) { return new PathRef(doc.getPath().append(relative).toString()); }
public DocumentRef resolvePathAsRef(String relative) { return new PathRef(doc.getPath().append(relative).toString()); }
@Override public DocumentTranslationMap write(ExportedDocument xdoc) throws IOException { if (xdoc.getDocument() == null) { // not a valid doc -> this may be a regular folder for example the // root of the tree return null; } Path path = xdoc.getPath(); // if (path.isEmpty() || path.isRoot()) { // return; // TODO avoid to import the root // } path = root.append(path); // compute target path return doWrite(xdoc, path); }
public TreeItemImpl(TreeItem parent, ContentProvider provider, Object data) { this.parent = parent; this.provider = provider; obj = data; String name = provider.getName(obj); if (parent != null) { path = parent.getPath().append(name); } else { path = new Path("/"); } if (provider.isContainer(obj)) { state |= F_CONTAINER; // set container flag and invalidate children } }
@Override public Path parseLocation(String location) { Path finalLocation = new Path(rootPath); Path rootUrlPath = new Path(rootUrl); Path urlLocation = new Path(location); Path cutLocation = urlLocation.removeFirstSegments(rootUrlPath.segmentCount()); finalLocation = finalLocation.append(cutLocation); String fileName = finalLocation.lastSegment(); String parentPath = finalLocation.removeLastSegments(1).toString(); return new Path(parentPath).append(fileName); }
@Override public DocumentObject newDocument(String path) { PathRef pathRef = new PathRef(doc.getPath().append(path).toString()); DocumentModel doc = ctx.getCoreSession().getDocument(pathRef); return (DocumentObject) ctx.newObject("Document", doc); }
public DocumentObject newDocument(String path) { PathRef pathRef = new PathRef(doc.getPath().append(path).toString()); DocumentModel doc = ctx.getCoreSession().getDocument(pathRef); return (DocumentObject) ctx.newObject(doc.getType(), doc); }
protected boolean cleanTrashPath(DocumentModel parent, String name) { Path checkedPath = new Path(parent.getPathAsString()).append(name); if (getSession().exists(new PathRef(checkedPath.toString()))) { DocumentModel model = getSession().getDocument(new PathRef(checkedPath.toString())); if (model != null && model.isTrashed()) { name = name + "." + System.currentTimeMillis(); getSession().move(model.getRef(), parent.getRef(), name); return true; } } return false; }
protected DocumentModel resolveParent(String location) { DocumentModel doc = null; DocumentRef docRef = new PathRef(location.toString()); if (exists(docRef)) { doc = getSession().getDocument(docRef); } else { Path locationPath = new Path(location); String filename = locationPath.lastSegment(); Path parentLocation = locationPath.removeLastSegments(1); // first try with spaces (for create New Folder) String folderName = filename; DocumentRef folderRef = new PathRef(parentLocation.append(folderName).toString()); if (exists(folderRef)) { doc = getSession().getDocument(folderRef); } } return doc; }
@Override public DocumentTranslationMap write(ExportedDocument xdoc) throws IOException { Path path = xdoc.getPath(); if (path.isEmpty() || path.isRoot()) { return null; // TODO avoid to import the root } path = root.append(path); // compute target path DocumentModel doc = createDocument(xdoc, path); DocumentLocation source = xdoc.getSourceLocation(); DocumentTranslationMap map = new DocumentTranslationMapImpl(source.getServerName(), doc.getRepositoryName()); map.put(source.getDocRef(), doc.getRef()); return map; }
protected static String getRootPath(CoreSession session, String basePath, String suffix) { PathRef rootRef = new PathRef(basePath); if (session.exists(rootRef)) { Path path = new Path(basePath).append(suffix); rootRef = new PathRef(path.toString()); if (session.exists(rootRef)) { return path.toString(); } else { DocumentModel root = session.createDocumentModel("Folder"); root.setPathInfo(basePath, suffix); root = session.createDocument(root); return root.getPathAsString(); } } return null; }
public static ExtensionPointInfoDocAdapter create(ExtensionPointInfo xpi, CoreSession session, String containerPath) { DocumentModel doc = session.createDocumentModel(TYPE_NAME); String name = computeDocumentName("xp-" + xpi.getId()); String targetPath = new Path(containerPath).append(name).toString(); boolean exist = false; if (session.exists(new PathRef(targetPath))) { exist = true; doc = session.getDocument(new PathRef(targetPath)); } doc.setPathInfo(containerPath, name); doc.setPropertyValue("dc:title", xpi.getId()); doc.setPropertyValue(PROP_NAME, xpi.getName()); doc.setPropertyValue(PROP_EP_ID, xpi.getId()); doc.setPropertyValue(PROP_DOC, xpi.getDocumentation()); // TODO incoherent naming here, also schema has no types doc.setPropertyValue(PROP_DESCRIPTORS, xpi.getDescriptors()); if (exist) { doc = session.saveDocument(doc); } else { doc = session.createDocument(doc); } return new ExtensionPointInfoDocAdapter(doc); }