11 Replies Latest reply: Oct 26, 2012 7:52 AM by 970471 RSS

    Programmatically creating Contributor Data Files

    Jaap Spiering
      In WebCenter Portal 11g PS5 and WebCenter Content PS5, doing something similar to Yannick's great tutorial here:
      http://www.yonaweb.be/webcenter_tutorial/using_content_presenter_templates

      A customer using a WebCenter Portal is not very enthousiastic about switching to the Site Studio Contributor to create and edit Contributor Data Files.
      Is there a way to programatically create these files from within our portal (via, say, a custom task flow and RIDC) or a custom service in UCM?

      Seems like Site Studio is doing a LOT in the background (SS_CHECKIN_WEB_ASSET, SS_GET_CONTRIBUTOR_STRINGS, then SS_CHECKIN_NEW) and not just checking in a new file which adheres to the Region Definition.
        • 1. Re: Programmatically creating Contributor Data Files
          TheNewBee
          Hi Jaap,

          Did u got any help on this. I am also thinking of same but couldnt try becouse its difficult to know about these services.
          Please help me if u got some documnet related to it

          Thanks
          • 2. Re: Programmatically creating Contributor Data Files
            Jonathan Hult
            You should be able to call a combination of SS_CHECKIN_WEB_ASSET and SS_CHECKIN_NEW from RIDC code. This should checkin the default.xml that ships with Site Studio. I do not believe the XML is customized to the region definition elements until you save it using WCM_EDIT_DATA_FILE.

            https://blogs.oracle.com/ATEAM_WEBCENTER/entry/creating_and_editing_a_page

            Jonathan
            http://jonathanhult.com
            • 3. Re: Programmatically creating Contributor Data Files
              Jaap Spiering
              I didn't get any help at the time, but I figured things out myself :)

              The post above is helpful, but I found the Site Studio services all work with the screens they provide, while I wanted to do everything from my ADF/WebCenter application.
              Basically the Contributor Data File is an XML file, so I made sure my application generated an XML file in the correct format so it would still be possible to edit the file using the Site Studio wizard, if desired.
              • 4. Re: Programmatically creating Contributor Data Files
                715681
                Hi Jaap,

                Which service you used to upload this XML File.
                • 5. Re: Programmatically creating Contributor Data Files
                  Jaap Spiering
                  We use CHECKIN_NEW and CHECKIN_SEL, we use none of the specific SS_ services.
                  • 6. Re: Programmatically creating Contributor Data Files
                    user4644586
                    Hello Everyone,

                    I have requirement to update the element value of CDF file programatically.

                    I was able to find out SS services "SS_GET_ELEMENT_DATA" and "SS_SET_ELEMENT_DATA" but could not able to update the CDF file.

                    If any one have any sample RIDC/intradoc code for this , please share.

                    Thanks a ton in advance !!

                    here is the some sample code that I was trying but could not figure out how to proceed:

                    serviceBinder1.putLocal("IdcService", "SS_GET_ELEMENT_DATA");
                    serviceBinder1.putLocal("dDocName", dDocName);
                    executeService(serviceBinder1, "weblogic", false);
                    String datafile = serviceBinder1.getLocal("dataFile");
                    String specDetailsIntroH1Head = serviceBinder1.getLocal("SpecDetailsIntroH1Head");
                    String jsonResponse = serviceBinder1.getLocal("jsonResponse");
                    //String replacestring = "+'"'+value+'"'+:"; "value"
                    String json = jsonResponse.replace("SKU", "German");
                    SystemUtils.trace("system", "json=="+json);
                    String targetContentId = serviceBinder1.getLocal("targetContentId");
                    String targetdID = serviceBinder1.getLocal("targetdID");
                    serviceBinder1.clearResultSets();
                    serviceBinder1.getLocalData().clear();

                    serviceBinder1.putLocal("IdcService", "SS_SET_ELEMENT_DATA");
                    serviceBinder1.putLocal("dDocName", targetContentId);
                    serviceBinder1.putLocal("dID", targetdID);
                    serviceBinder1.putLocal("dataFile",datafile);
                    serviceBinder1.putLocal("jsonResponse",json);
                    DataResultSet columnResultSet = new DataResultSet();
                    Element dd = new Element();
                    executeService(serviceBinder1, "weblogic", false);
                    • 7. Re: Programmatically creating Contributor Data Files
                      970471
                      What happens when you try the code with SS_GET_ELEMENT_DATA/SS_SET_ELEMENT_DATA? Do you get an Exception?

                      Jonathan
                      http://jonathanhult.com
                      • 8. Re: Programmatically creating Contributor Data Files
                        882509
                        Hi Jonathan,
                        Thanks for reply.

                        SS_GET_ELEMENT_DATA executed properly but when tried to execute "SS_SET_ELEMENT_DATA", then exception throws that SSElementData resultset is missing.


                        Now here I am not able to set the resultset SSElementData with element and values of CDF file.

                        Do you have any suggestion for this please? Any sample code would help a lot.
                        • 9. Re: Programmatically creating Contributor Data Files
                          970471
                          You need to create a ResultSet with the following columns: element, value, and isList. The isList is boolean, so if it is yes, then an additional result set with the name of the element and the columns named with the list sub-elements.

                          Then you need to add rows containing this information to the ResultSet. Finally, you need to add the ResultSet to the DataBinder (binder.addResultSet).

                          http://docs.oracle.com/cd/E17904_01/doc.1111/e10615/c11_ss_services.htm#CHDDGBHF

                          Jonathan
                          http://jonathanhult.com
                          • 10. Re: Programmatically creating Contributor Data Files
                            882509
                            Thanks Jonathan, below provided information was useful. Now I have further queries:

                            Below is the code that I got from net but having some doubt about some classes like "TextCustomElement", "Field ", "CustomDataElement ". Are these classes available in RIDC APIs or not because I was not able to find out? Also let me clarify the steps that need to perform for updating the values of CDF file are mentioned below:

                            First CheckOut the CDF file
                            Execute the service "SS_SET_ELEMENT_DATA" by setting the element values
                            CheckIn back with new revision of this CDF file

                            Are these steps correct?

                            Is it possible for you to correct the below code and paste again in forum or send me the corrected file at suratpccs@gmail.com?

                            Thanks a ton for your help.

                            DataBinder oldBinder = clientConfig.getIdcClient().createBinder();
                                           oldBinder.putLocal("IdcService", "SS_SET_ELEMENT_DATA");
                                           oldBinder.putLocal("dDocName", oldBinder.getLocal("dDocName"));
                                           oldBinder.putLocal("dID", oldBinder.getLocal("dID"));
                                           DataResultSet columnResultSet = new DataResultSetImpl();
                                           Field elem = new Field("element");
                                           Field value= new Field("value");
                                           Field isList = new Field("isList");
                                           columnResultSet.addField(elem, "element");
                                           columnResultSet.addField(value, "value");
                                           columnResultSet.addField(isList, "isList");
                            for( CustomDataElement e : elementi)
                                           {
                                                DataObject valueList = new DataObjectImpl();
                                                if( e instanceof ListCustomElement)
                                                {
                                                     ListCustomElement listel = (ListCustomElement) e;
                                                     valueList.put("element", "cpsAttachmentIdList");
                            //                         valueList.put("value", "");
                                                     valueList.put("isList", "1");
                                                     List<CustomListRow> listRow = listel.getListRow();
                                                     DataResultSet listResultSet = new DataResultSetImpl();
                                                     Field idAttNode = new Field("ATTACHMENT_ID");
                                                     listResultSet.addField(idAttNode, "ATTACHMENT_ID");
                                                     for( CustomListRow r : listRow)
                                                     {
                            //                         list sub-elements
                                                          DataObject valueElement = new DataObjectImpl();
                                                          Set<String> keySet = r.keySet();
                                                          for(String k :keySet)
                                                          {
                                                               TextCustomElement textCustomElement = r.get(k);
                                                               valueElement.put("ATTACHMENT_ID", textCustomElement.getValue());
                                                               listResultSet.addRow(valueElement);
                                                          }
                                                     }
                            //                         name of the element
                                                     oldBinder.addResultSet("sub-elements", listResultSet);
                                                     
                                                }
                                                if( e instanceof TextCustomElement)
                                                {
                                                     TextCustomElement textel = (TextCustomElement) e;
                                                     valueList.put("element", textel.getName());
                                                     valueList.put("value", textel.getValue());
                                                     valueList.put("isList", "0");
                                                }
                                                columnResultSet.addRow(valueList);
                                           }
                                           oldBinder.addResultSet("SSElementData", columnResultSet);
                                           

                                           response = executeService( oldBinder);
                            • 11. Re: Programmatically creating Contributor Data Files
                              970471
                              This part looks correct:

                              DataResultSet columnResultSet = new DataResultSetImpl();
                              Field elem = new Field("element");
                              Field value= new Field("value");
                              Field isList = new Field("isList");
                              columnResultSet.addField(elem, "element");
                              columnResultSet.addField(value, "value");
                              columnResultSet.addField(isList, "isList");

                              I do not believe you want to use classes such as "TextCustomElement", "Field ", "CustomDataElement".

                              For each column in the row, you just want to add a text String. So if I have the WYSIWYG element entitled "title", containing "This is the text in the WYSIWYG", I would do this:

                              List<String> row = new ArrayList<String>();
                              row.add("title");
                              row.add("This is the text in the WYSIWYG");
                              row.add("0");
                              columnResultSet.addRow(row);

                              Jonathan
                              http://jonathanhult.com