Unsolved
This post is more than 5 years old
19 Posts
0
2486
Versioning in Atmos - Working now
We were trying to make use of Atmos versioning feature to retrieve the older versions of a file that is stored in Atmos cloud. However the functionality did not work and made us digg through the code to find a solution. Hope this helps someone who wants to do the same!
In the root folder emc library (for java ) root folder, go to the file
\api\src\com\emc\esu\api\rest\EsuRestApi.java
In that find the following function ( line 2336 ) .
private List parseObjectList( byte[] response ) ;
In this function they get the root element as object and then iterate the child using ObjectId but for versioning, the service returns only ObjectId. As the above function is called by some other function, we wrote our own versioning fuction.
We called our custom function below at EsuRestApi.java and we could get the versioning information now.
/**
* Parses an XML response and extracts the list of ObjectIDs rewritten for listversion.
* @param response the response byte array to parse as XML
* @return the list of object IDs contained in the response.
*/
@SuppressWarnings("unchecked")
private List parseObjectIdList( byte[] response ) {
List objs = new ArrayList ();
// Use JDOM to parse the XML
SAXBuilder sb = new SAXBuilder();
try {
Document d = sb.build( new ByteArrayInputStream( response ) );
// The ObjectID element is part of a namespace so we need to use
// the namespace to identify the elements.
Namespace esuNs = Namespace.getNamespace( "http://www.emc.com/cos/" );
List children = d.getRootElement().getChildren( "ObjectID", esuNs );
l4j.debug( "Found " + children.size() + " objects" );
for( Iterator i=children.iterator(); i.hasNext(); ) {
Object o = i.next();
if( o instanceof Element ) {
Element objectIdElement = (Element)o;
ObjectId oid = new ObjectId( objectIdElement.getText() );
l4j.debug( oid.toString() );
objs.add( oid );
} else {
l4j.debug( o + " is not an Element!" );
}
}
} catch (JDOMException e) {
throw new EsuException( "Error parsing response", e );
} catch (IOException e) {
throw new EsuException( "Error reading response", e );
}
return objs;
}
Janakan Rajendran
InfraSage