/** * Constructs a {@link UnrestrictedSessionRunner} given an existing session (which may or may not be already * unrestricted). * <p> * Originating user is taken on given session. * * @param session the available session */ protected UnrestrictedSessionRunner(CoreSession session) { this.session = session; sessionIsAlreadyUnrestricted = checkUnrestricted(session); if (sessionIsAlreadyUnrestricted) { repositoryName = null; } else { repositoryName = session.getRepositoryName(); } NuxeoPrincipal pal = session.getPrincipal(); if (pal != null) { originatingUsername = pal.getName(); } }
protected void updateRepositoryName() { if (session != null) { repositoryName = session.getRepositoryName(); } }
public void attach(CoreSession session) { if (!session.getRepositoryName().equals(repositoryName)) { throw new IllegalArgumentException( "Invalid session, expected repo: " + repositoryName + " actual: " + session.getRepositoryName()); } sessionId = session.getSessionId(); assert sessionId != null : "Attach to session with a null sessionId"; }
public NxQueryBuilder(CoreSession coreSession) { session = coreSession; repositories.add(coreSession.getRepositoryName()); fetchFromElasticsearch = Boolean.parseBoolean(Framework.getProperty(FETCH_DOC_FROM_ES_PROPERTY, "false")); }
public void push(LoginContext lc) { Entry entry = new Entry(lc); String repositoryName; if (originalSession != null) { repositoryName = originalSession.getRepositoryName(); } else { repositoryName = null; // default repository } entry.session = CoreInstance.openCoreSession(repositoryName); currentSession = entry.session; stack.add(entry); }
@OperationMethod public Blob run() throws IOException { checkAccess(); esa.dropAndInitRepositoryIndex(session.getRepositoryName(), false); String commandId = submitBulkCommand("SELECT ecm:uuid FROM Document", true); log.warn(String.format("Submitted index command: %s to index the entire %s repository.", commandId, session.getRepositoryName())); return Blobs.createJSONBlobFromValue(Collections.singletonMap("commandId", commandId)); }
protected String getIndexName(CoreSession session, Map<String, Serializable> properties) { if (properties.containsKey(INDEX_OPTION)) { return (String) properties.get(INDEX_OPTION); } ElasticSearchAdmin esa = Framework.getService(ElasticSearchAdmin.class); return esa.getWriteIndexName(esa.getIndexNameForRepository(session.getRepositoryName())); }
protected CoreSession getRepositorySession(String repoName) { if (repoName == null || repoName.isEmpty()) { RepositoryManager rm = Framework.getService(RepositoryManager.class); repoName = rm.getDefaultRepositoryName(); } if (documentManager != null && documentManager.getRepositoryName().equals(repoName)) { return documentManager; } dedicatedSession = CoreInstance.openCoreSession(repoName); return dedicatedSession; }
protected LockManager getLockManager(CoreSession session) { LockManagerService lms = Framework.getService(LockManagerService.class); return lms.getLockManager(session.getRepositoryName()); } }
@OperationMethod public Blob run() throws Exception { if (log.isDebugEnabled()) { log.debug("Starting transaction "); } String txId = TransactionalConversationManager.getInstance().start(this.session.getPrincipal(), this.session.getRepositoryName()); if (log.isDebugEnabled()) { log.debug("Transaction " + txId + " started"); } return new StringBlob(txId); }
@OperationMethod public void run() { checkAccess(); esi.reindexRepository(repo.getRepositoryName()); }
@OperationMethod public void run(String nxql) { checkAccess(); esi.runReindexingWorker(repo.getRepositoryName(), nxql); }
@OperationMethod public void run() { ImagingRecomputeWork work = new ImagingRecomputeWork(session.getRepositoryName(), query); Framework.getService(WorkManager.class).schedule(work); }
@OperationMethod public void run() { ThumbnailRecomputeWork work = new ThumbnailRecomputeWork(session.getRepositoryName(), query); Framework.getService(WorkManager.class).schedule(work); }
public String getDownloadUrl(DocumentModel doc, String xpath, String filename) { String url = null; DownloadService downloadService = Framework.getService(DownloadService.class); // Document creation mode if (doc.getRef() == null) { url = downloadService.getDownloadUrl(this.documentManager.getRepositoryName(), this.virtualChangeableDocId, xpath, filename); } else { url = downloadService.getDownloadUrl(doc, xpath, filename); } return url; }
protected static SQLQuery addSecurityPolicy(CoreSession session, SQLQuery query) { Collection<SQLQuery.Transformer> transformers = NXCore.getSecurityService() .getPoliciesQueryTransformers( session.getRepositoryName()); for (SQLQuery.Transformer trans : transformers) { query = trans.transform(session.getPrincipal(), query); } return query; }
protected void fireACEStatusUpdatedEvent(Map<DocumentRef, List<ACE>> refToACEs) { EventContext eventContext = new EventContextImpl(session, session.getPrincipal()); eventContext.setProperty(DOCUMENT_REFS, (Serializable) refToACEs); eventContext.setProperty(REPOSITORY_NAME, session.getRepositoryName()); Framework.getService(EventService.class).fireEvent(ACE_STATUS_UPDATED, eventContext); }
@Override public void scheduleExecution(EscalationRule rule, CoreSession session) { WorkManager manager = Framework.getService(WorkManager.class); manager.schedule( new EscalationRuleWork(rule.getId(), rule.getNode().getDocument().getId(), session.getRepositoryName()), WorkManager.Scheduling.IF_NOT_SCHEDULED); }
protected void trashDescendants(DocumentModel model, Boolean value) { CoreSession session = model.getCoreSession(); BulkService service = Framework.getService(BulkService.class); String nxql = String.format("SELECT * from Document where ecm:ancestorId='%s'", model.getId()); service.submit(new BulkCommand.Builder(ACTION_NAME, nxql).repository(session.getRepositoryName()) .user(session.getPrincipal().getName()) .param(PARAM_NAME, value) .build()); }
protected void notifyEvent(CoreSession session, String eventId, DocumentModel doc, boolean immediate) { DocumentEventContext ctx = new DocumentEventContext(session, session.getPrincipal(), doc); ctx.setProperties(new HashMap<>(doc.getContextData())); ctx.setCategory(DocumentEventCategories.EVENT_DOCUMENT_CATEGORY); ctx.setProperty(CoreEventConstants.REPOSITORY_NAME, session.getRepositoryName()); ctx.setProperty(CoreEventConstants.SESSION_ID, session.getSessionId()); Event event = ctx.newEvent(eventId); event.setInline(false); event.setImmediate(immediate); EventService eventService = Framework.getService(EventService.class); eventService.fireEvent(event); }