/** * Note that this method cannot be removed for now since it's used by Hibernate for loading a XWikiDocument. * * @param parent the reference of the parent relative to the document * @deprecated since 2.2M1 used {@link #setParentReference(DocumentReference)} instead */ @Deprecated public void setParent(String parent) { // If the passed parent is an empty string we also need to set the reference to null. The reason is that // in the database we store "" when the parent is empty and thus when Hibernate loads this class it'll call // setParent with "" if the parent had not been set when saved. if (StringUtils.isEmpty(parent)) { setParentReference((EntityReference) null); } else { setParentReference(this.relativeEntityReferenceResolver.resolve(parent, EntityType.DOCUMENT)); } }
/** * Convert a full document reference into the proper relative document reference (wiki part is removed if it's the * same as document wiki) to store as parent. * * @deprecated since 2.2.3 use {@link #setParentReference(org.xwiki.model.reference.EntityReference)} instead */ @Deprecated public void setParentReference(DocumentReference parentReference) { if (parentReference != null) { setParent(serializeReference(parentReference, this.compactWikiEntityReferenceSerializer, getDocumentReference())); } else { setParentReference((EntityReference) null); } }
public void setDocumentParentReference(DocumentReference documentReference, DocumentReference parentReference) throws Exception { XWikiContext xcontext = getContext(); XWikiDocument doc = xcontext.getWiki().getDocument(documentReference, xcontext); DocumentReference oldParentReference = doc.getParentReference(); doc.setParentReference(parentReference); saveDocument(doc, String.format("Changed document syntax from [%s] to [%s].", oldParentReference, parentReference), true); }
childDocument.setParentReference(newParentReference);
document.setParentReference(relativeHierarchicalReference); save = true;
serverdoc.setSyntax(Syntax.XWIKI_1_0); serverdoc.setParentReference(VIRTUAL_WIKI_DEFINITION_CLASS_REFERENCE); saveDocument(serverdoc, context); } else {
@Override public void onEvent(Event event, Object source, Object data) { XWikiDocument doc = (XWikiDocument) source; if (doc.getXObject(Group.CLASS_REFERENCE) == null) { return; } DocumentReference docReference = doc.getDocumentReference(); if ("PhenoTipsGroupTemplate".equals(docReference.getName())) { return; } XWikiContext context = this.xcontextProvider.get(); DocumentReference adminsReference = new DocumentReference(docReference.getName() + " Managers", docReference.getLastSpaceReference()); XWiki xwiki = context.getWiki(); try { // Create the managers group XWikiDocument adminsDoc = xwiki.getDocument(adminsReference, context); setMembers(this.dab.getCurrentUserReference(), adminsDoc, context); setRights(adminsReference, adminsDoc, context); adminsDoc.setParentReference(new EntityReference(docReference)); xwiki.saveDocument(adminsDoc, "Automatically created managers group", true, context); // Setup the new group setMembers(adminsReference, doc, context); setRights(adminsReference, doc, context); // This is a pre-save notification, the document will be saved afterwards } catch (XWikiException ex) { this.logger.error("Failed to set up the new group [{}]: {}", docReference, ex.getMessage(), ex); } }
newFamilyXDocument.setCreatorReference(patientXDoc.getCreatorReference()); newFamilyXDocument.setContentAuthorReference(patientXDoc.getContentAuthorReference()); newFamilyXDocument.setParentReference(this.familyParentReference); newFamilyXDocument.setSyntax(Syntax.XWIKI_2_1);
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); } } }
@Override public void onEvent(Event event, Object source, Object data) { XWikiDocument doc = (XWikiDocument) source; if (doc.getXObject(Group.CLASS_REFERENCE) == null) { return; } DocumentReference docReference = doc.getDocumentReference(); if ("PhenoTipsGroupTemplate".equals(docReference.getName())) { return; } XWikiContext context = this.xcontextProvider.get(); DocumentReference adminsReference = new DocumentReference(docReference.getName() + " Administrators", docReference.getLastSpaceReference()); XWiki xwiki = context.getWiki(); try { // Create the administrative group XWikiDocument adminsDoc = xwiki.getDocument(adminsReference, context); setMembers(this.dab.getCurrentUserReference(), adminsDoc, context); setRights(adminsReference, adminsDoc, context); adminsDoc.setParentReference(new EntityReference(docReference)); xwiki.saveDocument(adminsDoc, "Automatically created administrative group", true, context); // Setup the new group setMembers(adminsReference, doc, context); setRights(adminsReference, doc, context); // This is a pre-save notification, the document will be saved afterwards } catch (XWikiException ex) { this.logger.error("Failed to set up the new group [{}]: {}", docReference, ex.getMessage(), ex); } }
newFamilyXDocument.setCreatorReference(patientXDoc.getCreatorReference()); newFamilyXDocument.setContentAuthorReference(patientXDoc.getContentAuthorReference()); newFamilyXDocument.setParentReference(this.familyParentReference); newFamilyXDocument.setSyntax(Syntax.XWIKI_2_1);
setParentReference(this.currentMixedDocumentReferenceResolver.resolve(parent));
setParentReference(templatedoc.getParentReference());
doc.setParentReference(new EntityReference("XWikiClasses", EntityType.DOCUMENT) .appendParent(new EntityReference("XWiki", EntityType.SPACE)));
this.document.setParentReference(getEntityReference(WikiDocumentFilter.PARAMETER_PARENT, parameters, null)); this.document.setCustomClass(getString(WikiDocumentFilter.PARAMETER_CUSTOMCLASS, parameters, null)); this.document.setTitle(getString(WikiDocumentFilter.PARAMETER_TITLE, parameters, null));
doc.setStore(getStore()); doc.setTemplateDocumentReference(getTemplateDocumentReference()); doc.setParentReference(getRelativeParentReference()); doc.setCreatorReference(getCreatorReference()); doc.setDefaultLanguage(getDefaultLanguage());
baseclass.fromMap(map, userObject); doc.setParentReference(parentReference); doc.setContent(content); doc.setSyntax(syntax);
for (DocumentReference childDocumentReference : childDocumentReferences) { XWikiDocument childDocument = xwiki.getDocument(childDocumentReference, context); childDocument.setParentReference(newDocumentReference); String saveMessage = context.getMessageTool().get("core.comment.renameParent", Arrays.asList(this.compactEntityReferenceSerializer.serialize(newDocumentReference)));