HandlerXml xml = new HandlerXml();
Object result = svc.get("/files/basic/api/introspection",params, xml).getData();
if (result instanceof Document) {
XmlNavigator workspacesNavigator = new XmlNavigator((Document) result);
DataNavigator filesNavigator = workspacesNavigator.get(TAG_SERVICE + "/" + TAG_WORKSPACE).selectEq(TAG_TITLE, ATTR_VAL_FILES);
String href = filesNavigator.get(TAG_COLLECTION).selectEq(TAG_TITLE, ATTR_VAL_MY_FILES).stringValue(ATTR_HREF);
if (StringUtil.isNotEmpty(href)) {
String start = svc.getEndpoint().getUrl();
if (href.indexOf(start) > -1) {
href = href.substring(href.indexOf(start) + start.length());
}
ClientService filesService = createClientService(svc.getEndpoint(), href);
result = filesService.get(href, ClientService.FORMAT_XML).getData();
if (result instanceof Document) {
Document entriesDocument = (Document) result;
XmlNavigator entriesNavigator = new XmlNavigator(entriesDocument);
DataNavigator entries = entriesNavigator.get(TAG_FEED + "/" + TAG_ENTRY);
String repId = entriesNavigator.stringValue(TAG_FEED + "/" + TAG_ID);
if (StringUtil.isNotEmpty(repId)) {
repId = repId.substring(repId.lastIndexOf(':') + 1);
}
if (entries != null) {
String epName = accessor.findEndpointName();
for (int i = 0; i < entries.getCount(); i++) {
DataNavigator navigator = entries.get(i);
FileEntry fe = new FileEntry();
fe.setRepository(repId);
fe.setTitle(navigator.stringValue(TAG_LABEL));
fe.setUpdated(navigator.dateValue(TAG_MODIFIED));
fe.setAuthorName(navigator.stringValue(TAG_AUTHOR + "/" + TAG_NAME));
fe.setDescription(navigator.stringValue(TAG_SUMMARY));
fe.setFileId(navigator.stringValue(TAG_UUID));
fe.setUniqueId(fe.getFileId());
fe.setMimeType(getMimeType(navigator.stringValue(TAG_LABEL)));
fe.setIcon(MimeIconRegistry.getInstance().get(fe.getMimeType()));
String proxyUrl = "xsp/.proxy/files/"+accessor.findEndpointName()+"/connections/" + fe.getTitle() + "?" + PARAM_TYPE + "=" + TYPE + "&" + PARAM_ID
+ "=" + fe.getUniqueId() + "&" + PARAM_REPOSITORY_ID + "=" + repId + "&"+"fileName="+fe.getTitle()+"&" + PARAM_ENDPOINT_NAME
+ "=";
if (StringUtil.isNotEmpty(epName)) {
proxyUrl = proxyUrl + epName;
}
else {
proxyUrl = proxyUrl + TYPE;
}
fe.setProxyURL(proxyUrl);
fe.setPublished(navigator.dateValue(TAG_PUBLISHED));
fe.setVersion(navigator.stringValue(TAG_VERSION));
fe.setVisibility(navigator.stringValue(TAG_VISIBILITY));
fileEntries.add(fe);
}
}
}
}