public DocumentTreeIterator(CoreSession session, DocumentModel root, boolean excludeRoot) { this.root = root; this.session = session; if (excludeRoot) { sequence = session.getChildrenIterator(root.getRef(), null, null, null); } else { sequence = new OneDocSequence(root); } }
protected boolean hasPermission(CoreSession session, DocumentModel doc, Set<String> permissions, boolean required) { for (String permission : permissions) { if ((required && !session.hasPermission(doc.getRef(), permission)) || (!required && session.hasPermission(doc.getRef(), permission))) { return false; } } return true; }
/** * Opens a {@link CoreSession} for a system user. * <p> * The session must be closed using {@link CloseableCoreSession#close}. * * @param repositoryName the repository name, or {@code null} for the default repository * @return the session * @since 5.9.3 */ public static CloseableCoreSession openCoreSessionSystem(String repositoryName) { return openCoreSession(repositoryName, new SystemPrincipal(null)); }
public DocumentLocationImpl(DocumentModel doc) { serverName = doc.getRepositoryName(); docRef = doc.getRef(); String id = doc.getId(); if (id != null) { docIdRef = new IdRef(id); } else { docIdRef = null; } String path = doc.getPathAsString(); if (path != null) { docPathRef = new PathRef(path); } else { docPathRef = null; } }
protected boolean checkUnrestricted(CoreSession session) { return session.getPrincipal().isAdministrator(); }
@Override public void attach(String sid) { if (this.sid != null) { throw new NuxeoException("Cannot attach a document that is already attached"); } this.sid = sid; }
@Override public Calendar getModificationDate() { return (Calendar) doc.getProperty("dublincore", "modified"); }
/** * Opens a {@link CoreSession} for the currently logged-in user. * <p> * The session must be closed using {@link CloseableCoreSession#close}. * * @param repositoryName the repository name, or {@code null} for the default repository * @return the session * @since 5.9.3 */ public static CloseableCoreSession openCoreSession(String repositoryName) { return openCoreSession(repositoryName, getPrincipal(null)); }
@Override public void transferTo(File file) throws IOException { blob.transferTo(file); }
@Override public void setEncoding(String encoding) { blob.setEncoding(encoding); }
@Override public boolean accept(DocumentModel docModel) { for (Filter filter : filters) { if (!filter.accept(docModel)) { return false; } } return true; }
@Override public byte[] getByteArray() throws IOException { return blob.getByteArray(); }
@Override public void setDigest(String digest) { blob.setDigest(digest); }
/** * Registers the input {@link C} and generates a new <code>scrollId</code> to associate with. * * @return the scrollId associated to the cursor. */ public String registerCursor(C cursor, int batchSize, int keepAliveSeconds) { return registerCursorResult(new CursorResult<>(cursor, batchSize, keepAliveSeconds)); }
/** * Runs the given {@link Consumer} with a system {@link CoreSession} while logged in as a system user. * * @param repositoryName the repository name for the {@link CoreSession} * @param consumer the consumer taking a system {@link CoreSession} * @since 8.4 */ public static void doPrivileged(String repositoryName, Consumer<CoreSession> consumer) { new UnrestrictedSessionRunner(repositoryName, getCurrentPrincipalName()) { @Override public void run() { consumer.accept(session); } }.runUnrestricted(); }
protected boolean isScrollTimedOut(String scrollId, CursorResult<C, O> cursorResult) { if (cursorResult.timedOut()) { if (unregisterCursor(scrollId)) { log.warn("Scroll '" + scrollId + "' timed out"); } return true; } return false; }
public ServerException() { fillInStackTrace(); }
/** * Opens a {@link CoreSession} for a system user with an optional originating username. * <p> * The session must be closed using {@link CloseableCoreSession#close}. * * @param repositoryName the repository name, or {@code null} for the default repository * @param originatingUsername the originating username to set on the SystemPrincipal * @return the session * @since 8.1 */ public static CloseableCoreSession openCoreSessionSystem(String repositoryName, String originatingUsername) { return openCoreSession(repositoryName, new SystemPrincipal(originatingUsername)); }
/** * Registers the input {@link C} associated to the input <code>scrollId</code>. * * @return the scrollId associated to the cursor. */ public String registerCursor(String scrollId, C cursor, int batchSize, int keepAliveSeconds) { return registerCursorResult(scrollId, new CursorResult<>(cursor, batchSize, keepAliveSeconds)); }