Start a Conversation

Unsolved

This post is more than 5 years old

3193

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

212 Posts

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

18 Posts

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

212 Posts

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

18 Posts

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

No Events found!

Top