@Override public String generatePathSegment(String s) { return IdUtils.generateId(s, "-", true, getMaxSize()); }
/** * Generates path segment: * - value is lowercased * - length is 24 at maximum * - empty spaces are replaced by '-'. */ @Override public String generatePathSegment(String value) throws NuxeoException { return IdUtils.generateId(value, "-", true, maxSize); }
@Override public String generatePathSegment(String s) throws ClientException { return IdUtils.generateId(s, "-", true, -1); }
protected static String computeDocumentName(String name) { return IdUtils.generateId(name, "-", true, 500); }
@Override public String generatePathSegment(DocumentModel doc) throws ClientException { String s = doc.getTitle(); if (s == null) { s = ""; } return IdUtils.generateId(s, "-", true, 24); }
protected void generateCandidates(List<String> names, String username, int max) { String name = IdUtils.generateId(username, "-", false, max); if (!names.contains(name)) { names.add(name); } if (name.length() == max) { // at max size or truncated String digested = name.substring(0, name.length() - 8) + digest(username, 8); if (!names.contains(digested)) { names.add(digested); } } }
@Override public String generatePathSegment(DocumentModel doc) throws ClientException { String s = doc.getTitle(); if (s == null) { s = StringUtils.EMPTY; } return IdUtils.generateId(s, "-", true, -1); } };
/** * Generates path segment based on document's title. */ @Override public String generatePathSegment(DocumentModel doc) throws NuxeoException { String title = doc.getTitle(); if (title == null) { title = StringUtils.EMPTY; } return IdUtils.generateId(title, "-", true, maxSize); }
@Override public String getSequenceKey(DocumentModel document) throws DocumentException { assert document != null; String title = StringUtils.EMPTY; if(DafpicConstants.CST_DOC_TYPE_CONTACT.equals(document.getType())){ String firstName = (String) document.getPropertyValue(DafpicConstants.CST_DOC_XPATH_CONTACT_FIRST_NAME); String lastName = (String) document.getPropertyValue(DafpicConstants.CST_DOC_XPATH_CONTACT_LAST_NAME); title = IdUtils.generateId(firstName, "-", true, 3) + IdUtils.generateId(lastName, "-", true, 3); } else { title = (String) document.getTitle(); if(StringUtils.isNotBlank(title)){ title = IdUtils.generateId(title, "-", true, 7); } else { title = "-"; } } return StringUtils.lowerCase(new StringBuffer().append(document.getType()) .append("-").append(title).toString()); }
public static synchronized DocumentModel getOrCreate(CoreSession session, String rootPath, String id, String folderType) { String path = String.format("%s/%s", rootPath, id); DocumentRef pathRef = new PathRef(path); boolean exists = session.exists(pathRef); if (exists) { DocumentModel existing = session.getDocument(pathRef); if (!existing.isTrashed()) { return existing; } } // create it DocumentModel newDocument = session.createDocumentModel(rootPath, IdUtils.generateId(id, "-", true, 24), folderType); newDocument.setPropertyValue(TITLE_PROPERTY_NAME, id); newDocument = session.createDocument(newDocument); return newDocument; }
newName = newName + "_" + version; newName = IdUtils.generateId(newName, "-", true, 100);
@Override public DocumentationItem createDocumentationItem(CoreSession session, NuxeoArtifact item, String title, String content, String type, List<String> applicableVersions, boolean approved, String renderingType) { DocumentModel doc = session.createDocumentModel(DocumentationItem.TYPE_NAME); String name = title + '-' + item.getId(); name = IdUtils.generateId(name, "-", true, 64); UUID docUUID = UUID.nameUUIDFromBytes(name.getBytes()); doc.setPathInfo(getDocumentationRoot(session).getPathAsString(), name); doc.setPropertyValue("dc:title", title); Blob blob = Blobs.createBlob(content); blob.setFilename(type); doc.setPropertyValue("file:content", (Serializable) blob); doc.setPropertyValue(DocumentationItem.PROP_TARGET, item.getId()); doc.setPropertyValue(DocumentationItem.PROP_TARGET_TYPE, item.getArtifactType()); doc.setPropertyValue(DocumentationItem.PROP_DOCUMENTATION_ID, docUUID.toString()); doc.setPropertyValue(DocumentationItem.PROP_NUXEO_APPROVED, Boolean.valueOf(approved)); doc.setPropertyValue(DocumentationItem.PROP_TYPE, type); doc.setPropertyValue(DocumentationItem.PROP_RENDERING_TYPE, renderingType); doc.setPropertyValue(DocumentationItem.PROP_APPLICABLE_VERSIONS, (Serializable) applicableVersions); doc = session.createDocument(doc); session.save(); return doc.getAdapter(DocumentationItem.class); }