final public <T extends RootPersistentEntity>long putResource(String resPath,T obj,long newTS,Serializer<T> serializer) throws IOException {
  resPath=norm(resPath);
  long oldTS=obj.getLastModified();
  obj.setLastModified(newTS);
  try {
    ByteArrayOutputStream buf=new ByteArrayOutputStream();
    DataOutputStream dout=new DataOutputStream(buf);
    serializer.serialize(obj,dout);
    dout.close();
    buf.close();
    newTS=checkAndPutResourceImpl(resPath,buf.toByteArray(),oldTS,newTS);
    obj.setLastModified(newTS);
    return newTS;
  }
 catch (  IOException e) {
    obj.setLastModified(oldTS);
    throw e;
  }
catch (  RuntimeException e) {
    obj.setLastModified(oldTS);
    throw e;
  }
}

final public < T extends RootPersistentEntity > long putResource ( String resPath , T obj , long newTS , Serializer < T > serializer ) throws IOException { resPath = norm ( resPath ) ; long oldTS = obj . getLastModified ( ) ; obj . setLastModified ( newTS ) ; try { ByteArrayOutputStream buf = new ByteArrayOutputStream ( ) ; DataOutputStream dout = new DataOutputStream ( buf ) ; serializer . serialize ( obj , dout ) ; dout . close ( ) ; buf . close ( ) ; newTS = checkAndPutResourceImpl ( resPath , buf . toByteArray ( ) , oldTS , newTS ) ; obj . setLastModified ( newTS ) ; return newTS ; } catch ( IOException e ) { obj . setLastModified ( oldTS ) ; throw e ; } catch ( RuntimeException e ) { obj . setLastModified ( oldTS ) ; throw e ; } }
check & set , overwrite a resource
