added metadata check for accounting: lastUser,lastAccess, lastOperation

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/content-management/storage-manager-trigger@93439 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
roberto.cirillo 2014-03-21 15:50:43 +00:00
parent f022f34a35
commit d8f0b32fc5
1 changed files with 24 additions and 13 deletions

View File

@ -20,6 +20,7 @@ import com.mongodb.DBObject;
public class JsonParser extends Thread{
final static Logger logger=LoggerFactory.getLogger(JsonParser.class);
final static int MINUTE_DECREMENT=-2;
private CubbyHole c;
private int number;
private Report report;
@ -51,30 +52,40 @@ public class JsonParser extends Thread{
String name=(String) obj.get("name");
String owner=(String) obj.get("owner");
String creationTime=(String) obj.get("creationTime");
String lastReadTime=null;
if(obj.get("lastRead") != null) lastReadTime=(String)obj.get("lastRead");
logger.debug("last Read field: "+lastReadTime);
String lastAccess=null;
// logger.info("obj.get(lastAccess) "+obj.get("lastAccess"));
if(obj.get("lastAccess") != null) lastAccess=(String)obj.get("lastAccess");
// logger.info("last Access field: "+lastAccess);
String lastOperation=null;
// logger.info("obj.get(lastAccess) "+obj.get("lastOperation"));
if(obj.get("lastOperation") != null) lastOperation=(String)obj.get("lastOperation");
// logger.info("last OPERATION field: "+lastOperation);
String lastUser=null;
// logger.info("obj.get(lastUser) "+obj.get("lastUser"));
if(obj.get("lastUser") != null) lastUser=(String)obj.get("lastUser");
// logger.info("last USER field: "+lastUser);
String delete=null;
logger.debug("obj.get(OnDeleting) "+obj.get("onDeleting"));
// logger.info("obj.get(OnDeleting) "+obj.get("onDeleting"));
if(obj.get("onDeleting") != null) delete=(String)obj.get("onDeleting");
logger.debug("delete field: "+delete);
// logger.info("delete field: "+delete);
ObjectId objectId=(ObjectId)obj.get("_id");
String id = objectId.toString();
long length=-1;
if(obj.get("length")!=null) length=(long)obj.get("length");
logger.debug("[recordCheck] operation: "+op+" name: "+name+" type: "+type+" path: "+filename+" length: "+length+" owner: "+owner+ " id: "+id);
logger.info("[recordCheck] operation: "+op+" name: "+name+" type: "+type+" path: "+filename+" length: "+length+" owner: "+owner+"\n\t cretionTime: "+creationTime+ " id: "+id+" lastOperation "+lastOperation+" lastUser: "+lastUser+" lastAccess: "+lastAccess);
if(((length >0) && (filename!=null))){
//call to the accounting library
String scope=retrieveScopeFromRemoteFilePath(filename);
String operation=null;
try {
operation=mappingOperationField(op, id, delete, lastReadTime);
} catch (ParseException e) {
e.printStackTrace();
}
if(delete!=null){
operation="DELETE";
}else{
operation=lastOperation;
}
// operation=mappingOperationField(op, id, delete, lastAccess);
// report(op, filename, owner, creationTime, delete, id, length,scope, operation);
logger.info(" operation accounted "+operation);
logger.info("[accountingCall] operation: "+op+" name: "+name+" type: "+type+" path: "+filename+" length: "+length+" owner: "+owner+" id: "+id+" scope: "+scope);
logger.info("\n[accountingCall] operation: "+operation+"\n\t name: "+name+"\n\t type: "+type+"\n\t path: "+filename+"\n\t length: "+length+"\n\t owner: "+owner+"\n\t cretionTime: "+creationTime+"\n\t id: "+id+"\n\t scope: "+scope+"\n\t lastOperation "+lastOperation+"\n\t lastUser: "+lastUser+"\n\t lastAccess: "+lastAccess);
// }else if(op.equals("i")){
// previousInsert=id;
}else{
@ -107,7 +118,7 @@ public class JsonParser extends Thread{
// calendarLastRead.set(Calendar.MINUTE, -5);
Calendar now=Calendar.getInstance();
logger.info("now: "+sdf.format(now.getTime()));
now.add(Calendar.MINUTE, -5);
now.add(Calendar.MINUTE, MINUTE_DECREMENT);
// logger.info("now decreased -5 min: "+sdf.format(dateNow));
// logger.info("lastRead is "+sdf.format(dateLastRead)+" now,5 min decreased is"+sdf.format(dateNow));
logger.info("now decreased -5 min: "+sdf.format(now.getTime()));