@Override public DocumentReference getReporter() { return this.getXDocument().getCreatorReference(); }
/** * Returns the owner of the patient. * * @param patientDoc patient XDocument * @return owner as string */ public String getOwner(XWikiDocument patientDoc) { String owner = getPropertyValue(patientDoc, Owner.CLASS_REFERENCE, Owner.PROPERTY_NAME, ""); if (StringUtils.isNotBlank(owner)) { return owner; } if (patientDoc.getCreatorReference() != null) { return this.serializer.serialize(patientDoc.getCreatorReference()); } return owner; }
/** * Returns the owner of the patient. * * @param patientDoc patient XDocument * @return owner as string */ public String getOwner(XWikiDocument patientDoc) { String owner = getPropertyValue(patientDoc, Owner.CLASS_REFERENCE, Owner.PROPERTY_NAME, ""); if (StringUtils.isNotBlank(owner)) { return owner; } if (patientDoc.getCreatorReference() != null) { return this.serializer.serialize(patientDoc.getCreatorReference()); } return owner; }
/** * Note that this method cannot be removed for now since it's used by Hibernate for saving a XWikiDocument. * * @deprecated since 3.0M2 use {@link #getCreatorReference()} instead */ @Deprecated public String getCreator() { String creator; DocumentReference creatorReference = getCreatorReference(); if (creatorReference == null) { creator = ""; } else { creator = this.compactWikiEntityReferenceSerializer.serialize(creatorReference, getDocumentReference()); } return creator; }
/** * Constructor that copies the data from an XDocument. * * @param doc the XDocument representing this patient in XWiki */ public PhenoTipsPatient(XWikiDocument doc) { super(doc); this.reporter = doc.getCreatorReference(); BaseObject data = doc.getXObject(CLASS_REFERENCE); if (data == null) { return; } loadSerializers(); }
/** * 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); }
DocumentReference creator = document.getCreatorReference();
@Override public void onEvent(Event event, Object source, Object data) { XWikiDocument doc = (XWikiDocument) source; XWikiContext context = (XWikiContext) this.execution.getContext().getProperty("xwikicontext"); try { if (doc.getXObject(Owner.CLASS_REFERENCE) != null) { return; } BaseObject ownerObject = doc.newXObject(Owner.CLASS_REFERENCE, context); if (doc.getCreatorReference() != null) { ownerObject.setStringValue("owner", doc.getCreatorReference().toString()); } else { ownerObject.setStringValue("owner", ""); } } catch (XWikiException ex) { this.logger.error("Failed to set the initial owner for patient [{}]: {}", doc.getDocumentReference(), ex.getMessage(), ex); } } }
@Override public void onEvent(Event event, Object source, Object data) { XWikiDocument doc = (XWikiDocument) source; XWikiContext context = (XWikiContext) this.execution.getContext().getProperty("xwikicontext"); try { if (doc.getXObject(Owner.CLASS_REFERENCE) != null) { return; } BaseObject ownerObject = doc.newXObject(Owner.CLASS_REFERENCE, context); if (doc.getCreatorReference() != null) { ownerObject.setStringValue(OWNER, doc.getCreatorReference().toString()); } else { ownerObject.setStringValue(OWNER, ""); } } catch (XWikiException ex) { this.logger.error("Failed to set the initial owner for entity [{}]: {}", doc.getDocumentReference(), ex.getMessage(), ex); } } }
private boolean setWikiMacroClassesDocumentFields(XWikiDocument doc, String title) { boolean needsUpdate = false; if (StringUtils.isBlank(doc.getCreator())) { needsUpdate = true; doc.setCreator(XWikiRightService.SUPERADMIN_USER); } if (StringUtils.isBlank(doc.getAuthor())) { needsUpdate = true; doc.setAuthorReference(doc.getCreatorReference()); } if (StringUtils.isBlank(doc.getParent())) { needsUpdate = true; doc.setParent("XWiki.XWikiClasses"); } if (StringUtils.isBlank(doc.getTitle())) { needsUpdate = true; doc.setTitle(title); } if (StringUtils.isBlank(doc.getContent()) || !Syntax.XWIKI_2_0.equals(doc.getSyntax())) { needsUpdate = true; doc.setContent("{{include document=\"XWiki.ClassSheet\" /}}"); doc.setSyntax(Syntax.XWIKI_2_0); } return needsUpdate; }
/** * @param solrDocument the Solr document * @param translatedDocument the XWiki document * @param entityReference the document reference */ private void setAuthors(SolrInputDocument solrDocument, XWikiDocument translatedDocument, EntityReference entityReference) { XWikiContext xcontext = this.xcontextProvider.get(); String authorString = entityReferenceSerializer.serialize(translatedDocument.getAuthorReference()); solrDocument.setField(FieldUtils.AUTHOR, authorString); String authorDisplayString = xcontext.getWiki().getPlainUserName(translatedDocument.getAuthorReference(), xcontext); solrDocument.setField(FieldUtils.AUTHOR_DISPLAY, authorDisplayString); String creatorString = entityReferenceSerializer.serialize(translatedDocument.getCreatorReference()); solrDocument.setField(FieldUtils.CREATOR, creatorString); String creatorDisplayString = xcontext.getWiki().getPlainUserName(translatedDocument.getCreatorReference(), xcontext); solrDocument.setField(FieldUtils.CREATOR_DISPLAY, creatorDisplayString); }
Integer x = 0; if (present.contains("referrer")) { String creator = getUsername(patientDoc.getCreatorReference()); DataCell cell = new DataCell(creator, x, 0); bodySection.addCell(cell);
public LDAPProfileXClass(XWikiContext context) throws XWikiException { this.context = context; XWikiDocument ldapClassDoc = context.getWiki().getDocument(LDAPPROFILECLASS_REFERENCE, context); this.ldapClass = ldapClassDoc.getXClass(); boolean needsUpdate = this.ldapClass.addTextField(LDAP_XFIELD_DN, LDAP_XFIELDPN_DN, 80); needsUpdate |= this.ldapClass.addTextField(LDAP_XFIELD_UID, LDAP_XFIELDPN_UID, 80); if (ldapClassDoc.getCreatorReference() == null) { needsUpdate = true; ldapClassDoc.setCreator(XWikiRightService.SUPERADMIN_USER); } if (ldapClassDoc.getAuthorReference() == null) { needsUpdate = true; ldapClassDoc.setAuthorReference(ldapClassDoc.getCreatorReference()); } if (!ldapClassDoc.isHidden()) { needsUpdate = true; ldapClassDoc.setHidden(true); } if (needsUpdate) { context.getWiki().saveDocument(ldapClassDoc, "Update LDAP user profile class", context); } }
private void saveGroupDocument(XWikiDocument document, String message) throws WikiUserManagerException { // Get the XWiki objects XWikiContext xcontext = xcontextProvider.get(); XWiki xwiki = xcontext.getWiki(); // The document should be hidden document.setHidden(true); // The document must have a creator if (document.getCreatorReference() == null) { document.setCreatorReference(xcontext.getUserReference()); } // The document must have an author if (document.getAuthorReference() == null) { document.setAuthorReference(xcontext.getUserReference()); } // Save the document try { xwiki.saveDocument(document, message, xcontext); } catch (XWikiException e) { throw new WikiUserManagerException("Fail to save the member group", e); } }
@Override public void save(WikiPropertyGroup group, String wikiId) throws WikiPropertyGroupException { XWikiContext context = xcontextProvider.get(); XWiki xwiki = context.getWiki(); WikiTemplatePropertyGroup templateGroup = (WikiTemplatePropertyGroup) group; try { XWikiDocument descriptorDocument = wikiDescriptorDocumentHelper.getDocumentFromWikiId(wikiId); BaseObject object = descriptorDocument.getXObject(WikiTemplateClassDocumentInitializer.SERVER_CLASS, true, context); object.setIntValue(WikiTemplateClassDocumentInitializer.FIELD_ISWIKITEMPLATE, templateGroup.isTemplate() ? 1 : 0); // The document must have a creator if (descriptorDocument.getCreatorReference() == null) { descriptorDocument.setCreatorReference(context.getUserReference()); } // The document must have an author if (descriptorDocument.getAuthorReference() == null) { descriptorDocument.setAuthorReference(context.getUserReference()); } xwiki.saveDocument(descriptorDocument, String.format("Changed property group [%s].", GROUP_NAME), context); } catch (WikiManagerException e) { throw new WikiPropertyGroupException(String.format(ERROR_MESSAGE_NO_DESCRIPTOR_DOCUMENT, wikiId), e); } catch (XWikiException e) { throw new WikiPropertyGroupException("Unable to save descriptor document.", e); } }
private void setDescriptorDocMetadata(XWikiDocument descriptorDoc) { XWikiContext context = xcontextProvider.get(); // Set the document as hidden descriptorDoc.setHidden(true); // The document must have a creator if (descriptorDoc.getCreatorReference() == null) { descriptorDoc.setCreatorReference(context.getUserReference()); } // The document must have an author if (descriptorDoc.getAuthorReference() == null) { descriptorDoc.setAuthorReference(context.getUserReference()); } // Set the document parent if (descriptorDoc.getParentReference() == null) { EntityReference parentReference = new EntityReference("WebHome", EntityType.DOCUMENT); parentReference.appendParent(new EntityReference("WikiManager", EntityType.SPACE)); descriptorDoc.setParentReference(parentReference); } } }
document.setHidden(true); if (document.getCreatorReference() == null) { document.setCreatorReference(context.getUserReference());
newFamilyXDocument.setCreatorReference(patientXDoc.getCreatorReference()); newFamilyXDocument.setContentAuthorReference(patientXDoc.getContentAuthorReference()); newFamilyXDocument.setParentReference(this.familyParentReference);
doc.setAuthorReference(doc.getCreatorReference());
/** * For every family member, read users and groups that have either view or edit edit access on the patient, then * gives the sam elevel of access on the family for those users and groups. After performing this method, if p is a * member of the family, and x has level y access on p, x has level y access on the family. The user who is the * owner of the family always has full access to the family. Note that the document is not saved to disk, changes * are only made for the provided Family object and its in-memory copy of the corresponding XWiki document. * * @param family to update permissions * @param context XWiki context to be used. The documnt will not be saved to disk, only changes in memory for the * family document given will be made */ public void updatePermissions(Family family, XWikiContext context) { XWiki wiki = context.getWiki(); List<Patient> members = family.getMembers(); this.updatePermissionsForOneRightLevel(VIEW_RIGHTS, members, family.getDocument(), wiki, context); // setting view-edit rights after view rights makes sure if a user has edit rights on one patient // and view rights on another the user still gets edit permissions for the family this.updatePermissionsForOneRightLevel(VIEWEDIT_RIGHTS, members, family.getDocument(), wiki, context); DocumentReference creatorReference = family.getDocument().getCreatorReference(); this.setOwnerPermissionsForUser(creatorReference == null ? "" : creatorReference.toString(), family.getDocument(), context); }