@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } DocumentLocation other = (DocumentLocation) obj; if (docRef == null) { if (other.getDocRef() != null) { return false; } } else if (!docRef.equals(other.getDocRef())) { return false; } if (serverName == null) { if (other.getServerName() != null) { return false; } } else if (!serverName.equals(other.getServerName())) { return false; } return true; }
@Override public String getUrlFromDocumentView(DocumentView docView) { DocumentLocation docLoc = docView.getDocumentLocation(); String filepath = docView.getParameter(FILE_PROPERTY_PATH_KEY); String filename = docView.getParameter(FILENAME_KEY); if (docLoc != null && filepath != null && filename != null) { StringBuilder buf = new StringBuilder(); buf.append(getPrefix()); buf.append("/"); buf.append(docLoc.getServerName()); buf.append("/"); buf.append(docLoc.getDocRef().toString()); buf.append("/"); buf.append(filepath); buf.append("/"); buf.append(URIUtils.quoteURIPathToken(filename)); String uri = buf.toString(); Map<String, String> requestParams = new HashMap<>(docView.getParameters()); requestParams.remove(FILE_PROPERTY_PATH_KEY); requestParams.remove(FILENAME_KEY); return URIUtils.addParametersToURIQuery(uri, requestParams); } return null; }
protected DocumentModel loadDocument() throws DocumentNotFoundException { final DocumentRef docRef = getDocument().getDocRef(); DocumentModel doc = session.getDocument(docRef); doc.putContextData(DublinCoreListener.DISABLE_DUBLINCORE_LISTENER, true); return doc; }
@Override public DocumentTranslationMap write(ExportedDocument doc) throws IOException { initWriter(); writer.write(doc.getDocument()); // out.write(doc.getDocument().asXML().getBytes()); // keep location unchanged DocumentLocation oldLoc = doc.getSourceLocation(); String oldServerName = oldLoc.getServerName(); DocumentRef oldDocRef = oldLoc.getDocRef(); DocumentTranslationMap map = new DocumentTranslationMapImpl(oldServerName, oldServerName); map.put(oldDocRef, oldDocRef); return map; }
@Override public List<PublishedDocument> getExistingPublishedDocument(DocumentLocation docLoc) { List<PublishedDocument> publishedDocuments = super.getExistingPublishedDocument(docLoc); DocumentModel sourceDocument = coreSession.getDocument(docLoc.getDocRef()); if (sourceDocument.isProxy()) { // If on a proxy, we want all the others proxy pointing to the same // version if (!sourceDocument.hasFacet(RENDITION_FACET) && !sourceDocument.hasSchema(RENDITION_SCHEMA)) { return publishedDocuments; } DocumentRef docRef = new IdRef( (String) sourceDocument.getPropertyValue(Constants.RENDITION_SOURCE_ID_PROPERTY)); publishedDocuments.addAll(getPublishedDocumentsFromProxyDocument(docRef, sourceDocument)); } else { publishedDocuments.addAll(getPublishedDocumentsFromLiveDocument(docLoc.getDocRef())); } return publishedDocuments; }
@Override @Begin(id = "#{conversationIdGenerator.currentOrNewMainConversationId}", join = true) public String navigateToURL(String documentUrl) { final DocumentLocation docLoc; try { docLoc = DocumentLocator.parseDocRef(documentUrl); } catch (BadDocumentUriException e) { log.error("Cannot get document ref from uri " + documentUrl + ". " + e.getMessage(), e); return null; } final DocumentRef docRef = docLoc.getDocRef(); RepositoryLocation repLoc = new RepositoryLocation(docLoc.getServerName()); return navigateTo(repLoc, docRef); }
@Override public DocumentTranslationMap write(ExportedDocument doc) throws IOException { OutputFormat format = AbstractDocumentWriter.createPrettyPrint(); XMLWriter writer = null; try { writer = new XMLWriter(out, format); writer.write(doc.getDocument()); } finally { if (writer != null) { writer.close(); } } // keep location unchanged DocumentLocation oldLoc = doc.getSourceLocation(); String oldServerName = oldLoc.getServerName(); DocumentRef oldDocRef = oldLoc.getDocRef(); DocumentTranslationMap map = new DocumentTranslationMapImpl(oldServerName, oldServerName); map.put(oldDocRef, oldDocRef); return map; }
private DocumentTranslationMap doWrite(ExportedDocument xdoc, Path targetPath) { DocumentModel previousDoc = null; PathRef pathRef = new PathRef(targetPath.toString()); if (session.exists(pathRef)) { previousDoc = session.getDocument(pathRef); } DocumentModel doc; if (previousDoc == null) { doc = createDocument(xdoc, targetPath); } else { doc = updateDocument(xdoc, previousDoc); } DocumentLocation source = xdoc.getSourceLocation(); DocumentTranslationMap map = new DocumentTranslationMapImpl(source.getServerName(), doc.getRepositoryName()); if (source.getDocRef() != null && source.getDocRef().reference() != null) { map.put(source.getDocRef(), doc.getRef()); } return map; }
@Override public DocumentTranslationMap write(ExportedDocument doc) throws IOException { String path = doc.getPath().toString(); writeDocument(path, doc); // keep location unchanged DocumentLocation oldLoc = doc.getSourceLocation(); String oldServerName = oldLoc.getServerName(); DocumentRef oldDocRef = oldLoc.getDocRef(); DocumentTranslationMap map = new DocumentTranslationMapImpl(oldServerName, oldServerName); map.put(oldDocRef, oldDocRef); return map; }
documentManager = navigationContext.getOrCreateDocumentManager(); DocumentModel doc = documentManager.getDocument(docLoc.getDocRef()); if (doc == null) { return;
@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; } DocumentModel doc = null; String id = xdoc.getId(); try { doc = session.getDocument(new IdRef(id)); } catch (DocumentNotFoundException e) { log.error("Cannot update document. No such document: " + id); return null; } doc = updateDocument(xdoc, doc); DocumentLocation source = xdoc.getSourceLocation(); DocumentTranslationMap map = new DocumentTranslationMapImpl(source.getServerName(), doc.getRepositoryName()); map.put(source.getDocRef(), doc.getRef()); return map; }
DocumentTranslationMap map = new DocumentTranslationMapImpl(repo, repo); DocumentModel sourceDoc = session.getDocument(source); DocumentModel destDoc = session.copy(source, targetLocation.getDocRef(), null); roots.add(destDoc.getRef());
@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; }
/** * @since 5.7 */ public void downloadThumbnail(DocumentView docView) { if (docView != null) { DocumentLocation docLoc = docView.getDocumentLocation(); if (documentManager == null) { RepositoryLocation loc = new RepositoryLocation(docLoc.getServerName()); navigationContext.setCurrentServerLocation(loc); documentManager = navigationContext.getOrCreateDocumentManager(); } DocumentModel doc = documentManager.getDocument(docLoc.getDocRef()); if (doc != null) { ThumbnailAdapter thumbnailDoc = doc.getAdapter(ThumbnailAdapter.class); Blob thumbnail = thumbnailDoc.getThumbnail(documentManager); if (thumbnail == null) { return; } ComponentUtils.download(doc, null, thumbnail, thumbnail.getFilename(), "thumbnail"); } } } }