String clbXMLFile = clbXMLFileNames[0];
String oldXMLFileName = clbXMLFileNames[1];
// connects to DAS
String dasName = SystemPropertyConstants.DEFAULT_SERVER_INSTANCE_NAME;
SynchronizationClientImpl sc = new SynchronizationClientImpl(dasName);
_logger.log(Level.INFO,
"clb.admin.StartSyncCLB",
new Object[]{clbXMLFile, dasName});
try {
sc.connect();
_logger.log(Level.FINEST,
"clb.admin.ConnectedToDAS" );
} catch (IOException ie) {
throw new SynchronizationException("Connection to SynchronizationClientImpl failed. IOException occured while trying to connect " + ie.getMessage());
}
String instanceRoot = System.getProperty(SystemPropertyConstants.INSTANCE_ROOT_PROPERTY);
String configName = getConfigName(e, serverName);
String clbTargetLocation = instanceRoot + File.separator + CONFIG + File.separator + configName;
//Added as a workaround for scenario when config-dir does not exist
//under instance config
final File clbTargetDir = new File(clbTargetLocation);
if (!clbTargetDir.exists()) {
try {
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
clbTargetDir.mkdir();
return null;
}
});
} catch (SecurityException ex) {
throw new SynchronizationException(
"Unable to create directory " + clbTargetLocation, ex);
}
}
if(oldXMLFileName !=null)
{
try {
boolean value = false;
File myDir = new File(clbTargetLocation);
// Define a filter for clb xml files
if (clbXMLFile.indexOf(".v") != -1) {
String clbFile = clbXMLFile.substring(0,clbXMLFile.indexOf(".v"));
FilenameFilter select = new FileListFilter(clbFile);
File[] contents = myDir.listFiles(select);
for (int i=0; i < contents.length; i++) {
_logger.log(Level.FINE,
"clb.admin.DeleteCLB", contents[i].getName());
value = contents[i].delete();
if (value == false)
_logger.log(Level.WARNING, "clb.admin.UnableToDelete", contents[i].getName());
}
}
}catch(SecurityException se){
_logger.log(Level.WARNING, "clb.admin.UnableToDeleteWErr", new String[]{oldXMLFileName, se.getMessage()});
}
}
_logger.log(Level.FINEST,
"clb.admin.FechingFile", new String[]{clbXMLFile, clbTargetLocation} );
sc.get(CONFIG + File.separator + configName + File.separator + clbXMLFile, clbTargetLocation + File.separator + clbXMLFile);
_logger.log(Level.FINE,
"clb.admin.SyncCLBSucessful", clbXMLFile);
try {
sc.disconnect();
} catch (IOException ie) {
_logger.log(Level.FINE, "Unable to close connection to DAS : " + ie.toString());
}