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:
parent
f022f34a35
commit
d8f0b32fc5
|
@ -20,6 +20,7 @@ import com.mongodb.DBObject;
|
||||||
public class JsonParser extends Thread{
|
public class JsonParser extends Thread{
|
||||||
|
|
||||||
final static Logger logger=LoggerFactory.getLogger(JsonParser.class);
|
final static Logger logger=LoggerFactory.getLogger(JsonParser.class);
|
||||||
|
final static int MINUTE_DECREMENT=-2;
|
||||||
private CubbyHole c;
|
private CubbyHole c;
|
||||||
private int number;
|
private int number;
|
||||||
private Report report;
|
private Report report;
|
||||||
|
@ -51,30 +52,40 @@ public class JsonParser extends Thread{
|
||||||
String name=(String) obj.get("name");
|
String name=(String) obj.get("name");
|
||||||
String owner=(String) obj.get("owner");
|
String owner=(String) obj.get("owner");
|
||||||
String creationTime=(String) obj.get("creationTime");
|
String creationTime=(String) obj.get("creationTime");
|
||||||
String lastReadTime=null;
|
String lastAccess=null;
|
||||||
if(obj.get("lastRead") != null) lastReadTime=(String)obj.get("lastRead");
|
// logger.info("obj.get(lastAccess) "+obj.get("lastAccess"));
|
||||||
logger.debug("last Read field: "+lastReadTime);
|
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;
|
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");
|
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");
|
ObjectId objectId=(ObjectId)obj.get("_id");
|
||||||
String id = objectId.toString();
|
String id = objectId.toString();
|
||||||
long length=-1;
|
long length=-1;
|
||||||
if(obj.get("length")!=null) length=(long)obj.get("length");
|
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))){
|
if(((length >0) && (filename!=null))){
|
||||||
//call to the accounting library
|
//call to the accounting library
|
||||||
String scope=retrieveScopeFromRemoteFilePath(filename);
|
String scope=retrieveScopeFromRemoteFilePath(filename);
|
||||||
String operation=null;
|
String operation=null;
|
||||||
try {
|
if(delete!=null){
|
||||||
operation=mappingOperationField(op, id, delete, lastReadTime);
|
operation="DELETE";
|
||||||
} catch (ParseException e) {
|
}else{
|
||||||
e.printStackTrace();
|
operation=lastOperation;
|
||||||
}
|
}
|
||||||
|
// operation=mappingOperationField(op, id, delete, lastAccess);
|
||||||
// report(op, filename, owner, creationTime, delete, id, length,scope, operation);
|
// report(op, filename, owner, creationTime, delete, id, length,scope, operation);
|
||||||
logger.info(" operation accounted "+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")){
|
// }else if(op.equals("i")){
|
||||||
// previousInsert=id;
|
// previousInsert=id;
|
||||||
}else{
|
}else{
|
||||||
|
@ -107,7 +118,7 @@ public class JsonParser extends Thread{
|
||||||
// calendarLastRead.set(Calendar.MINUTE, -5);
|
// calendarLastRead.set(Calendar.MINUTE, -5);
|
||||||
Calendar now=Calendar.getInstance();
|
Calendar now=Calendar.getInstance();
|
||||||
logger.info("now: "+sdf.format(now.getTime()));
|
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("now decreased -5 min: "+sdf.format(dateNow));
|
||||||
// logger.info("lastRead is "+sdf.format(dateLastRead)+" now,5 min decreased is"+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()));
|
logger.info("now decreased -5 min: "+sdf.format(now.getTime()));
|
||||||
|
|
Loading…
Reference in New Issue