/** * Get a string representing the current version of the document. * * @return A string representing the current version of the document. */ public String getVersion() { return this.doc.getVersion(); }
public boolean isPlogNew(XWikiDocument plogdoc) { return plogdoc.getVersion().equals("1.1"); } }
/** * @param documentReference the Skin Extension's document reference * @param context the XWiki Context * @return the version of the document */ private String getDocumentVersion(DocumentReference documentReference, XWikiContext context) { try { return context.getWiki().getDocument(documentReference, context).getVersion(); } catch (XWikiException e) { LOGGER.error("Failed to load document [{}].", documentReference, e); } return ""; }
@Override public Boolean isLastDocumentVersion(String fullName, String version) throws XWikiGWTException { try { XWikiContext context = getXWikiContext(); return Boolean.valueOf(context.getWiki().getDocument(fullName, context).getVersion().equals(version)); } catch (Exception e) { throw getXWikiGWTException(e); } }
/** * @param document the document to serialize * @return the serialized version of the document */ protected Serializable serializeXWikiDocument(XWikiDocument document) { HashMap<String, Serializable> remoteDataMap = new HashMap<String, Serializable>(); remoteDataMap.put(DOC_NAME, document.getDocumentReference()); if (!document.isNew()) { remoteDataMap.put(DOC_VERSION, document.getVersion()); remoteDataMap.put(DOC_LANGUAGE, document.getLanguage()); } XWikiDocument originalDocument = document.getOriginalDocument(); if (originalDocument != null && !originalDocument.isNew()) { remoteDataMap.put(ORIGDOC_VERSION, originalDocument.getVersion()); remoteDataMap.put(ORIGDOC_LANGUAGE, originalDocument.getLanguage()); } return remoteDataMap; }
/** * @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; } }
private String getKey(String text, XWikiDocument contentdoc, XWikiDocument includingdoc, XWikiContext context) { String qs = ((context == null || context.getRequest() == null) ? "" : context.getRequest().getQueryString()); if (qs != null) { qs = qs.replaceAll("refresh=1&?", ""); qs = qs.replaceAll("&?refresh=1", ""); } String db = ((context == null) ? "xwiki" : context.getDatabase()); String cdoc = ((contentdoc == null) ? "" : contentdoc.getDatabase() + ":" + contentdoc.getFullName() + ":" + contentdoc.getRealLanguage() + ":" + contentdoc.getVersion()); String idoc = ((includingdoc == null) ? "" : includingdoc.getDatabase() + ":" + includingdoc.getFullName() + ":" + includingdoc.getRealLanguage() + ":" + includingdoc.getVersion()); String action = ((context == null) ? "view" : context.getAction()); String lang = ((context == null) ? "" : context.getLanguage()); lang += ((contentdoc == null) ? "" : ":" + contentdoc.getRealLanguage()); return db + "-" + cdoc + "-" + idoc + "-" + qs + "-" + action + "-" + lang + "-" + text.hashCode(); }
public AbstractDocumentData(String type, XWikiDocument doc, XWikiContext context, boolean deleted) { super(type, doc.getDocumentReference(), deleted); setVersion(doc.getVersion()); setDocumentTitle(doc.getRenderedTitle(Syntax.PLAIN_1_0, context)); setLanguage(doc.getLanguage()); }
public XWikiDocument getDocument(XWikiDocument doc, String revision, XWikiContext context) throws XWikiException { XWikiDocument newdoc; String database = context.getDatabase(); try { if (doc.getDocumentReference().getWikiReference().getName() != null) { context.setDatabase(doc.getDocumentReference().getWikiReference().getName()); } if ((revision == null) || revision.equals("")) { newdoc = new XWikiDocument(doc.getDocumentReference()); } else if (revision.equals(doc.getVersion())) { newdoc = doc; } else { newdoc = getVersioningStore().loadXWikiDoc(doc, revision, context); } } catch (XWikiException e) { if (revision.equals("1.1") || revision.equals("1.0")) { newdoc = new XWikiDocument(doc.getDocumentReference()); } else { throw e; } } finally { context.setDatabase(database); } return newdoc; }
if (!getVersion().equals(doc.getVersion())) { return false;
@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; }
rolledbackDoc.setAuthor(username); rolledbackDoc.setRCSVersion(tdoc.getRCSVersion()); rolledbackDoc.setVersion(tdoc.getVersion()); rolledbackDoc.setContentDirty(true); List<Object> params = new ArrayList<Object>();
localeParameters.put(WikiDocumentFilter.PARAMETER_LASTREVISION, document.getVersion());
documentFilter.beginWikiDocumentRevision(document.getVersion(), revisionParameters); documentFilter.endWikiDocumentRevision(document.getVersion(), revisionParameters);
plainContentPrinter.toString()); solrDocument.setField(FieldUtils.VERSION, translatedDocument.getVersion()); solrDocument.setField(FieldUtils.COMMENT, translatedDocument.getComment());
doc.setContentAuthor(xdoc.getContentAuthor()); doc.setCustomClass(xdoc.getCustomClass()); doc.setVersion(xdoc.getVersion()); doc.setContentUpdateDate(xdoc.getContentUpdateDate().getTime()); doc.setDate(xdoc.getDate().getTime());
/** * {@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); }
document.setVersion(document.getVersion());
el.addText(getVersion()); wr.write(el);