use of org.xwiki.rest.model.jaxb.Properties in project xwiki-platform by xwiki.
the class ObjectPropertiesResourceImpl method getObjectProperties.
@Override
public Properties getObjectProperties(String wikiName, String spaceName, String pageName, String className, Integer objectNumber, Boolean withPrettyNames) throws XWikiRestException {
try {
DocumentInfo documentInfo = getDocumentInfo(wikiName, spaceName, pageName, null, null, true, false);
Document doc = documentInfo.getDocument();
com.xpn.xwiki.objects.BaseObject baseObject = getBaseObject(doc, className, objectNumber);
if (baseObject == null) {
throw new WebApplicationException(Status.NOT_FOUND);
}
Object object = DomainObjectFactory.createObject(objectFactory, uriInfo.getBaseUri(), Utils.getXWikiContext(componentManager), doc, baseObject, false, Utils.getXWikiApi(componentManager), withPrettyNames);
Properties properties = objectFactory.createProperties();
properties.getProperties().addAll(object.getProperties());
String objectUri = Utils.createURI(uriInfo.getBaseUri(), ObjectResource.class, doc.getWiki(), Utils.getSpacesFromSpaceId(doc.getSpace()), doc.getName(), object.getClassName(), object.getNumber()).toString();
Link objectLink = objectFactory.createLink();
objectLink.setHref(objectUri);
objectLink.setRel(Relations.OBJECT);
properties.getLinks().add(objectLink);
return properties;
} catch (XWikiException e) {
throw new XWikiRestException(e);
}
}
use of org.xwiki.rest.model.jaxb.Properties in project xwiki-platform by xwiki.
the class ClassPropertiesResourceImpl method getClassProperties.
@Override
public Properties getClassProperties(String wikiName, String className) throws XWikiRestException {
String database = Utils.getXWikiContext(componentManager).getWikiId();
try {
Utils.getXWikiContext(componentManager).setWikiId(wikiName);
com.xpn.xwiki.api.Class xwikiClass = Utils.getXWikiApi(componentManager).getClass(className);
if (xwikiClass == null) {
throw new WebApplicationException(Status.NOT_FOUND);
}
Class clazz = DomainObjectFactory.createClass(objectFactory, uriInfo.getBaseUri(), wikiName, xwikiClass);
Properties properties = objectFactory.createProperties();
properties.getProperties().addAll(clazz.getProperties());
String classUri = Utils.createURI(uriInfo.getBaseUri(), ClassResource.class, wikiName, xwikiClass.getName()).toString();
Link classLink = objectFactory.createLink();
classLink.setHref(classUri);
classLink.setRel(Relations.CLASS);
properties.getLinks().add(classLink);
return properties;
} catch (XWikiException e) {
throw new XWikiRestException(e);
} finally {
Utils.getXWikiContext(componentManager).setWikiId(database);
}
}
use of org.xwiki.rest.model.jaxb.Properties in project xwiki-platform by xwiki.
the class ObjectPropertiesAtPageVersionResourceImpl method getObjectProperties.
@Override
public Properties getObjectProperties(String wikiName, String spaceName, String pageName, String version, String className, Integer objectNumber, Boolean withPrettyNames) throws XWikiRestException {
try {
DocumentInfo documentInfo = getDocumentInfo(wikiName, spaceName, pageName, null, version, true, false);
Document doc = documentInfo.getDocument();
XWikiDocument xwikiDocument = Utils.getXWiki(componentManager).getDocument(doc.getDocumentReference(), Utils.getXWikiContext(componentManager));
xwikiDocument = Utils.getXWiki(componentManager).getDocument(xwikiDocument, doc.getVersion(), Utils.getXWikiContext(componentManager));
com.xpn.xwiki.objects.BaseObject baseObject = xwikiDocument.getObject(className, objectNumber);
if (baseObject == null) {
throw new WebApplicationException(Status.NOT_FOUND);
}
Object object = DomainObjectFactory.createObject(objectFactory, uriInfo.getBaseUri(), Utils.getXWikiContext(componentManager), doc, baseObject, true, Utils.getXWikiApi(componentManager), withPrettyNames);
Properties properties = objectFactory.createProperties();
properties.getProperties().addAll(object.getProperties());
String objectUri = Utils.createURI(uriInfo.getBaseUri(), ObjectAtPageVersionResource.class, doc.getWiki(), Utils.getSpacesFromSpaceId(doc.getSpace()), doc.getName(), version, object.getClassName(), object.getNumber()).toString();
Link objectLink = objectFactory.createLink();
objectLink.setHref(objectUri);
objectLink.setRel(Relations.OBJECT);
properties.getLinks().add(objectLink);
return properties;
} catch (XWikiException e) {
throw new XWikiRestException(e);
}
}
Aggregations