AnsweredAssumed Answered

Using Checkin and Checkout API

Question asked by ajaiking on Jun 9, 2009

I am new to Alfresco and i need to write my custom java class that does the checkin and checkout operation.
I have gone through some documents and with the help of forums, am able to do a document checkin.
But when i try to checkout a document, i am facing issues, when saving a working copy in the system,
I need your help to resolve this,

This is my checkout code:

public static void getCheckOut(String fileName) throws Exception{

Node rootNode = session.getRootNode();
      Node companyHome = rootNode.getNode("app:company_home");
      NodeIterator  checkedfiles = companyHome.getNodes(fileName);
        Node node = (Node);
        Property prop = node.getProperty("cm:name");
        Value value = prop.getValue();
        String str = value.getString();
      // convert the JCR Node to an Alfresco Node Reference
      NodeRef nodeRef = JCRNodeRef.getNodeRef(node);
      ServiceRegistry serviceRegistry = initAlfrescoFoundation();
      CheckOutCheckInService cociService = serviceRegistry.getCheckOutCheckInService();
      NodeRef workingCopy = cociService.checkout(nodeRef);
      ContentService contentService = serviceRegistry.getContentService();
      NodeService nodeService = serviceRegistry.getNodeService();
      ContentReader reader = contentService.getReader(workingCopy,  ContentModel.PROP_CONTENT);
      System.out.println("Type: "+reader.getMimetype());
      File file=new File("c:/testchec.pdf");

Here am not able to get the checkout as a file in the system,

Kindly help me out.

Ajai G