9 Replies Latest reply on Jun 9, 2011 10:37 PM by Mrsunilg

    Is there any service "write to repository"??

    Mrsunilg Level 1

      Hi, Is there any service in livecycle workbenchES2 for writing any file to repository, or creating a repository...

       

      I have a service to read a file , readResourceRepository... but dont see any other service... please let me know how do i orchestrate a process to write a file in repository..

        • 1. Re: Is there any service "write to repository"??
          Hodmi Level 4

          AFAIK there is no service out of the box.  There is an API for that (you may be able to change the existing DSC and make the service orchistratable), but that would take some development.

          • 2. Re: Is there any service "write to repository"??
            Mrsunilg Level 1

            Hodmi,

             

            What is DSC?

            Are you talking about execute script activity where i can write java code to act it like "writing to repository".

            • 3. Re: Is there any service "write to repository"??
              Hodmi Level 4

              We're going into unsupported territory here, so be forewarned - this is not supported.  If it doesn't work, or breaks your LiveCycle server you are out of luck.

               

              DSC (Document Service Component) are java code modules that provide services to LiveCycle.  You can create your own and this is part of the extensibility of the LiveCycle product (there are several articles on this on the Developer Network).

               

              Adobe provides you with many DSCs out of the box.  One of which is the Repository DSC.  The jar for this component is located in {LC install}/deploy and it is called adobe-repository-dsc.jar.  This operation has a method called writeResource but it is currently not usable in a workflow (it is used by the system behind the scenes).  You can make it usable by doing the following:

               

              1 - locate the  {LC install}/deploy/adobe-repository-dsc.jar

              2 - make a backup of this file

              3 - open the jar using winzip

              4 - open the component.xml file for editing

              5 - locate the line:           <operation name="writeResource"  method="writeResource" orchestrateable="false" >

              6 - change it to:         <operation name="writeResource"  method="writeResource" orchestrateable="true" >

              7 - save the component.xml file

              8 - add the component.xml file back to the jar file (either using winzip or a JDK)

              Now update your component on the server

              9 - open Workbench

              10 - Choose Window->Show View->Components

              11 - In the components view locate the RepositoryService

              12 - Right click on the RepositoryService and choose Stop Component

              13 - Right click on the RepositoryService and choose Uninstall Component

              14 - Right click on the Components root and choose Install Component

              15 - Follow the wizard and choose your modified jar file

              16 - Right click on the new RepositoryService ad choose Start Component

               

              If all goes right you should see a writeResource under the Repository service (in Foundation).  If anything goes wrong go back to step 9 and reinstall the original (which you backed up in step 2).

               

              As I said - this is NOT SUPPORTED.  You didn't hear it from me....I was never here......

              • 4. Re: Is there any service "write to repository"??
                Mrsunilg Level 1

                Hodmi,

                If this is unsupported, then i should not choose this method. It may harm my server... correct??

                 

                Is there any alternative way to do so...

                 

                I think if i write Java API code to execute script activity.. and make it in such a way that i recieve one file (document) and write it to reposity...

                 

                Is this method fine..

                 

                or can you suggest any other method..

                • 5. Re: Is there any service "write to repository"??
                  Hodmi Level 4

                  In all fairness modifying the DSC to this extent really can't hurt anything else on the server - and you should have a backup of the original DSC in any case.  Although the code uses publicly available APIs, an orchristrated version hasn't been officially tested by Adobe (although several of us have done it on our own).  As an Adobe employee I have make sure you know the risks.

                   

                  Writing either your own DSC (which is just a java jar file with an xml descriptor) will work as will using the Script operation to call the API.

                  • 6. Re: Is there any service "write to repository"??
                    Mrsunilg Level 1

                    Hodmi,

                     

                     

                    First of all i could not fine adobe-repository-dsc.jar on my system. Is it present on server?????

                     

                     

                    Second thing....

                     

                    I tried to use execute script activity and put below code into it... but it is showing some error"DSCRun time exception"...Can a file be written to repostiory using execute script and below code into it...

                     

                    can you modify this code

                     

                     

                     

                     

                    import java.io.ByteArrayInputStream;
                    import java.io.File;
                    import java.lang.String;


                    import java.io.InputStream;
                    import java.util.Properties;

                    import org.apache.commons.codec.binary.Base64;
                    import java.util.*;
                    import com.adobe.idp.Document;
                    import com.adobe.idp.dsc.clientsdk.ServiceClientFactory;
                    import com.adobe.repository.bindings.dsc.client.ResourceRepositoryClient;
                    import com.adobe.repository.infomodel.*;
                    import com.adobe.repository.infomodel.bean.*;

                     


                    com.adobe.idp.Document testFile=patExecContext.getProcessDataDocumentValue("/process_data/InputDoc");

                    String  testFolderUri=patExecContext.getProcessDataValue("/process_data/Path");


                    Properties ConnectionProps = new Properties();
                       ConnectionProps.setProperty(ServiceClientFactoryProperties.DSC_DEFAULT_SOAP_ENDPOINT, "********");
                       ConnectionProps.setProperty(ServiceClientFactoryProperties.DSC_TRANSPORT_PROTOCOL,"SOAP") ;         
                       ConnectionProps.setProperty(ServiceClientFactoryProperties.DSC_SERVER_TYPE, "WebSphere");
                       ConnectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_USERNAME, "********");
                       ConnectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_PASSWORD, "********");
                      

                       ServiceClientFactory myFactory = ServiceClientFactory.createInstance(ConnectionProps);
                      
                      
                       ResourceRepositoryClient repositoryClient = new ResourceRepositoryClient(myFactory);

                     

                     


                    // Create a RepositoryInfomodelFactoryBean needed for creating resources
                       RepositoryInfomodelFactoryBean repositoryInfomodelFactory = new RepositoryInfomodelFactoryBean(null);

                       // Create the resource to be written to the folder
                       Resource testResource = repositoryInfomodelFactory.newResource(
                        new Id(),
                        new Lid(),
                        "testResource"
                       );

                       // Set the resource’s description
                       testResource.setDescription("test resource");

                      
                       ResourceContent testContent = repositoryInfomodelFactory.newResourceContent();
                     
                      
                       testContent.setDataDocument(testFile);
                       //testContent.setSize(testData.length);
                       testResource.setContent(testContent);

                       // Write the resource to the folder
                       repositoryClient.writeResource(testFolderUri, testResource);

                       // Retrieve the resource’s URI
                       //String resourceUri = testFolderUri + "/" + testResource.getName();

                       // Retrieve the resource to verify that it was successfully written
                       //Resource r = repositoryClient.readResource(resourceUri);

                       // Print the resource verification message
                       //System.out.println("Resource " + resourceUri + " was successfully written.");

                      } catch (Exception e) {}

                    • 7. Re: Is there any service "write to repository"??
                      Hodmi Level 4

                      1) the DSC should be in the {liveCycle install}\deploy\adobe-repository-dsc.jar.  For example on my server it is:

                      C:\Adobe\Adobe LiveCycle ES2\deploy\adobe-repository-dsc.jar

                       

                      2) DSCRun time exception just means something is wrong.  Look in the app server's log file for the stack trace and more detailed information.  Usually its something simple like a syntax error or missing input.

                      • 8. Re: Is there any service "write to repository"??
                        Mrsunilg Level 1

                        No Hodmi, I dont find any deploy folder at C:\adobe\adobe livecycle es2\

                        • 9. Re: Is there any service "write to repository"??
                          Mrsunilg Level 1

                          Hi,

                           

                          could you please same me a script to write a document in repository. I want to use this script in createscript activity on workbench. Just i want one document as pdf and want to save in repository.

                           

                          Regards

                          Sunil