in framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/ManifoldCF.java [218:513]
public static void unregisterAllConnectors(IThreadContext tc, Connectors c)
throws ManifoldCFException
{
// Create a map of class name and description, so we can compare what we can find
// against what we want.
Map<String,String> desiredOutputConnectors = new HashMap<String,String>();
Map<String,String> desiredTransformationConnectors = new HashMap<String,String>();
Map<String,String> desiredMappingConnectors = new HashMap<String,String>();
Map<String,String> desiredAuthorityConnectors = new HashMap<String,String>();
Map<String,String> desiredNotificationConnectors = new HashMap<String,String>();
Map<String,String> desiredRepositoryConnectors = new HashMap<String,String>();
Map<String,String> desiredDomains = new HashMap<String,String>();
if (c != null)
{
for (int i = 0; i < c.getChildCount(); i++)
{
ConfigurationNode cn = c.findChild(i);
if (cn.getType().equals(NODE_AUTHORIZATIONDOMAIN))
{
String domainName = cn.getAttributeValue(ATTRIBUTE_DOMAIN);
String name = cn.getAttributeValue(ATTRIBUTE_NAME);
desiredDomains.put(domainName,name);
}
else if (cn.getType().equals(NODE_OUTPUTCONNECTOR))
{
String name = cn.getAttributeValue(ATTRIBUTE_NAME);
String className = cn.getAttributeValue(ATTRIBUTE_CLASS);
desiredOutputConnectors.put(className,name);
}
else if (cn.getType().equals(NODE_TRANSFORMATIONCONNECTOR))
{
String name = cn.getAttributeValue(ATTRIBUTE_NAME);
String className = cn.getAttributeValue(ATTRIBUTE_CLASS);
desiredTransformationConnectors.put(className,name);
}
else if (cn.getType().equals(NODE_MAPPINGCONNECTOR))
{
String name = cn.getAttributeValue(ATTRIBUTE_NAME);
String className = cn.getAttributeValue(ATTRIBUTE_CLASS);
desiredMappingConnectors.put(className,name);
}
else if (cn.getType().equals(NODE_AUTHORITYCONNECTOR))
{
String name = cn.getAttributeValue(ATTRIBUTE_NAME);
String className = cn.getAttributeValue(ATTRIBUTE_CLASS);
desiredAuthorityConnectors.put(className,name);
}
else if (cn.getType().equals(NODE_NOTIFICATIONCONNECTOR))
{
String name = cn.getAttributeValue(ATTRIBUTE_NAME);
String className = cn.getAttributeValue(ATTRIBUTE_CLASS);
desiredNotificationConnectors.put(className,name);
}
else if (cn.getType().equals(NODE_REPOSITORYCONNECTOR))
{
String name = cn.getAttributeValue(ATTRIBUTE_NAME);
String className = cn.getAttributeValue(ATTRIBUTE_CLASS);
desiredRepositoryConnectors.put(className,name);
}
}
}
// Grab a database handle, so we can use transactions later.
IDBInterface database = DBInterfaceFactory.make(tc,
ManifoldCF.getMasterDatabaseName(),
ManifoldCF.getMasterDatabaseUsername(),
ManifoldCF.getMasterDatabasePassword());
// Domains...
{
IAuthorizationDomainManager mgr = AuthorizationDomainManagerFactory.make(tc);
IResultSet domains = mgr.getDomains();
for (int i = 0; i < domains.getRowCount(); i++)
{
IResultRow row = domains.getRow(i);
String domainName = (String)row.getValue("domainname");
String description = (String)row.getValue("description");
if (desiredDomains.get(domainName) == null || !desiredDomains.get(domainName).equals(description))
{
mgr.unregisterDomain(domainName);
}
}
System.err.println("Successfully unregistered all domains");
}
// Output connectors...
{
IOutputConnectorManager mgr = OutputConnectorManagerFactory.make(tc);
IOutputConnectionManager connManager = OutputConnectionManagerFactory.make(tc);
IResultSet classNames = mgr.getConnectors();
int i = 0;
while (i < classNames.getRowCount())
{
IResultRow row = classNames.getRow(i++);
String className = (String)row.getValue("classname");
String description = (String)row.getValue("description");
if (desiredOutputConnectors.get(className) == null || !desiredOutputConnectors.get(className).equals(description))
{
// Deregistration should be done in a transaction
database.beginTransaction();
try
{
// Find the connection names that come with this class
String[] connectionNames = connManager.findConnectionsForConnector(className);
// For all connection names, notify all agents of the deregistration
AgentManagerFactory.noteOutputConnectorDeregistration(tc,connectionNames);
// Now that all jobs have been placed into an appropriate state, actually do the deregistration itself.
mgr.unregisterConnector(className);
}
catch (ManifoldCFException e)
{
database.signalRollback();
throw e;
}
catch (Error e)
{
database.signalRollback();
throw e;
}
finally
{
database.endTransaction();
}
}
}
System.err.println("Successfully unregistered all output connectors");
}
// Output connectors...
{
ITransformationConnectorManager mgr = TransformationConnectorManagerFactory.make(tc);
ITransformationConnectionManager connManager = TransformationConnectionManagerFactory.make(tc);
IResultSet classNames = mgr.getConnectors();
int i = 0;
while (i < classNames.getRowCount())
{
IResultRow row = classNames.getRow(i++);
String className = (String)row.getValue("classname");
String description = (String)row.getValue("description");
if (desiredTransformationConnectors.get(className) == null || !desiredTransformationConnectors.get(className).equals(description))
{
// Deregistration should be done in a transaction
database.beginTransaction();
try
{
// Find the connection names that come with this class
String[] connectionNames = connManager.findConnectionsForConnector(className);
// For all connection names, notify all agents of the deregistration
AgentManagerFactory.noteTransformationConnectorDeregistration(tc,connectionNames);
// Now that all jobs have been placed into an appropriate state, actually do the deregistration itself.
mgr.unregisterConnector(className);
}
catch (ManifoldCFException e)
{
database.signalRollback();
throw e;
}
catch (Error e)
{
database.signalRollback();
throw e;
}
finally
{
database.endTransaction();
}
}
}
System.err.println("Successfully unregistered all transformation connectors");
}
// Mapping connectors...
{
IMappingConnectorManager mgr = MappingConnectorManagerFactory.make(tc);
IResultSet classNames = mgr.getConnectors();
int i = 0;
while (i < classNames.getRowCount())
{
IResultRow row = classNames.getRow(i++);
String className = (String)row.getValue("classname");
String description = (String)row.getValue("description");
if (desiredMappingConnectors.get(className) == null || !desiredMappingConnectors.get(className).equals(description))
{
mgr.unregisterConnector(className);
}
}
System.err.println("Successfully unregistered all mapping connectors");
}
// Authority connectors...
{
IAuthorityConnectorManager mgr = AuthorityConnectorManagerFactory.make(tc);
IResultSet classNames = mgr.getConnectors();
int i = 0;
while (i < classNames.getRowCount())
{
IResultRow row = classNames.getRow(i++);
String className = (String)row.getValue("classname");
String description = (String)row.getValue("description");
if (desiredAuthorityConnectors.get(className) == null || !desiredAuthorityConnectors.get(className).equals(description))
{
mgr.unregisterConnector(className);
}
}
System.err.println("Successfully unregistered all authority connectors");
}
// Notification connectors...
{
INotificationConnectorManager mgr = NotificationConnectorManagerFactory.make(tc);
IJobManager jobManager = JobManagerFactory.make(tc);
INotificationConnectionManager connManager = NotificationConnectionManagerFactory.make(tc);
IResultSet classNames = mgr.getConnectors();
int i = 0;
while (i < classNames.getRowCount())
{
IResultRow row = classNames.getRow(i++);
String className = (String)row.getValue("classname");
String description = (String)row.getValue("description");
if (desiredNotificationConnectors.get(className) == null || !desiredNotificationConnectors.get(className).equals(description))
{
// Deregistration should be done in a transaction
database.beginTransaction();
try
{
// Find the connection names that come with this class
String[] connectionNames = connManager.findConnectionsForConnector(className);
// For each connection name, modify the jobs to note that the connector is no longer installed
jobManager.noteNotificationConnectorDeregistration(connectionNames);
// Now that all jobs have been placed into an appropriate state, actually do the deregistration itself.
mgr.unregisterConnector(className);
}
catch (ManifoldCFException e)
{
database.signalRollback();
throw e;
}
catch (Error e)
{
database.signalRollback();
throw e;
}
finally
{
database.endTransaction();
}
}
}
}
// Repository connectors...
{
IConnectorManager mgr = ConnectorManagerFactory.make(tc);
IJobManager jobManager = JobManagerFactory.make(tc);
IRepositoryConnectionManager connManager = RepositoryConnectionManagerFactory.make(tc);
IResultSet classNames = mgr.getConnectors();
int i = 0;
while (i < classNames.getRowCount())
{
IResultRow row = classNames.getRow(i++);
String className = (String)row.getValue("classname");
String description = (String)row.getValue("description");
if (desiredRepositoryConnectors.get(className) == null || !desiredRepositoryConnectors.get(className).equals(description))
{
// Deregistration should be done in a transaction
database.beginTransaction();
try
{
// Find the connection names that come with this class
String[] connectionNames = connManager.findConnectionsForConnector(className);
// For each connection name, modify the jobs to note that the connector is no longer installed
jobManager.noteConnectorDeregistration(connectionNames);
// Now that all jobs have been placed into an appropriate state, actually do the deregistration itself.
mgr.unregisterConnector(className);
}
catch (ManifoldCFException e)
{
database.signalRollback();
throw e;
}
catch (Error e)
{
database.signalRollback();
throw e;
}
finally
{
database.endTransaction();
}
}
}
System.err.println("Successfully unregistered all repository connectors");
}
}