use of org.apache.jackrabbit.spi.PropertyInfo in project jackrabbit by apache.
the class RepositoryServiceImpl method getItemInfos.
/**
* @see RepositoryService#getItemInfos(SessionInfo, ItemId)
*/
@Override
public Iterator<? extends ItemInfo> getItemInfos(SessionInfo sessionInfo, ItemId itemId) throws RepositoryException {
if (!itemId.denotesNode()) {
PropertyInfo propertyInfo = getPropertyInfo(sessionInfo, (PropertyId) itemId);
return Iterators.singleton(propertyInfo);
} else {
NodeId nodeId = (NodeId) itemId;
Path path = getPath(itemId, sessionInfo);
String uri = getURI(path, sessionInfo);
int depth = batchReadConfig.getDepth(path, this.getNamePathResolver(sessionInfo));
HttpGet request = new HttpGet(uri + "." + depth + ".json");
HttpResponse response = null;
try {
response = executeRequest(sessionInfo, request);
int statusCode = response.getStatusLine().getStatusCode();
if (statusCode == DavServletResponse.SC_OK) {
HttpEntity entity = response.getEntity();
if (entity.getContentLength() == 0) {
// no JSON response -> no such node on the server
throw new ItemNotFoundException("No such item " + nodeId);
}
NamePathResolver resolver = getNamePathResolver(sessionInfo);
NodeInfoImpl nInfo = new NodeInfoImpl(nodeId, path);
ItemInfoJsonHandler handler = new ItemInfoJsonHandler(resolver, nInfo, getRootURI(sessionInfo), getQValueFactory(sessionInfo), getPathFactory(), getIdFactory());
JsonParser ps = new JsonParser(handler);
ps.parse(entity.getContent(), ContentType.get(entity).getCharset().name());
Iterator<? extends ItemInfo> it = handler.getItemInfos();
if (!it.hasNext()) {
throw new ItemNotFoundException("No such node " + uri);
}
return handler.getItemInfos();
} else {
throw ExceptionConverter.generate(new DavException(statusCode, "Unable to retrieve NodeInfo for " + uri), request);
}
} catch (IOException e) {
log.error("Internal error while retrieving NodeInfo.", e);
throw new RepositoryException(e.getMessage());
} finally {
request.releaseConnection();
}
}
}
use of org.apache.jackrabbit.spi.PropertyInfo in project jackrabbit by apache.
the class RepositoryServiceImpl method buildPropertyInfos.
private List<PropertyInfo> buildPropertyInfos(NodeInfo nInfo) throws RepositoryException {
List<PropertyInfo> l = new ArrayList<PropertyInfo>(3);
NodeId nid = nInfo.getId();
Path nPath = nInfo.getPath();
if (nid.getPath() == null) {
PropertyId id = getIdFactory().createPropertyId(nid, NameConstants.JCR_UUID);
QValue[] vs = new QValue[] { getQValueFactory().create(nid.getUniqueID(), PropertyType.STRING) };
Path p = getPathFactory().create(nPath, NameConstants.JCR_UUID, true);
PropertyInfo pi = new PropertyInfoImpl(id, p, PropertyType.STRING, false, vs);
l.add(pi);
}
Name pName = NameConstants.JCR_PRIMARYTYPE;
QValue[] vs = new QValue[] { getQValueFactory().create(nInfo.getNodetype()) };
PropertyInfo pi = new PropertyInfoImpl(getIdFactory().createPropertyId(nid, pName), getPathFactory().create(nPath, pName, true), PropertyType.NAME, false, vs);
l.add(pi);
Name[] mixins = nInfo.getMixins();
if (mixins.length > 0) {
pName = NameConstants.JCR_MIXINTYPES;
vs = new QValue[mixins.length];
for (int i = 0; i < mixins.length; i++) {
vs[i] = getQValueFactory().create(mixins[i]);
}
pi = new PropertyInfoImpl(getIdFactory().createPropertyId(nid, pName), getPathFactory().create(nPath, pName, true), PropertyType.NAME, true, vs);
l.add(pi);
}
return l;
}
Aggregations