/** * Get the date when the current document version has been created, i.e. the date of the last modification of the * document. * * @return The date where the current document version has been created. */ public Date getDate() { return this.doc.getDate(); }
@Override public long getLastModifiedDate() { return this.document.getDate().getTime(); }
/** * {@inheritDoc} * * @see com.xpn.xwiki.doc.XWikiDocument#getDate() */ @Override public Date getDate() { return getDocument().getDate(); }
private synchronized void updateSystemConsentCache(XWikiDocument configDoc) { try { Set<Consent> consents = new LinkedHashSet<>(); List<BaseObject> consentObjects = configDoc.getXObjects(this.consentReference); if (consentObjects != null) { for (BaseObject consentObject : consentObjects) { Consent nextConsent = fromXWikiConsentConfiguration(consentObject, configDoc); if (nextConsent != null) { consents.add(nextConsent); } } } this.cachedSystemConsents = Collections.unmodifiableSet(consents); this.lastSystemConsentLoadTime = configDoc.getDate(); } catch (Exception ex) { this.logger.error("Could not load system consents from preferences document: {}", ex.getMessage()); } }
private synchronized void updateSystemConsentCache(XWikiDocument configDoc) { try { Set<Consent> consents = new LinkedHashSet<>(); List<BaseObject> consentObjects = configDoc.getXObjects(this.consentReference); if (consentObjects != null) { for (BaseObject consentObject : consentObjects) { Consent nextConsent = fromXWikiConsentConfiguration(consentObject, configDoc); if (nextConsent != null) { consents.add(nextConsent); } } } this.cachedSystemConsents = Collections.unmodifiableSet(consents); this.lastSystemConsentLoadTime = configDoc.getDate(); } catch (Exception ex) { this.logger.error("Could not load system consents from preferences document: {}", ex.getMessage()); } }
private synchronized void updateSystemConsentCache(XWikiDocument configDoc) { try { Set<Consent> consents = new LinkedHashSet<>(); List<BaseObject> consentObjects = configDoc.getXObjects(this.consentReference); if (consentObjects != null) { for (BaseObject consentObject : consentObjects) { Consent nextConsent = fromXWikiConsentConfiguration(consentObject, configDoc); if (nextConsent != null) { consents.add(nextConsent); } } } this.cachedSystemConsents = Collections.unmodifiableSet(consents); this.lastSystemConsentLoadTime = configDoc.getDate(); } catch (Exception ex) { this.logger.error("Could not load system consents from preferences document: {}", ex.getMessage()); } }
@Override public Set<Consent> getSystemConsents() { try { DocumentReference configDocRef = this.referenceResolver.resolve(this.configurationPageReference); XWikiDocument configDoc = (XWikiDocument) this.bridge.getDocument(configDocRef); if (this.lastSystemConsentLoadTime == null || configDoc.getDate().after(this.lastSystemConsentLoadTime)) { updateSystemConsentCache(configDoc); } } catch (Exception ex) { this.logger.error("Could not load preferences document: {}", ex.getMessage()); } return this.cachedSystemConsents; }
@Override public Set<Consent> getSystemConsents() { try { DocumentReference configDocRef = this.referenceResolver.resolve(this.configurationPageReference); XWikiDocument configDoc = (XWikiDocument) this.bridge.getDocument(configDocRef); if (this.lastSystemConsentLoadTime == null || configDoc.getDate().after(this.lastSystemConsentLoadTime)) { updateSystemConsentCache(configDoc); } } catch (Exception ex) { this.logger.error("Could not load preferences document: {}", ex.getMessage()); } return this.cachedSystemConsents; }
@Override public Set<Consent> getSystemConsents() { try { DocumentReference configDocRef = this.referenceResolver.resolve(this.configurationPageReference); XWikiDocument configDoc = (XWikiDocument) this.bridge.getDocument(configDocRef); if (this.lastSystemConsentLoadTime == null || configDoc.getDate().after(this.lastSystemConsentLoadTime)) { updateSystemConsentCache(configDoc); } } catch (Exception ex) { this.logger.error("Could not load preferences document: {}", ex.getMessage()); } return this.cachedSystemConsents; }
@Override public PatientData<String> load(Patient patient) { try { XWikiDocument doc = patient.getXDocument(); Map<String, String> result = new LinkedHashMap<>(); DateTimeFormatter dateFormatter = ISODateTimeFormat.dateTime().withZone(DateTimeZone.UTC); result.put(DOCUMENT_NAME, doc.getDocumentReference().getName()); result.put(CREATION_DATE, dateFormatter.print(new DateTime(doc.getCreationDate()))); result.put(AUTHOR, (doc.getAuthorReference() != null) ? doc.getAuthorReference().getName() : UNKNOWN_USER); result.put(DATE, dateFormatter.print(new DateTime(doc.getDate()))); return new DictionaryPatientData<>(getName(), result); } catch (Exception e) { this.logger.error(ERROR_MESSAGE_LOAD_FAILED, e.getMessage()); } return null; }
@Override public PatientData<String> load(Patient patient) { try { XWikiDocument doc = (XWikiDocument) this.documentAccessBridge.getDocument(patient.getDocument()); Map<String, String> result = new LinkedHashMap<>(); DateTimeFormatter dateFormatter = ISODateTimeFormat.dateTime().withZone(DateTimeZone.UTC); result.put(DOCUMENT_NAME, doc.getDocumentReference().getName()); result.put(CREATION_DATE, dateFormatter.print(new DateTime(doc.getCreationDate()))); result.put(AUTHOR, (doc.getAuthorReference() != null) ? doc.getAuthorReference().getName() : UNKNOWN_USER); result.put(DATE, dateFormatter.print(new DateTime(doc.getDate()))); return new DictionaryPatientData<>(getName(), result); } catch (Exception e) { this.logger.error("Could not find requested document or some unforeseen" + " error has occurred during controller loading ", e.getMessage()); } return null; }
Date docDate = docBundle.getDate();
setupHeaders(response, mimetype, doc.getDate(), data.length); response.getOutputStream().write(data); return true;
public DocumentData(final XWikiDocument doc, final XWikiContext context, final boolean deleted) { super(LucenePlugin.DOCTYPE_WIKIPAGE, doc, context, deleted); setAuthor(doc.getAuthor()); setCreator(doc.getCreator()); setModificationDate(doc.getDate()); setCreationDate(doc.getCreationDate()); }
public long findDeletedAttachmentForDocRevision(XWikiDocument doc, String docRevision, String filename, XWikiContext context) throws XWikiException { XWikiAttachment attachment = null; XWikiDocument rdoc = context.getWiki().getDocument(doc, docRevision, context); if (context.getWiki().hasAttachmentRecycleBin(context) && filename != null) { attachment = rdoc.getAttachment(filename); if (attachment != null) { List<DeletedAttachment> deleted = context.getWiki().getAttachmentRecycleBinStore() .getAllDeletedAttachments(attachment, context, true); Collections.reverse(deleted); for (DeletedAttachment entry : deleted) { if (entry.getDate().after(rdoc.getDate())) { return entry.getId(); } } } } return -1; } }
/** * @param event the current event * @param currentDoc the affected document * @param context the context of the event * @return the {@link WatchListEvent} to use to notify watchers of the current document */ private WatchListEvent getWatchListEvent(Event event, XWikiDocument currentDoc, XWikiContext context) { String type = null; DocumentReference documentReference = currentDoc.getDocumentReference(); DocumentReference userReference = context.getUserReference(); String version = currentDoc.getVersion(); Date date = currentDoc.getDate(); if (event instanceof DocumentCreatedEvent) { type = WatchListEventType.CREATE; } else if (event instanceof DocumentUpdatedEvent) { type = WatchListEventType.UPDATE; } else if (event instanceof DocumentDeletedEvent) { version = currentDoc.getOriginalDocument().getVersion(); type = WatchListEventType.DELETE; } WatchListEvent watchListEvent = new WatchListEvent(documentReference, type, userReference, version, date); return watchListEvent; } }
public List getLastModifications(XWikiContext context) throws XWikiException { String key = this.doc.getSpace() + "-lastmodifications"; ArrayList<Modification> list = null; this.plugin.getProjectManager().initProjectsCache(context); XWikiCache projectCache = this.plugin.getProjectManager().getProjectsCache(); synchronized (key) { try { list = (ArrayList<Modification>) projectCache.getFromCache(key); } catch (XWikiCacheNeedsRefreshException e) { projectCache.cancelUpdate(key); list = new ArrayList<Modification>(); String hql = " where doc.web='" + doc.getSpace() + "' and doc.name != 'WebPreferences'" + "order by doc.date desc"; List docList = context.getWiki().getStore().searchDocumentsNames(hql, context); for (Iterator i = docList.iterator(); i.hasNext();) { String modName = (String) i.next(); XWikiDocument modDoc = context.getWiki().getDocument(modName, context); Date date = modDoc.getDate(); list.add(new Modification(modDoc.getFullName(), modDoc.getDisplayTitle(context), modDoc.getComment(), date, this.doc.display("name", "view"))); } projectCache.putInCache(key, list); } } return list; }
@Override public PatientSummary createPatientSummary(Patient patient, UriInfo uriInfo) { if (patient == null) { return null; } User currentUser = this.users.getCurrentUser(); if (!this.access.hasAccess(currentUser, Right.VIEW, patient.getDocumentReference())) { return null; } PatientSummary result = new PatientSummary(); XWikiDocument doc = patient.getXDocument(); result.withId(patient.getId()).withEid(patient.getExternalId()); result.withCreatedBy(String.valueOf(patient.getReporter())).withLastModifiedBy( String.valueOf(doc.getAuthorReference())); result.withVersion(doc.getVersion()); result.withCreatedOn(new DateTime(doc.getCreationDate()).withZone(DateTimeZone.UTC)); result.withLastModifiedOn(new DateTime(doc.getDate()).withZone(DateTimeZone.UTC)); result.withLinks(this.autolinker.get().forSecondaryResource(PatientResource.class, uriInfo) .withExtraParameters("entity-id", patient.getId()) .withExtraParameters("entity-type", "patients") .build()); return result; }
/** * {@inheritDoc} */ public void updateXWikiDocArchive(XWikiDocument doc, boolean bTransaction, XWikiContext context) throws XWikiException { try { XWikiDocumentArchive archiveDoc = getXWikiDocumentArchive(doc, context); archiveDoc.updateArchive(doc, doc.getAuthor(), doc.getDate(), doc.getComment(), doc.getRCSVersion(), context); doc.setRCSVersion(archiveDoc.getLatestVersion()); saveXWikiDocArchive(archiveDoc, bTransaction, context); } catch (Exception e) { Object[] args = {doc.getFullName()}; throw new XWikiException(XWikiException.MODULE_XWIKI_STORE, XWikiException.ERROR_XWIKI_STORE_HIBERNATE_SAVING_OBJECT, "Exception while updating archive {0}", e, args); } }
/** * {@inheritDoc} */ public void addDocumentActivityEvent(String streamName, XWikiDocument doc, String type, int priority, String title, List<String> params, XWikiContext context) throws ActivityStreamException { ActivityEvent event = newActivityEvent(); event.setStream(streamName); event.setPage(doc.getFullName()); if (doc.getDatabase() != null) { event.setWiki(doc.getDatabase()); } event.setDate(doc.getDate()); event.setPriority(priority); event.setType(type); event.setTitle(title); event.setBody(title); event.setVersion(doc.getVersion()); event.setParams(params); // This might be wrong once non-altering events will be logged. event.setUser(doc.getAuthor()); addActivityEvent(event, doc, context); }