summaryrefslogtreecommitdiff
path: root/source/com/c2kernel/entity/agent/ActiveEntity.java
diff options
context:
space:
mode:
authorabranson <andrew.branson@cern.ch>2011-08-04 00:42:34 +0200
committerabranson <andrew.branson@cern.ch>2011-08-04 00:42:34 +0200
commit0ec8481c10cd8277d84c7c1a785483a0a739e5a0 (patch)
tree5f6e5d9ae75193e67e6f3b3dfa488960c5cde1d5 /source/com/c2kernel/entity/agent/ActiveEntity.java
parent036cbdba66f804743c4c838ed598d6972c4b3e17 (diff)
More code cleanup:
Refactored Entity Proxy Subscription to handle generics better Rewrote RemoteMap to use TreeMap instead of the internal array for order. It now sorts its keys by number if they parse, else as strings. Removed a no-longer-in-progress outcome form class
Diffstat (limited to 'source/com/c2kernel/entity/agent/ActiveEntity.java')
-rw-r--r--[-rwxr-xr-x]source/com/c2kernel/entity/agent/ActiveEntity.java76
1 files changed, 45 insertions, 31 deletions
diff --git a/source/com/c2kernel/entity/agent/ActiveEntity.java b/source/com/c2kernel/entity/agent/ActiveEntity.java
index cb77bbb..3d45e35 100755..100644
--- a/source/com/c2kernel/entity/agent/ActiveEntity.java
+++ b/source/com/c2kernel/entity/agent/ActiveEntity.java
@@ -12,7 +12,12 @@ package com.c2kernel.entity.agent;
import java.util.Iterator;
-import com.c2kernel.common.*;
+import com.c2kernel.common.AccessRightsException;
+import com.c2kernel.common.CannotManageException;
+import com.c2kernel.common.InvalidDataException;
+import com.c2kernel.common.ObjectCannotBeUpdated;
+import com.c2kernel.common.ObjectNotFoundException;
+import com.c2kernel.common.PersistencyException;
import com.c2kernel.entity.AgentPOA;
import com.c2kernel.entity.C2KLocalObject;
import com.c2kernel.lookup.AgentPath;
@@ -21,6 +26,7 @@ import com.c2kernel.lookup.RolePath;
import com.c2kernel.persistency.ClusterStorageException;
import com.c2kernel.persistency.TransactionManager;
import com.c2kernel.process.Gateway;
+import com.c2kernel.property.Property;
import com.c2kernel.property.PropertyArrayList;
import com.c2kernel.utils.CastorXMLUtility;
import com.c2kernel.utils.Logger;
@@ -48,13 +54,13 @@ public class ActiveEntity extends AgentPOA
* Connection to the persistency backeng
**************************************************************************/
private TransactionManager mDatabase = null;
-
+
/**************************************************************************
- * The agent's joblist
+ * The agent's joblist
**************************************************************************/
private JobList currentJobs;
/**
- *
+ *
* @param key
* @param poa
*/
@@ -73,7 +79,8 @@ public class ActiveEntity extends AgentPOA
/**
* initialise cristal2 properties & collector
*/
- public void initialise( String agentProps )
+ @Override
+ public void initialise( String agentProps )
throws AccessRightsException,
InvalidDataException,
PersistencyException
@@ -99,7 +106,7 @@ public class ActiveEntity extends AgentPOA
}
/**
- *
+ *
* @param propsString
* @return Properties
* @throws InvalidDataException Properties cannot be unmarshalled
@@ -112,7 +119,7 @@ public class ActiveEntity extends AgentPOA
PropertyArrayList props = null;
// create properties
- if( !propsString.equals("") && propsString != null )
+ if( propsString != null && !propsString.equals("") )
{
try
{
@@ -126,10 +133,10 @@ public class ActiveEntity extends AgentPOA
throw new InvalidDataException(ex.toString(), null);
}
- Iterator iter = props.list.iterator();
+ Iterator<Property> iter = props.list.iterator();
while( iter.hasNext() )
- mDatabase.put( mSystemKey, (C2KLocalObject)iter.next(), props );
+ mDatabase.put( mSystemKey, iter.next(), props );
}
else
{
@@ -138,12 +145,13 @@ public class ActiveEntity extends AgentPOA
return props;
}
-
+
/**************************************************************************
*
*
**************************************************************************/
- public org.omg.PortableServer.POA _default_POA()
+ @Override
+ public org.omg.PortableServer.POA _default_POA()
{
if(mPOA != null)
return mPOA;
@@ -156,7 +164,8 @@ public class ActiveEntity extends AgentPOA
*
*
**************************************************************************/
- public int getSystemKey()
+ @Override
+ public int getSystemKey()
{
return mSystemKey;
}
@@ -166,7 +175,8 @@ public class ActiveEntity extends AgentPOA
*
*
**************************************************************************/
- public String queryData(String xpath)
+ @Override
+ public String queryData(String xpath)
throws AccessRightsException,
ObjectNotFoundException,
PersistencyException
@@ -203,7 +213,7 @@ public class ActiveEntity extends AgentPOA
}
catch (ObjectNotFoundException ex) {
throw ex;
- }
+ }
catch(Throwable ex)
{
Logger.error("ActiveEntity::queryData("+mSystemKey+") - " +
@@ -218,37 +228,39 @@ public class ActiveEntity extends AgentPOA
}
-
+
/**
* Called by an activity when it reckons we need to update our joblist for it
*/
-
- public synchronized void refreshJobList(int sysKey, String stepPath, String newJobs) {
+
+ @Override
+ public synchronized void refreshJobList(int sysKey, String stepPath, String newJobs) {
try {
JobArrayList newJobList = (JobArrayList)CastorXMLUtility.unmarshall(newJobs);
-
+
// get our joblist
if (currentJobs == null)
currentJobs = new JobList( mSystemKey, null);
-
+
// remove old jobs for this item
currentJobs.removeJobsForStep( sysKey, stepPath );
-
+
// merge new jobs in
- for (Iterator iter = newJobList.list.iterator(); iter.hasNext();) {
- Job newJob = (Job)iter.next();
+ for (Object name : newJobList.list) {
+ Job newJob = (Job)name;
Logger.msg(6, "Adding job for "+newJob.getItemSysKey()+"/"+newJob.getStepPath()+":"+newJob.getPossibleTransition());
currentJobs.addJob(newJob);
}
-
+
} catch (Throwable ex) {
Logger.error("Could not refresh job list.");
- Logger.error(ex);
+ Logger.error(ex);
}
-
+
}
-
- public void addRole(String roleName) throws CannotManageException, ObjectNotFoundException {
+
+ @Override
+ public void addRole(String roleName) throws CannotManageException, ObjectNotFoundException {
RolePath newRole = Gateway.getLDAPLookup().getRoleManager().getRolePath(roleName);
try {
newRole.addAgent(new AgentPath(mSystemKey));
@@ -258,11 +270,12 @@ public class ActiveEntity extends AgentPOA
throw new CannotManageException("Could not update role");
}
}
-
- public void removeRole(String roleName) throws CannotManageException, ObjectNotFoundException {
+
+ @Override
+ public void removeRole(String roleName) throws CannotManageException, ObjectNotFoundException {
RolePath rolePath = Gateway.getLDAPLookup().getRoleManager().getRolePath(roleName);
try {
- rolePath.removeAgent(new AgentPath(mSystemKey));
+ rolePath.removeAgent(new AgentPath(mSystemKey));
} catch (InvalidEntityPathException e) {
throw new CannotManageException("Invalid syskey for agent: "+mSystemKey, "");
} catch (ObjectCannotBeUpdated ex) {
@@ -272,7 +285,8 @@ public class ActiveEntity extends AgentPOA
/**
*
*/
- protected void finalize() throws Throwable {
+ @Override
+ protected void finalize() throws Throwable {
Logger.msg(7, "Agent "+mSystemKey+" reaped");
Gateway.getStorage().clearCache(mSystemKey, null);
super.finalize();