@Override public void beginWikiDocument(String name, FilterEventParameters parameters) throws FilterException { this.currentDocument = name; this.currentDocumentParameters = parameters; this.currentDocumentReference = new LocalDocumentReference(this.currentDocument, this.currentSpaceReference); }
@Override public LocalDocumentReference replaceParent(EntityReference newParent) { if (newParent == getParent()) { return this; } return new LocalDocumentReference(this, newParent); }
this.wikiWriter.newEntry(new LocalDocumentReference(this.currentDocumentReference, locale)), this.properties.getEncoding(), this.properties.isFormat(), true); if (this.currentDocumentReference.getParent().getParent() == null) { this.currentDocumentReference.getParent().getName()); } else { defaultSerializer.serialize(this.currentDocumentReference.getParent())); this.writer.writeElement(XarDocumentModel.ELEMENT_NAME, this.currentDocumentReference.getName());
public OutputStream newEntry(LocalDocumentReference reference) throws FilterException { StringBuilder path = new StringBuilder(); // Add space path addSpacePath(path, reference.getParent()); // Add document name path.append(escapeXARPath(reference.getName())); // Add language if (reference.getLocale() != null && !reference.getLocale().equals(Locale.ROOT)) { path.append('.'); path.append(reference.getLocale()); } // Add extension path.append(".xml"); String entryName = path.toString(); ZipArchiveEntry zipentry = new ZipArchiveEntry(entryName); try { this.zipStream.putArchiveEntry(zipentry); } catch (IOException e) { throw new FilterException("Failed to add a new zip entry for [" + path + "]", e); } this.xarPackage.addEntry(reference, entryName); return this.zipStream; }
private Locale getLocale(EntityReference reference) { if (reference instanceof DocumentReference) { return ((DocumentReference) reference).getLocale(); } else if (reference instanceof LocalDocumentReference) { return ((LocalDocumentReference) reference).getLocale(); } return null; }
@Override protected DocumentReference getDocumentReference() { return new DocumentReference(CLASS_REFERENCE.getName(), new SpaceReference(CLASS_SPACE_NAME, getCurrentWikiReference())); }
@Override public FilterPolicy filterEvent(Event event, DocumentReference user, Collection<NotificationFilterPreference> filterPreferences, NotificationFormat format) { return event.getUser().getLocalDocumentReference().equals(SYSTEM_USER) ? FilterPolicy.FILTER : FilterPolicy.NO_EFFECT; }
@Override protected void serializeEntityReference(EntityReference currentReference, StringBuilder representation, boolean isLastReference, Object... parameters) { super.serializeEntityReference(currentReference, representation, isLastReference, parameters); // Append parameters for DocumentReference (if any) if (currentReference instanceof DocumentReference) { DocumentReference documentReference = (DocumentReference) currentReference; if (documentReference.getLocale() != null) { representation.append('(').append(documentReference.getLocale()).append(')'); } } else if (currentReference instanceof LocalDocumentReference) { LocalDocumentReference documentReference = (LocalDocumentReference) currentReference; if (documentReference.getLocale() != null) { representation.append('(').append(documentReference.getLocale()).append(')'); } } } }
@Override protected DocumentReference getDocumentReference() { return new DocumentReference(CLASS_REFERENCE.getName(), new SpaceReference(CLASS_SPACE_NAME, getCurrentWikiReference())); } }
/** * Describe {@code deliverUpdateEvent} method here. * * @param ref Reference to the document that should be invalidated. */ private void deliverUpdateEvent(DocumentReference ref) { if (XWikiConstants.WIKI_DOC_REFERENCE.equals(ref, EntityType.SPACE)) { // For XWiki.XWikiPreferences, remove the whole wiki. securityCache.remove(securityReferenceFactory.newEntityReference(ref.getWikiReference())); } else if (ref.getName().equals(XWikiConstants.SPACE_DOC)) { // For WebPreferences, remove the whole space. securityCache.remove(securityReferenceFactory.newEntityReference(ref.getParent())); } else { // For any other documents, remove that document cache. securityCache.remove(securityReferenceFactory.newEntityReference(ref)); // If it's a wiki descriptor remove the wiki reference from the cache if (ref.getName().startsWith(XWikiConstants.WIKI_DESCRIPTOR_PREFIX) && XWikiConstants.XWIKI_SPACE_REFERENCE.equals(ref.getLastSpaceReference(), EntityType.SPACE) && ref.getWikiReference().getName().equals(this.xcontextProvider.get().getMainXWiki())) { // For xwiki:XWiki.XWikiServer... documents, also remove the whole corresponding wiki. securityCache.remove(securityReferenceFactory.newEntityReference(new WikiReference( ref.getName().substring(XWikiConstants.WIKI_DESCRIPTOR_PREFIX.length()).toLowerCase()))); } } } }
/** * Default constructor. */ public WikiMacroClassDocumentInitializer() { super(new LocalDocumentReference(WIKI_MACRO_CLASS_SPACE, WIKI_MACRO_CLASS_PAGE)); }
/** * Default constructor. */ public XWikiServerXwikiDocumentInitializer() { super(new LocalDocumentReference(XWiki.SYSTEM_SPACE, DOCUMENT_NAME)); }
/** * @return the {@link LocalDocumentReference} corresponding to this {@link DocumentReference} * @since 9.3RC1 * @since 8.4.5 */ public LocalDocumentReference getLocalDocumentReference() { if (this.localDocumentReference == null) { this.localDocumentReference = new LocalDocumentReference(this); } return this.localDocumentReference; }
/** * @param reference Reference to the main page of the wiki */ public void setMainPageReference(DocumentReference reference) { this.mainPageReference = new LocalDocumentReference(reference); }
/** * Default constructor. */ public WikiMacroParameterClassDocumentInitializer() { super(new LocalDocumentReference(WIKI_MACRO_PARAMETER_CLASS_SPACE, WIKI_MACRO_PARAMETER_CLASS_PAGE)); }
/** * Default constructor. */ public HourlyWatchListJobDocumentInitializer() { super(new LocalDocumentReference(SCHEDULER_SPACE, DOCUMENT_NAME)); }
/** * Default constructor. */ public WikiNotificationFilterDisplayerDocumentInitializer() { super(new LocalDocumentReference(PARENT_PATH, "NotificationFilterDisplayerClass")); }
/** * Default constructor. */ public ToggleableFilterPreferenceDocumentInitializer() { super(new LocalDocumentReference(PARENT_PATH, "ToggleableFilterPreferenceClass")); }
/** * Default constructor. */ public DailyWatchListJobDocumentInitializer() { super(new LocalDocumentReference(SCHEDULER_SPACE, DOCUMENT_NAME)); }
/** * Default constructor. */ public WeeklyWatchListJobDocumentInitializer() { super(new LocalDocumentReference(SCHEDULER_SPACE, DOCUMENT_NAME)); }