This discussion is archived
10 Replies Latest reply: Nov 21, 2012 9:14 AM by user434745 RSS

How to Create a New Folder in UCM with API?

954977 Newbie
Currently Being Moderated
Hi,I'm working with UCM programing, now I know how to make a new file in UCM by API, but I don't know how to create a folder in UCM by API.
Many thanks to who can help me.You can give me an example like this:
public String createFile(String fileName, InputStream inputStream,
String parentFolderId) {
String dID = null;
try {
DataBinder dataBinder = this.idcClient.createBinder();
dataBinder.putLocal("IdcService", "CHECKIN_UNIVERSAL");
dataBinder.putLocal("dSecurityGroup", "Public");
dataBinder.putLocal("xCollectionID", parentFolderId);
dataBinder.getLocalData().setDate("dInDate", new Date());
TransferFile tf = new TransferFile(inputStream, fileName, -1L);
dataBinder.addFile("primaryFile", tf);
ServiceResponse response = this.idcClient.sendRequest(this.idcContext, dataBinder);
DataBinder responseData = response.getResponseAsBinder();
dID = responseData.getLocal("dID");
response.close();
} catch (Exception e) {
throw new RuntimeException(e);
}
return dID;
}
  • 1. Re: How to Create a New Folder in UCM with API?
    jiri.machotka Guru
    Currently Being Moderated
    Which component do you use? For Contribution Folders, there is a sample available in this thread: creation of folder structure using RIDC code

    For Framework Folders there seems to be no example available, yet. It should be similar, though, just calling a different service, FLD_CREATE_FOLDER - http://docs.oracle.com/cd/E23943_01/doc.1111/e11011/c08_frameworkfolders.htm#CHDFBCJF

    Like always with the API code, you can basically read what you should do, if you turn on system-wide tracing (most likely for requestaudit - http://docs.oracle.com/cd/E23943_01/doc.1111/e10792/c03_processes.htm#CSMSP536 ) and perform the scenario from GUI.
  • 2. Re: How to Create a New Folder in UCM with API?
    954977 Newbie
    Currently Being Moderated
    Thank you,but I still got question.The first link you gave can help me.
    When this sentence executed:
    System.out.println("dCollectionID.... " + serverBinder.getLocal("dCollectionID"));

    I can't get the value of dCollectionID,and the output is:
    dCollectionID.... null

    Also still in the UCM I can't see the folder I meant to create.
    Please help me to deal with the issue.
    Thank you!
  • 3. Re: How to Create a New Folder in UCM with API?
    jiri.machotka Guru
    Currently Being Moderated
    Take a look also at the last link I gave you.

    If dCollection is null it most likely means that parameters of the service, or the service itself, are somehow incorrect. You can find it in
    ServiceResponse response =idcClient.sendRequest(userContext, dataBinder);
    or - even more easily - in the log.

    Let me repeat, if you do it from GUI first, the log will tell you what service with what parameters should be called.
  • 4. Re: How to Create a New Folder in UCM with API?
    954977 Newbie
    Currently Being Moderated
    Here are my test sentences in JDeveloper:
    idcClient = manager.createClient("idc://192.168.15.128:4444");
    IdcContext userContext = new IdcContext("weblogic");
    String PATH = "/Contribution Folders";
    DataBinder dataBinder = idcClient.createBinder();
    dataBinder.putLocal("IdcService", "COLLECTION_NEW");
    dataBinder.putLocal("hasParentCollectionID", "true");
    dataBinder.putLocal("dCollectionName", submissionID);
    dataBinder.putLocal("dParentCollectionID",this.getFolderIdFromPath(idcClient,userContext,PATH + "/" +journalName));
    dataBinder.putLocal("dCollectionOwner", "sysadmin");
    ServiceResponse response = idcClient.sendRequest(userContext, dataBinder);
    System.out.println("userContext is:"+userContext);
    System.out.println("dataBinder is:"+dataBinder);
    System.out.println("response is:"+response);
    DataBinder serverBinder = response.getResponseAsBinder();
    System.out.println("serverBinder is:"+serverBinder);
    System.out.println("dCollectionID.... " + serverBinder.getLocal("dCollectionID"));

    I tried to output the parameter serverBinder ,but I can only get this:
    serverBinder is: IdcService: COLLECTION_NEW
    ClientEncoding: UTF-8
    ECID-Context: 1.0000JgO9NHvB5EWFLzESOA1GeWLx000001;kajE
    IsJava: 1
    NoHttpHeaders: 0
    UserDateFormat: iso8601
    UserTimeZone: UTC
    blDateFormat: yyyy-MM-dd HH:mm:ssZ!tUTC!mAM,PM
    blFieldTypes: xForceFolderSecurity text,xPartitionId text,dInDate date,xReadOnly text,dSubscriptionNotifyDate date,xTemplateType text,dMessage message,xInhibitUpdate text,dCreateDate date,xWebFlag text,dSubscriptionCreateDate date,xHidden text,dReleaseDate date,StatusMessage message,dSubscriptionUsedDate date,xCollectionID int,xStorageRule text,dOutDate date,xExternalDataSet bigtext,xComments memo,xIdcProfile text
    changedMonikers:
    changedSubjects:
    dCollectionName: zhangsan
    dCollectionOwner: sysadmin
    dParentCollectionID: 660049714646000201
    dUser: weblogic
    defaultAccount:
    deleteComplete: true
    deleteCompleteInCollections: true
    deleteImmediate: false
    exploreStyle: virtualfs
    hasHierarchicalBased: true
    hasParentCollectionID: true
    idcToken:
    isEmptyReleaseDate: 1
    localizedForResponse: 1
    noAuthorDefault: 1
    noRevLabel: 1
    refreshMonikers:
    refreshSubMonikers:
    refreshSubjects:
    showHidden: true
    embedded ResultSets: 'DocFormats' 'DocTypes' 'METADATA_OVERRIDE' 'UserAttribInfo'

    And I readlly can't see the dCollectionID,and I don't know why this happens.
    Also the log file can't help me either.
    Hope you can understand what I mean and help me to solve the problem.
  • 5. Re: How to Create a New Folder in UCM with API?
    jiri.machotka Guru
    Currently Being Moderated
    OK, for the third time, what happens, if you do it from GUI?

    1) I have no confirmation that you use the component Contribution Folders, but even if so, this can confirm that you call the right service
    2) Once the service is verified, you should verify its parameters. Most often, either a mandatory parameter is missing, or (most likely here) while copying/pasting a 3rd party code, some parameters have to be adjusted to your system. From the code there are two that might require adjustment:
    dataBinder.putLocal("dParentCollectionID",this.getFolderIdFromPath(idcClient,userContext,PATH + "/" +journalName));
    dataBinder.putLocal("dCollectionOwner", "sysadmin");
    Again, GUI will give you parameters that work and you can later adjust them to your needs.
    3) You gave details about serverBinder, but first thing to verify is response. If there is an error in parameters, I'd expect to find it there (but maybe I'm wrong).
  • 6. Re: How to Create a New Folder in UCM with API?
    jiri.machotka Guru
    Currently Being Moderated
    blFieldTypes: xForceFolderSecurity text,xPartitionId text,dInDate date,xReadOnly text,dSubscriptionNotifyDate date,xTemplateType text,dMessage message,xInhibitUpdate text,dCreateDate date,xWebFlag text,dSubscriptionCreateDate date,xHidden text,dReleaseDate date,StatusMessage message,dSubscriptionUsedDate date,xCollectionID int,xStorageRule text,dOutDate date,xExternalDataSet bigtext,xComments memo,xIdcProfile text
    Actually, take a look also at xCollectionID . Maybe, that's the answer.

    Anyway, you also wrote:
    Also still in the UCM I can't see the folder I meant to create.
    This can be related to dParentCollectionID. I'd suggest to start with a fixed value (then, you will have to make dCollectionName dynamic so that you can call your code several times)
  • 7. Re: How to Create a New Folder in UCM with API?
    954977 Newbie
    Currently Being Moderated
    Thank you for your answers,I test your answer,but it doesn't work.
    Now I have soved this issuse.
    The key code is
    dataBinder.putLocal("IdcService", "COLLECTION_ADD");
    The webpage is
    [http://oraclemw.blogspot.com/2011/04/integrating-oracle-ucm-11g-ridc-with.html]
    By the way,do you know if the UCM has the tool for upload a series of folders and files?
    For example, I have a well-performed folders in localmachine like a company structure.
    I want to upload these files in a short time,and the structure in UCM and localmachine are the same.
    Do you know what I mean?
    If you know if there are maded tools exist,please tell me.
    I'm appreciate for your help.
    Thank you!

    Edited by: Zhuanfeng on 2012-11-19 上午4:35
  • 8. Re: How to Create a New Folder in UCM with API?
    jiri.machotka Guru
    Currently Being Moderated
    By the way,do you know if the UCM has the tool for upload a series of folders and files?
    Provided that your local machine is Windows, then, yes, absolutely. Take a look at Desktop Integration Suite: http://docs.oracle.com/cd/E23943_01/doc.1111/e10624/toc.htm

    It is based on WebDAV, so any WebDAV client should be able to upload files as well.
  • 9. Re: How to Create a New Folder in UCM with API?
    954977 Newbie
    Currently Being Moderated
    Thank you for your help.
  • 10. Re: How to Create a New Folder in UCM with API?
    user434745 Newbie
    Currently Being Moderated
    There is a trick that will let you create new folders (with or without content) using just CHECKIN_UNIVERSAL.

    For a nice bribe, I'll let you in on it ;)



    (Or you can use Fiddler to check out what DIS does and figure it out yourself!)

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points