UNSOLVED

thornj1

updated

16 years ago

T

thornj1

18 Posts

0

3342

July 6th, 2010 12:00

Create a Directory with Atmos JAVA API

I'm sure this is a simple task.  What method should be used for creating directory objects on a path?

Jason Thornbrugh
Principal Solutions Engineer
GSC Demo Cloud

  • aashishpatil

    2 Intern

    •

    212 Posts

    768

    0

    Posted July 8th, 2010 11:00

    Hi Jason,

    You can use the EsuApi.createObjectOnPath(...) method to do this. To create a directory make sure that the ObjectPath ends with a '/' otherwise the path is interpreted to be for an object and not namespace

    Here is some code in the NewDirectoryAction.java file of the Atmos Object Browser

    http://codesearch.developer.emc.com/kse/entcodespaces/AJcBNg

    Thanks,

    Aashish

  • thornj1

    18 Posts

    768

    0

    Posted July 8th, 2010 12:00

    Thanks, I'll have to look at the example when I have some time. I was

    getting a null exception when calling createObjectOnPath in the

    following code.

    private static String mkdir(String imageDirName,String

    pathName) {

    String objID = "";

    try {

    UploadHelper uploadHelper = new

    UploadHelper(esuAPI);

    ObjectId oId =

    uploadHelper.createObjectOnPath(new ObjectPath(pathName+imageDirName),

    null, null, null);

    objID = oId.toString();

    } catch (Throwable e) {

    System.err.println(e);

    }

    return objID;

    }

    Jason Thornbrugh

    Principal Solutions Engineer

    GSC Demo Cloud

  • aashishpatil

    2 Intern

    •

    212 Posts

    768

    0

    Posted July 8th, 2010 12:00

    Make sure your path starts with a Œ/¹, uses Œ/¹ as the path separator and

    finally ends with a Œ/¹

    E.g. /myfolders/somefolder/somesubfolder/

    Aashish

  • thornj1

    18 Posts

    768

    0

    Posted July 8th, 2010 13:00

    I found the problem.  I noticed in the sample code that the createObjectOnPath() method takes 5 parameters.  In my code, the createObjectOnPath() method only accepts 4 parameters.  I discovered that both the EsuApi and EsuRestApi declare this method.  I was using the wrong one (via UploadHelper).

    private static String mkdir(String dirName) {
         String objID = "";
         try {
              //UploadHelper uploadHelper = new UploadHelper(esuAPI);

              EsuRestApi esuAPI = new EsuRestApi(HOST, PORT, FULLTOKENID, SECRETKEY);

              //ObjectId oId = uploadHelper.createObjectOnPath(new ObjectPath(pathName+imageDirName), null, null, null);

              ObjectId oId = esuAPI.createObjectOnPath(new ObjectPath(dirName), null, null, null, null);

              objID = oId.toString();
              System.out.println(objID);
         } catch (Throwable e) {
              System.err.println(e);
         }
         return objID;
    }

    Thanks for the input.

    Jason Thornbrugh
    Principal Solutions Engineer
    GSC Demo Cloud