if (urlRepositoryInfo.compareTo(undefined)==0) {
out.write(callback + "('" + index + "', null, 500, 'RespositoryInfo URL not specified', 500)");
return;
}
ECMRepository ecm = new ECMRepository(user, password);
ConfigFileHandler cfh = new ConfigFileHandler("repositoriesNum.properties","repositories","repositoryInfo", "repositoryCapabilities", "uriTemplates", "contentTypes", "metainfo");
//String filePath = getServletContext().getRealPath("/WEB-INF/classes") +"/";
String filePath = getServletContext().getRealPath("/WEB-INF") +"/";
// getting Repository Info
RequestOptions requestOptions = ecm.createRequestOptions();
ClientResponse cResp = ecm.getRequest(urlRepositoryInfo, requestOptions);
Document<Service> doc = cResp.getDocument();
Service ecmInfo = doc.getRoot();
JSONObject ecmInfoJSON = cfh.getRepositoryInfo(ecmInfo);
// ADD: getting cmis:folder type
// getting getTypes uri
JSONObject uriTemplates = JSONObject.fromObject(ecmInfoJSON.get("uriTemplates"));
String urlService = uriTemplates.get("typebyid").toString();
CharSequence target = "{id}";
CharSequence replacement = "cmis:document";
urlService = urlService.replace(target, replacement);
urlService += "/children";
/*// getFolderTypes
String urlFolderTypeService = uriTemplates.getString("typebyid").toString();
target = "{id}";
replacement = "cmis:folder";
urlFolderTypeService = urlFolderTypeService.replace(target, replacement);
urlFolderTypeService += "/children";
//System.out.println("urlFolderTypeService: "+ urlFolderTypeService);*/
// getting Content Types
JSONObject contentTypes = new JSONObject();
//String[] exclTypes = {":wcm:",":inwf:",":fm:",":bpm:",":lnk:",":cm:",":imap:",":wca:",":ia:"};
String[] exclTypes = {":wcm:",":inwf:",":fm:",":bpm:",":lnk:",":cm:",":imap:",":wca:",":ia:",":trx:",":rma:",":dl:",":ws:"};
Feed feed = ecm.getFeed(urlService);
List<Entry> typesList = ecm.getTypes(feed, exclTypes);
Entry type;
for (int i=0; i<typesList.size(); i++) {
type = typesList.get(i);
contentTypes.put("ctype" + String.valueOf(i), type.getContent());
}
/*// getting Folder Content Types
Feed feedFolder = ecm.getFeed(urlFolderTypeService);
typesList = ecm.getTypes(feedFolder, exclTypes);
System.out.println("typesList: "+ typesList);
for (int i=0; i<typesList.size(); i++) {
type = typesList.get(i);
contentTypes.put("ctype" + String.valueOf(contentTypes.size()), type.getContent());
}*/
// getting Metadata Content Types
String getTypeDefURL = uriTemplates.get("typebyid").toString();
JSONObject metadataTypes = new JSONObject();
ECMRepository repo = new ECMRepository(user, password);
for (int i=0; i<contentTypes.size(); i++) {
urlService = getTypeDefURL;
String typeName = contentTypes.getString("ctype"+ String.valueOf(i));
replacement = typeName;
urlService = urlService.replace(target, replacement);
urlService += "?includeInheritedProperties=true";
Entry entry = repo.getEntry(urlService);
AtomToJSON atom2json = new AtomToJSON();
JSONObject json = atom2json.entry2JSON(entry);
JSONObject typeTag = json.getJSONObject("type");
metadataTypes.put("metainfo-ctype"+ String.valueOf(i), typeTag.toString());