use of com.xpn.xwiki.objects.BaseProperty in project xwiki-platform by xwiki.
the class XWikiDocument method renameProperties.
/**
* @since 2.2M2
*/
public void renameProperties(DocumentReference classReference, Map<String, String> fieldsToRename) {
List<BaseObject> objects = this.xObjects.get(classReference);
if (objects == null) {
return;
}
boolean isDirty = false;
for (BaseObject bobject : objects) {
if (bobject == null) {
continue;
}
for (Map.Entry<String, String> entry : fieldsToRename.entrySet()) {
String origname = entry.getKey();
String newname = entry.getValue();
BaseProperty origprop = (BaseProperty) bobject.safeget(origname);
if (origprop != null) {
BaseProperty prop = origprop.clone();
bobject.removeField(origname);
prop.setName(newname);
bobject.addField(newname, prop);
isDirty = true;
}
}
}
// If at least one property was renamed, mark the document dirty.
if (isDirty) {
setMetaDataDirty(true);
}
}
use of com.xpn.xwiki.objects.BaseProperty in project xwiki-platform by xwiki.
the class DefaultDocumentAccessBridge method getProperty.
@Override
public Object getProperty(ObjectReference objectReference, String propertyName) {
Object value = null;
try {
XWikiContext xcontext = getContext();
if (xcontext != null && xcontext.getWiki() != null) {
DocumentReference documentReference = (DocumentReference) objectReference.extractReference(EntityType.DOCUMENT);
XWikiDocument doc = xcontext.getWiki().getDocument(documentReference, xcontext);
BaseObject object = doc.getXObject(objectReference);
if (object != null) {
BaseProperty property = (BaseProperty) object.get(propertyName);
if (property != null) {
value = property.getValue();
}
}
}
} catch (Exception e) {
this.logger.error("Failed to get property", e);
}
return value;
}
use of com.xpn.xwiki.objects.BaseProperty in project xwiki-platform by xwiki.
the class DefaultDocumentAccessBridge method getProperty.
@Override
public Object getProperty(String documentReference, String className, int objectNumber, String propertyName) {
Object value = null;
try {
XWikiContext xcontext = getContext();
if (xcontext != null && xcontext.getWiki() != null) {
XWikiDocument doc = xcontext.getWiki().getDocument(documentReference, xcontext);
BaseObject object = doc.getObject(className, objectNumber);
if (object != null) {
BaseProperty property = (BaseProperty) object.get(propertyName);
if (property != null) {
value = property.getValue();
}
}
}
} catch (Exception e) {
this.logger.error("Failed to get property", e);
}
return value;
}
use of com.xpn.xwiki.objects.BaseProperty in project xwiki-platform by xwiki.
the class DefaultDocumentAccessBridge method getProperty.
@Override
public Object getProperty(DocumentReference documentReference, DocumentReference classReference, String propertyName) {
Object value = null;
try {
XWikiContext xcontext = getContext();
if (xcontext != null && xcontext.getWiki() != null) {
XWikiDocument doc = xcontext.getWiki().getDocument(documentReference, xcontext);
BaseObject object = doc.getXObject(classReference);
if (object != null) {
BaseProperty property = (BaseProperty) object.get(propertyName);
if (property != null) {
value = property.getValue();
}
}
}
} catch (Exception e) {
this.logger.error("Failed to get property", e);
}
return value;
}
use of com.xpn.xwiki.objects.BaseProperty in project xwiki-platform by xwiki.
the class Property method getValue.
/**
* @return the actual value of the property, as a String, Number or List.
*/
public java.lang.Object getValue() {
BaseProperty baseProperty = getBaseProperty();
com.xpn.xwiki.objects.classes.PropertyClass propertyClass = baseProperty.getPropertyClass(getXWikiContext());
// API level, so that java code using core classes will still have access, regardless or rights.
if (propertyClass != null && "Password".equals(propertyClass.getClassType())) {
if (!getXWikiContext().getWiki().getRightService().hasProgrammingRights(getXWikiContext())) {
return null;
}
}
return getBaseProperty().getValue();
}
Aggregations