Package com.germinus.ecm.bean

Examples of com.germinus.ecm.bean.ECMRepository


       String ticket = "";
       String urlLoginService = "";
      
       // Search by repository
       for (int repo=1; repo<repositories+1; repo++) {
            ECMRepository ecm = new ECMRepository(user, pwd);
        
            JSONObject repoConfig = cfh.getRepositoryConfig(filePath, repo);
            JSONObject uriTemplates = repoConfig.getJSONObject("uriTemplates");
            String urlQueryService = uriTemplates.getString("query");
      int pos = urlQueryService.indexOf("{q}");
      urlQueryService = urlQueryService.substring(0, pos);
        
            JSONObject repoInfo = repoConfig.getJSONObject("repositoryInfo");
      String rootFolderId = repoInfo.getString("rootFolderId");    
      JSONObject contentTypes = repoConfig.getJSONObject("contentTypes");
        
      String contentType = "";
      JSONObject jsonType = new JSONObject();

      // TICKET (ALFRESCO)
      urlLoginService = urlQueryService.substring(0, urlQueryService.indexOf("/cmis/query"));
      urlLoginService += "/api/login?u="+ user +"&pw="+ pwd +"&format=json";
      //System.out.println(urlLoginService);
      ticket = ecm.getTicket(urlLoginService);
      ticket = "&alf_ticket="+ ticket;
      //
        
      // Search by content
      for (int i=1; i<contentTypes.size(); i++) {
                resultsByContent = new JSONArray();
        contentType = contentTypes.getString("ctype"+ String.valueOf(i));
        contentType = contentType.substring(2);

        JSONObject metadataList = repoConfig.getJSONObject("metainfo").getJSONObject("metainfo-ctype"+ String.valueOf(i));
        JSONArray metadata = metadataList.getJSONArray("propertyStringDefinition");

                ecm = new ECMRepository(user, pwd);
        Feed feedResp = ecm.query(urlQueryService, contentType, rootFolderId, query, metadata, ticket);
System.out.println(feedResp.toString());
        List<Entry> contents = feedResp.getEntries();
        Entry content = null;

        for (int j=0; j<contents.size(); j++) {
View Full Code Here


            JSONObject jsonType = new JSONObject();

            // Search by repository
            for (int repo = 1; repo < repositories + 1; repo++) {
                ECMRepository ecm = new ECMRepository(user, pwd);

                JSONObject repoConfig = cfh.getRepositoryConfig(filePath, repo);
                JSONObject uriTemplates = repoConfig.getJSONObject("uriTemplates");
                String urlQueryService = uriTemplates.getString("query");
                int pos = urlQueryService.indexOf("{q}");
                urlQueryService = urlQueryService.substring(0, pos);

                JSONObject repoInfo = repoConfig.getJSONObject("repositoryInfo");
                String rootFolderId = repoInfo.getString("rootFolderId");


                // TICKET (ALFRESCO)
                urlLoginService = urlQueryService.substring(0, urlQueryService.indexOf("/cmis/query"));
                urlLoginService += "/api/login?u=" + user + "&pw=" + pwd + "&format=json";
                System.out.println(urlLoginService);
                ticket = ecm.getTicket(urlLoginService);
                ticket = "&alf_ticket=" + ticket;


                JSONObject metadataList = repoConfig.getJSONObject("metainfo").getJSONObject("metainfo-ctype0");
                JSONArray metadata = metadataList.getJSONArray("propertyStringDefinition");

                //String urlService = "http://"+ request.getServerName() +":"+ request.getServerPort()+"/alfresco/service/cmis/query?q=";
                String sQuery = "SELECT cmis:objectId FROM " + contentType + " WHERE iptc:name='"+query+"' AND IN_TREE('"+rootFolderId+"')";
                try {
                    sQuery = URLEncoder.encode(sQuery, "UTF-8");
                } catch (UnsupportedEncodingException e) {
                    System.err.println("[query] Error "+ e.getMessage());
                }

                urlQueryService += sQuery;
//System.out.println(urlQueryService);
                Feed feedResp = ecm.getFeed(urlQueryService);

                List<Entry> contents = feedResp.getEntries();
//System.out.println(feedResp.toString());
                Entry content = null;
                String objectId = null;
View Full Code Here

                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());
View Full Code Here

TOP

Related Classes of com.germinus.ecm.bean.ECMRepository

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.