/** * @deprecated since 2.2M1 use {@link #getXObject(DocumentReference, String, String)} instead */ @Deprecated public BaseObject getObject(String className, String key, String value) { return getObject(className, key, value, false); }
private BaseProperty getTagProperty(XWikiContext context) { BaseObject tags = getObject(XWikiConstant.TAG_CLASS); return tags != null ? ((BaseProperty) tags.safeget(XWikiConstant.TAG_CLASS_PROP_TAGS)) : null; }
/** * @param userDocument the user profile page. * @return the uid store in the user profile. Null if it can't find any or if it's empty. */ public String getUid(XWikiDocument userDocument) { BaseObject ldapObject = userDocument.getObject(this.ldapClass.getName()); return ldapObject == null ? null : getUid(ldapObject); }
private void saveEntry(String feedname, String feedurl, SyndEntry entry, XWikiDocument doc, boolean fullContent, XWikiContext context) throws XWikiException { int id = doc.createNewObject("XWiki.FeedEntryClass", context); BaseObject obj = doc.getObject("XWiki.FeedEntryClass", id); saveEntry(feedname, feedurl, entry, doc, obj, fullContent, context); }
/** * @param userDocument the user profile page. * @return the dn store in the user profile. Null if it can't find any or if it's empty. */ public String getDn(XWikiDocument userDocument) { BaseObject ldapObject = userDocument.getObject(this.ldapClass.getName()); return ldapObject == null ? null : getDn(ldapObject); }
public Object getObject(String classname, int nb) { try { BaseObject obj = this.getDoc().getObject(classname, nb); if (obj == null) { return null; } else { return newObjectApi(obj, getXWikiContext()); } } catch (Exception e) { return null; } }
public String getChronoPreference(String optname, XWikiContext context) throws XWikiException { return context.getWiki().getDocument(CLASS_CHRONOPREFS, context) .getObject(CLASS_CHRONOPREFS).getStringValue(optname); } }
public Object getObject(String classname, String key, String value, boolean failover) { try { BaseObject obj = this.getDoc().getObject(classname, key, value, failover); if (obj == null) { return null; } else { return newObjectApi(obj, getXWikiContext()); } } catch (Exception e) { return null; } }
public Object getObject(String classname, String key, String value) { try { BaseObject obj = this.getDoc().getObject(classname, key, value); if (obj == null) { return null; } else { return newObjectApi(obj, getXWikiContext()); } } catch (Exception e) { return null; } }
protected BaseObject getBaseObject(Document doc, String className, int objectNumber) throws XWikiException { XWikiDocument xwikiDocument = Utils.getXWiki(componentManager).getDocument(doc.getPrefixedFullName(), Utils.getXWikiContext(componentManager)); return xwikiDocument.getObject(className, objectNumber); }
private List<String> getTagsFromDocument(String documentId) throws XWikiException { XWikiDocument document = Utils.getXWiki(componentManager).getDocument(documentId, Utils.getXWikiContext(componentManager)); BaseObject object = document.getObject("XWiki.TagClass"); if (object != null) { BaseProperty prop = (BaseProperty) object.safeget("tags"); if (prop != null) { return (List<String>) prop.getValue(); } } return new ArrayList<String>(); } }
@Override public boolean containsWikiMacro(DocumentReference documentReference) { boolean result; try { XWikiDocument doc = getContext().getWiki().getDocument(documentReference, getContext()); BaseObject macroDefinition = doc.getObject(WIKI_MACRO_CLASS); result = (null != macroDefinition); } catch (XWikiException ex) { result = false; } return result; }
public XObject addObject(XWikiDocument doc, String className) throws XWikiGWTException { try { XWikiContext context = getXWikiContext(); int index = doc.createNewObject(className, context); return newObject(new XObject(), doc.getObject(className, index), false, false, context); } catch (Exception e) { throw getXWikiGWTException(e); } }
/** * {@inheritDoc} * * @see DocumentAccessBridge#getProperty(String, String, int, String) */ public Object getProperty(String documentReference, String className, int objectNumber, String propertyName) { try { XWikiContext xcontext = getContext(); return ((BaseProperty) xcontext.getWiki().getDocument(documentReference, xcontext).getObject(className, objectNumber).get(propertyName)).getValue(); } catch (Exception ex) { return null; } }
/** * add tags to the document. */ public void setTags(String tagsStr, XWikiContext context) throws XWikiException { BaseClass tagsClass = context.getWiki().getTagClass(context); StaticListClass tagProp = (StaticListClass) tagsClass.getField(XWikiConstant.TAG_CLASS_PROP_TAGS); BaseObject tags = getObject(XWikiConstant.TAG_CLASS, true, context); tags.safeput(XWikiConstant.TAG_CLASS_PROP_TAGS, tagProp.fromString(tagsStr)); setMetaDataDirty(true); }
private void saveStatus(String status, BaseObject object, XWikiContext context) throws XWikiException { XWikiDocument jobHolder = context.getWiki().getDocument(object.getName(), context); // We need to retrieve the object BaseObject the document again. Otherwise, modifications made to the // BaseObject passed as argument will not be saved (XWikiDocument#getObject clones the document // and returns the BaseObject from the clone) // TODO refactor the plugin in order to stop passing BaseObject around, passing document references instead. BaseObject job = jobHolder.getObject(XWIKI_JOB_CLASS); job.setStringValue("status", status); jobHolder.setMinorEdit(true); context.getWiki().saveDocument(jobHolder, context); }
public java.lang.Object get(String classOrFieldName) { if (this.currentObj != null) { return this.doc.display(classOrFieldName, this.currentObj.getBaseObject(), getXWikiContext()); } BaseObject object = this.doc.getFirstObject(classOrFieldName, getXWikiContext()); if (object != null) { return this.doc.display(classOrFieldName, object, getXWikiContext()); } return this.getDoc().getObject(classOrFieldName); }
/** * Retrieves the value of a string property. */ protected String getStringValue(String mapping, Document doc, XWikiContext context) throws XWikiException { PropertySelector ps = new PropertySelector(mapping); if (ps.getClassName() == null) { return doc.display(ps.getPropertyName()); } else { XWikiDocument xdoc = context.getWiki().getDocument(doc.getFullName(), context); return xdoc.getObject(ps.getClassName(), ps.getObjectIndex()).getStringValue(ps.getPropertyName()); } }
/** * Retrieves the value of a date property. */ protected Date getDateValue(String mapping, Document doc, XWikiContext context) throws XWikiException { XWikiDocument xdoc = context.getWiki().getDocument(doc.getFullName(), context); PropertySelector ps = new PropertySelector(mapping); if (ps.getClassName() == null) { return xdoc.getFirstObject(ps.getPropertyName(), context).getDateValue(ps.getPropertyName()); } else { return xdoc.getObject(ps.getClassName(), ps.getObjectIndex()).getDateValue(ps.getPropertyName()); } }
/** * Retrieves the value of a list property. */ protected List<Object> getListValue(String mapping, Document doc, XWikiContext context) throws XWikiException { XWikiDocument xdoc = context.getWiki().getDocument(doc.getFullName(), context); PropertySelector ps = new PropertySelector(mapping); if (ps.getClassName() == null) { return xdoc.getFirstObject(ps.getPropertyName(), context).getListValue(ps.getPropertyName()); } else { return xdoc.getObject(ps.getClassName(), ps.getObjectIndex()).getListValue(ps.getPropertyName()); } }