@Override public String getName() { if (path != null) { return path.lastSegment(); } return null; }
@Override public String getName() { return path == null ? null : path.lastSegment(); }
public String getName() { return path.lastSegment(); }
@Override public boolean accept(Path arg0) { return !arg0.lastSegment().endsWith(".class"); } });
public String getFileExtension() { if (hasTrailingSeparator()) { return null; } String lastSegment = lastSegment(); if (lastSegment == null) { return null; } int index = lastSegment.lastIndexOf('.'); if (index == -1) { return null; } return lastSegment.substring(index + 1); }
public static String getNameFromPath(String path) { return new Path(path).lastSegment(); }
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)); }
if (entry.getName().startsWith(PARENT_DOC_PREFIX) && !entry.isDirectory()) { String content = IOUtils.toString(is, StandardCharsets.UTF_8); String name = new Path(entry.getName()).lastSegment(); if (name.length() >= 6 && name.substring(0, 6).equalsIgnoreCase("readme")) { String name = new Path(entry.getName()).lastSegment(); if (name.length() >= 6 && name.substring(0, 6).equalsIgnoreCase("readme")) {
@Factory(value = "currentPersonalWorkspacePath", scope = EVENT) public String getCurrentPersonalWorkspace() { if (currentPersonalWorkspacePath == null && Boolean.TRUE.equals(isUserWorkspace)) { // Do not compute path if not necessary Path path = navigationContext.getCurrentDocument().getPath(); String lastSegment = ""; while (!path.isRoot() || !path.isEmpty()) { if (UserWorkspaceConstants.USERS_PERSONAL_WORKSPACES_ROOT.equals(path.lastSegment())) { if (lastSegment.isEmpty()) { currentPersonalWorkspacePath = ""; } else { currentPersonalWorkspacePath = path.append(lastSegment).toString(); } return currentPersonalWorkspacePath; } else { lastSegment = path.lastSegment(); } path = path.removeLastSegments(1); } } return currentPersonalWorkspacePath; }
protected void registerSimpleBackends(List<DocumentModel> docs) { List<String> paths = new ArrayList<String>(); for (DocumentModel doc : docs) { paths.add(doc.getPathAsString()); } List<String> heads = new ArrayList<String>(); for (int idx = 0; idx < paths.size(); idx++) { String path = paths.get(idx); if (isHead(path, paths, idx)) { heads.add(path); } } for (String head : heads) { String headName = new Path(head).lastSegment(); String name = headName; int idx = 1; while (backendMap.containsKey(name)) { name = headName + "-" + idx; idx = idx + 1; } Backend backend = realBackendFactory.createBackend(name, head, new Path(this.rootUrl).append(name).toString(), getSession()); registerBackend(backend); } }
public TreeItem find(Path path) { TreeItem item = this; for (int i = 0, len = path.segmentCount() - 1; i < len; i++) { if (!item.hasChildren()) { return null; } item = item.getChild(path.segment(i)); if (item == null) { return null; } } if (!item.hasChildren()) { return null; } return item.getChild(path.lastSegment()); }
/** * To throw creation or update document exception. */ @Override public DocumentTranslationMap write(ExportedDocument xdoc) throws IOException { DocumentTranslationMap dtm = super.write(xdoc); Boolean compatibilityImport = Boolean.valueOf(Framework.getProperty("ottc.import.archive.compatibility", "true")); // Maybe error in creation or update if(dtm == null){ // (Re-) Check schema definition in case of creation try { Path xDocPath = xdoc.getPath(); Path parentPath = xDocPath.removeLastSegments(1); String name = xDocPath.lastSegment(); DocumentModel docModel = new DocumentModelImpl(parentPath.toString(), name, xdoc.getType()); super.loadSchemas(xdoc, docModel, xdoc.getDocument()); } catch (NuxeoException ce) { if(BooleanUtils.isNotTrue(compatibilityImport)){ if(log.isDebugEnabled()){ log.debug(ce.getMessage(), ce); } throw new IOException(ce.getMessage(), ce); } } } return dtm; }
String name = toPath.lastSegment();
@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); }
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 protected DocumentModel doCreateUserWorkspace(CoreSession unrestrictedSession, PathRef wsRef, String userName) { String parentPath = new Path(wsRef.toString()).removeLastSegments(1).toString(); String wsName = new Path(wsRef.toString()).lastSegment(); DocumentModel doc = unrestrictedSession.createDocumentModel(parentPath, wsName, getUserWorkspaceType()); doc.setProperty("dublincore", "title", buildUserWorkspaceTitle(userName)); doc.setProperty("dublincore", "description", ""); return doc; }
@Override public void run() { DocumentRef pathRef = new PathRef(parentPath); if (session.exists(pathRef)) { taskRootDoc = session.getDocument(pathRef); } else { Path path = new Path(parentPath); taskRootDoc = session.createDocumentModel(path.removeLastSegments(1).toString(), path.lastSegment(), TaskConstants.TASK_ROOT_TYPE_NAME); taskRootDoc = session.createDocument(taskRootDoc); ACP acp = taskRootDoc.getACP(); ACL acl = acp.getOrCreateACL(ACL.LOCAL_ACL); acl.add(new ACE("Everyone", "Everything", false)); taskRootDoc.setACP(acp, true); taskRootDoc = session.saveDocument(taskRootDoc); } }
protected static DocumentModel createUserWorkspace( CoreSession unrestrictedSession, PathRef wsRef, String userName) throws ClientException { String parentPath = new Path(wsRef.toString()).removeLastSegments(1).toString(); String wsName = new Path(wsRef.toString()).lastSegment(); DocumentModel doc = unrestrictedSession.createDocumentModel(parentPath, wsName,"UserWorkspace"); doc.setProperty("dublincore", "title", userName); doc.setProperty("dublincore", "description", ""); doc = unrestrictedSession.createDocument(doc); ACP acp = new ACPImpl(); ACE grantEverything = new ACE(userName, SecurityConstants.EVERYTHING, true); ACL acl = new ACLImpl(); acl.setACEs(new ACE[] { grantEverything }); acp.addACL(acl); doc.setACP(acp, true); return doc; }
protected static DocumentModel createUserWorkspacesRoot( CoreSession unrestrictedSession, PathRef rootRef) throws ClientException { String parentPath = new Path(rootRef.toString()).removeLastSegments(1).toString(); String docName = new Path(rootRef.toString()).lastSegment(); DocumentModel doc = unrestrictedSession.createDocumentModel(parentPath, docName,"UserWorkspacesRoot"); doc.setProperty("dublincore", "title", docName); doc.setProperty("dublincore", "description", ""); doc = unrestrictedSession.createDocument(doc); ACP acp = new ACPImpl(); ACE denyEverything = new ACE(SecurityConstants.EVERYONE, SecurityConstants.EVERYTHING, false); ACL acl = new ACLImpl(); acl.setACEs(new ACE[] { denyEverything }); acp.addACL(acl); doc.setACP(acp, true); return doc; }
resultingRef = rootRef; } else { String rootName = root.getPath().lastSegment(); resultingRef = new PathRef(parentPath, rootName);