@Override public boolean equals(Object o) { if (o instanceof DocumentSkinReference) { DocumentSkinReference documentSkinReference = (DocumentSkinReference) o; return skinDocument.equals(documentSkinReference.skinDocument); } return false; }
@Override public boolean equals(Object o) { if (o instanceof DocumentColorThemeReference) { DocumentColorThemeReference documentSkinReference = (DocumentColorThemeReference) o; return colorThemeDocument.equals(documentSkinReference.colorThemeDocument); } return false; }
@Override public FilterPolicy filterEvent(Event event, DocumentReference user, Collection<NotificationFilterPreference> filterPreferences, NotificationFormat format) { return user != null && user.equals(event.getUser()) ? FilterPolicy.FILTER : FilterPolicy.NO_EFFECT; }
@Override public boolean equals(Object obj) { return obj instanceof PrimaryEntity && this.getDocumentReference().equals(((PrimaryEntity) obj).getDocumentReference()); }
@Override public boolean equals(Object obj) { if (!(obj instanceof PrimaryEntity)) { return false; } return this.getDocument().equals(((PrimaryEntity) obj).getDocument()); }
/** * {@inheritDoc} */ public boolean equals(Object obj) { boolean equals = false; if (obj instanceof TargetDocumentDescriptor) { TargetDocumentDescriptor other = (TargetDocumentDescriptor) obj; equals = other.getDocumentReference().equals(getDocumentReference()); } return equals; }
/** * @since 2.2M1 * @deprecated since 2.2.3 don't change the reference of a document once it's been constructed. Instead you can * clone the doc, rename it or copy it. */ @Deprecated public void setDocumentReference(DocumentReference reference) { // Don't allow setting a null reference for now, ie. don't do anything to preserve backward compatibility // with previous behavior (i.e. {@link #setFullName}. if (reference != null) { if (!reference.equals(getDocumentReference())) { this.documentReference = reference; setMetaDataDirty(true); // Clean the absolute parent reference cache to rebuild it next time getParentReference is called. this.parentReferenceCache = null; } } }
/** * @since 2.2M1 */ public void setTemplateDocumentReference(DocumentReference templateDocumentReference) { if ((templateDocumentReference == null && getTemplateDocumentReference() != null) || (templateDocumentReference != null && !templateDocumentReference.equals(getTemplateDocumentReference()))) { this.templateDocumentReference = templateDocumentReference; setMetaDataDirty(true); } }
@Override public void deleteMessage(String id) { Query q; try { q = this.qm.createQuery("where event.id = :id", Query.XWQL); q.bindValue("id", id); List<Event> events = this.stream.searchEvents(q); if (events == null || events.isEmpty()) { throw new IllegalArgumentException("This message does not exist"); } else if (events.get(0).getUser().equals(this.bridge.getCurrentUserReference())) { this.stream.deleteEvent(events.get(0)); } else { throw new IllegalArgumentException("You are not authorized to delete this message"); } } catch (QueryException ex) { LOG.warn("Failed to delete message: {}", ex.getMessage()); } }
/** * @param currentMacroBlock the current macro block being rendered * @return true if the chart macro takes its source in the current document or false otherwise */ protected boolean isDefinedChartSourceTheCurrentDocument(MacroBlock currentMacroBlock) { boolean result; if (this.documentReference == null) { result = true; } else { String sourceReference = extractSourceContentReference(currentMacroBlock); if (this.documentReferenceResolver.resolve(sourceReference, this.docBridge.getCurrentDocumentReference()).equals(this.documentReference)) { result = true; } else { result = false; } } return result; }
@Override public boolean matches(Object otherEvent) { if (otherEvent instanceof PatientEvent) { PatientEvent otherPatientEvent = (PatientEvent) otherEvent; if (!StringUtils.equals(otherPatientEvent.getEventType(), this.eventType)) { return false; } return this.patient == null || this.patient.getDocument() == null || (otherPatientEvent.getPatient() != null && this.patient.getDocument().equals( otherPatientEvent.getPatient().getDocument())); } return false; }
@Override public boolean matches(Object otherEvent) { if (otherEvent instanceof PatientEvent) { PatientEvent otherPatientEvent = (PatientEvent) otherEvent; if (!StringUtils.equals(otherPatientEvent.getEventType(), this.eventType)) { return false; } return this.patient == null || this.patient.getDocumentReference() == null || (otherPatientEvent.getPatient() != null && this.patient.getDocumentReference().equals( otherPatientEvent.getPatient().getDocumentReference())); } return false; }
@Override public List<DocumentReference> getSheets(DocumentModelBridge document, String action) { DocumentReference documentReference = document.getDocumentReference(); // (1) Check if there is a sheet specified for the current execution context. Apply it only if the given // document is the current document on the execution context. String sheetStringRef = getContextSheet(); if (sheetStringRef != null && documentReference.equals(documentAccessBridge.getCurrentDocumentReference())) { DocumentReference sheetReference = documentReferenceResolver.resolve(sheetStringRef, documentReference); if (matchSheet(sheetReference, action)) { return Collections.singletonList(sheetReference); } } // (2) Look for document sheets. List<DocumentReference> sheets = getDocumentSheets(document, action); if (sheets.isEmpty()) { // (3) Look for class sheets. sheets = new ArrayList<DocumentReference>(); for (DocumentReference classReference : modelBridge.getXObjectClassReferences(document)) { sheets.addAll(getClassSheets(classReference, action)); } } return sheets; }
/** * Join a wiki. * * @param userId userId to add to the wiki * @param wikiId id of the wiki * @return true if it succeed */ public boolean join(String userId, String wikiId) { // Check if the current user is userId XWikiContext context = xcontextProvider.get(); DocumentReference candidacyUser = documentReferenceResolver.resolve(userId); if (!context.getUserReference().equals(candidacyUser)) { setLastError(new WikiUserManagerException(String.format("User [%s] cannot call " + "$services.wiki.user.join() with an other userId.", context.getUserReference()))); return false; } try { wikiUserManager.join(userId, wikiId); } catch (WikiUserManagerException e) { setLastError(e); return false; } return true; }
/** * Note that this method cannot be removed for now since it's used by Hibernate for loading a XWikiDocument. * * @deprecated since 3.0M3 use {@link #setAuthorReference} instead */ @Deprecated public void setAuthor(String author) { // Note: Consider "" or null as the same, i.e. the author not being set DocumentReference authorReference = null; if (author != null && author.length() > 0) { authorReference = this.explicitReferenceDocumentReferenceResolver.resolve( this.xClassEntityReferenceResolver.resolve(author, EntityType.DOCUMENT), getDocumentReference()); } if ((getAuthorReference() == null && authorReference != null) || (getAuthorReference() != null && !getAuthorReference().equals(authorReference))) { setMetaDataDirty(true); } setAuthorReference(authorReference); }
private boolean canSeeCandidacy(MemberCandidacy candidacy) { XWikiContext context = xcontextProvider.get(); // Test if the user is concerned by the candidacy... DocumentReference candidacyUser = documentReferenceResolver.resolve(candidacy.getUserId()); if (context.getUserReference().equals(candidacyUser)) { // Hide the admin private comment candidacy.setAdminPrivateComment(null); return true; } // Otherwise the user must be an admin. return authorizationManager.hasAccess(Right.ADMIN, context.getUserReference(), new WikiReference(candidacy.getWikiId())); }
/** * Note that this method cannot be removed for now since it's used by Hibernate for loading a XWikiDocument. * * @deprecated since 3.0M3 use {@link #setContentAuthorReference} instead */ @Deprecated public void setContentAuthor(String contentAuthor) { // Note: Consider "" or null as the same, i.e. the content author not being set DocumentReference contentAuthorReference = null; if (contentAuthor != null && contentAuthor.length() > 0) { contentAuthorReference = this.explicitReferenceDocumentReferenceResolver.resolve( this.xClassEntityReferenceResolver.resolve(contentAuthor, EntityType.DOCUMENT), getDocumentReference()); } if ((getContentAuthorReference() == null && contentAuthorReference != null) || (getContentAuthorReference() != null && !getContentAuthorReference().equals(contentAuthorReference))) { setMetaDataDirty(true); } setContentAuthorReference(contentAuthorReference); }
/** * Note that this method cannot be removed for now since it's used by Hibernate for loading a XWikiDocument. * * @deprecated since 3.0M2 use {@link #setCreatorReference} instead */ @Deprecated public void setCreator(String creator) { // Note: Consider "" or null as the same, i.e. the creator not being set DocumentReference creatorReference = null; if (creator != null && creator.length() > 0) { creatorReference = this.explicitReferenceDocumentReferenceResolver.resolve( this.xClassEntityReferenceResolver.resolve(creator, EntityType.DOCUMENT), getDocumentReference()); } if ((getCreatorReference() == null && creatorReference != null) || (getCreatorReference() != null && !getCreatorReference().equals(creatorReference))) { setMetaDataDirty(true); } setCreatorReference(creatorReference); }
/** * Compute the similarity between two events. * * @param event1 first event to compare * @param event2 second event to compare * * @return an integer representing the similarity between the two events */ public int computeSimilarity(Event event1, Event event2) { if (event1.getDocument() != null && event1.getDocument().equals(event2.getDocument())) { if (event1.getType() != null && event1.getType().equals(event2.getType())) { return SAME_DOCUMENT_AND_TYPE; } else if (event1.getGroupId() != null && event1.getGroupId().equals(event2.getGroupId())) { return SAME_GROUP_ID_AND_DOCUMENT_BUT_DIFFERENT_TYPES; } } else if (event1.getDocument() == null && event1.getType() != null && event1.getType().equals(event2.getType())) { return SAME_TYPE_BUT_NO_DOCUMENT; } return NO_SIMILARITY; } }
/** * @since 2.2M1 */ private void refactorDocumentLinks(DocumentReference oldDocumentReference, DocumentReference newDocumentReference, XWikiContext context) throws XWikiException { XDOM xdom = getXDOM(); List<LinkBlock> linkBlockList = xdom.getChildrenByType(LinkBlock.class, true); for (LinkBlock linkBlock : linkBlockList) { ResourceReference linkReference = linkBlock.getReference(); if (linkReference.getType().equals(ResourceType.DOCUMENT)) { DocumentReference documentReference = this.explicitDocumentReferenceResolver.resolve( linkReference.getReference(), getDocumentReference()); if (documentReference.equals(oldDocumentReference)) { linkReference.setReference(this.compactEntityReferenceSerializer.serialize(newDocumentReference, getDocumentReference())); } } } setContent(xdom); }