/** * Special constructor that transforms a generic entity reference into a {@link DocumentReference}. It checks the * validity of the passed reference (ie correct type and correct parent). * * @exception IllegalArgumentException if the passed reference is not a valid document reference */ public DocumentReference(EntityReference reference) { super(reference.getName(), reference.getType(), reference.getParent()); }
/** * Creates any {@link EntityReference} from a string. * * @param name the entity reference name (eg "page") * @param type the entity type (eg "wiki", "space", "document", etc) * @return the created reference * @since 5.0M1 */ public EntityReference createEntityReference(String name, EntityType type) { return new EntityReference(name, type); }
/** * Extract wiki name from provided entity reference. * * @param entityReference the entity reference * @return the wiki name, null if no wiki name can be found. */ private String extractWikiName(EntityReference entityReference) { String wikiName = null; if (entityReference != null) { EntityReference wikiReference = entityReference.extractReference(EntityType.WIKI); if (wikiReference != null) { wikiName = wikiReference.getName(); } } return wikiName; } }
@Override public void endWikiObject(String name, FilterEventParameters parameters) throws WikiStreamException { if (this.currentEntityReference.getType() == EntityType.OBJECT) { this.currentEntityReference = this.currentEntityReference.getParent(); } this.currentXObject = null; this.currentXObjectClass = null; }
/** * Special constructor that transforms a generic entity reference into a {@link WikiReference}. It checks the * validity of the passed reference (ie correct type). * * @exception IllegalArgumentException if the passed reference is not a valid wiki reference */ public WikiReference(EntityReference reference) { super(reference.getName(), reference.getType()); }
private List<String> extractListFromReference(EntityReference reference) { List<String> path = new ArrayList<>(); // Add the spaces EntityReference spaceReference = reference.extractReference(EntityType.SPACE); EntityReference wikiReference = reference.extractReference(EntityType.WIKI); for (EntityReference singleReference : spaceReference.removeParent(wikiReference).getReversedReferenceChain()) { path.add(singleReference.getName()); } if (reference.getType() == EntityType.DOCUMENT) { path.add(reference.getName()); } return path; }
/** * {@inheritDoc} * * @see java.lang.Object#equals(Object) */ @Override public boolean equals(Object obj) { boolean equals = false; if (obj == this) { equals = true; } else if (obj instanceof EntityReference) { EntityReference entityReference = (EntityReference) obj; equals = (entityReference.getName() == null ? getName() == null : entityReference.getName().equals(getName())) && (entityReference.getParent() == null ? getParent() == null : entityReference.getParent().equals( getParent())) && (entityReference.getType() == null ? getType() == null : entityReference.getType().equals( getType())); } return equals; }
@Override public String getUsername() { if (this.user == null) { return null; } return this.user.getName(); }
private void sendEndWikiSpace(XARInputFilter proxyFilter, boolean force) throws FilterException { List<EntityReference> sentSpaces = this.sentSpaceReference.getReversedReferenceChain(); List<EntityReference> currentSpaces = this.currentSpaceReference.getReversedReferenceChain(); // Find the first different level int i = 0; while (i < sentSpaces.size() && i < currentSpaces.size()) { if (!currentSpaces.get(i).equals(sentSpaces.get(i))) { break; } ++i; } if (i < sentSpaces.size()) { // Delete what is different for (int diff = sentSpaces.size() - i; diff > 0; --diff, this.sentSpaceReference = this.sentSpaceReference.getParent()) { proxyFilter.endWikiSpace(this.sentSpaceReference.getName(), FilterEventParameters.EMPTY); } } }
private EntityReference toDOCUMENT(EntityReference referenceToConvert, EntityReference convertedParent) { return new EntityReference(getDefaultDocumentName(), EntityType.DOCUMENT, new EntityReference(referenceToConvert.getName(), EntityType.SPACE, convertedParent), referenceToConvert.getParameters()); }
private void add(EntityReference reference, EntityReferenceEntry entry) { EntityReferenceEntry currentEntry = entry; for (EntityReference element : reference.getReversedReferenceChain()) { // Move the first element to the right level in the tree if (currentEntry == entry) { while (currentEntry.children != null && currentEntry.getClosestChildren(element.getType()) == null) { currentEntry = currentEntry.add(); } } currentEntry = currentEntry.add(element.getType(), element.getName(), element.getParameters()); } }
/** * Creates a request to rename the specified entity. * * @param reference the entity to rename * @param newName the new entity name * @return the rename request */ public MoveRequest createRenameRequest(EntityReference reference, String newName) { return createRenameRequest(reference, new EntityReference(newName, reference.getType(), reference.getParent())); }
public LocationPicker add(String value) { EntityReference spaceReference = getUtil().resolveSpaceReference(value); EntityReference wikiReference = spaceReference.extractReference(EntityType.WIKI); if (wikiReference != null) { spaceReference = spaceReference.removeParent(wikiReference); } EntityReference documentReference = new EntityReference("WebHome", EntityType.DOCUMENT, spaceReference); String[] path = documentReference.getReversedReferenceChain().stream().map(EntityReference::getName).toArray(String[]::new); browse().selectDocument(path); return waitToDisplayValue(value); }
/** * Extract the first entity of the given type from this one by traversing the current entity to the root. * * @param type the type of the entity to be extracted * @return the first entity of the given type in the current entity when traversing to the root or null if no entity * of the passed type exist * @since 7.4M1 */ public EntityReference extractFirstReference(EntityType type) { EntityReference reference = extractReference(type); while (reference != null && reference.getParent() != null && reference.getParent().getType().equals(type)) { reference = reference.getParent(); } return reference; }
private boolean canSendBeginWikiSpace(boolean force) { return (this.sentSpaceReference == null || !this.sentSpaceReference.equals(this.currentSpaceReference)) && (force || this.properties.getEntities() == null); }
/** * Helper method to parse the target as a reference and extract a serialized document reference from it: the * document reference serialized if the target can be parsed as a typed reference, or the initial string itself * otherwise. * * @param target the serialized reference to target to extract the document reference from * @return the serialized reference to the document to which the target refers */ private EntityReference getDocumentReference(String target) { EntityReference ref = this.referenceResolver.resolve(target, EntityType.DOCUMENT); return ref.extractReference(EntityType.DOCUMENT); }
/** * Compared the two reference between the first (including) <code>from</code> type of entity and the last * (including) <code>to</code> type of entity. * * @param otherReference the reference to compare * @param from the type of the first (including) entity reference to compare * @param to the type of the the last (including) entity reference to compare * @return true if the two references are equals between the passes entity types references * @since 7.2M1 */ public boolean equals(EntityReference otherReference, EntityType from, EntityType to) { if (otherReference == this) { return true; } if (otherReference == null) { return false; } EntityReference currentReference1 = from != null ? this.extractReference(from) : this; EntityReference currentReference2 = from != null ? otherReference.extractReference(from) : otherReference; return currentReference1.equals(currentReference2, to); }
/** * @since 9.0RC1 */ public Class<?> getResourceAPI(EntityReference reference) throws Exception { ResourceAPI resource = RESOURCES_MAP.get(reference.getType()); if (resource == null) { throw new Exception("Unsuported type [" + reference.getType() + "]"); } return getLocale(reference) != null ? resource.localeAPI : resource.api; }
@Override public void endWiki(String name, FilterEventParameters parameters) throws WikiStreamException { this.currentWiki = null; this.currentReference = this.currentReference.getParent(); }