final private static LocalStringManagerImpl localStrings = new LocalStringManagerImpl(RemoveLibraryCommand.class);
public void execute(AdminCommandContext context) {
final ActionReport report = context.getActionReport();
final Logger logger = context.getLogger();
File libDir = env.getLibPath();
if (type.equals("ext")) {
libDir = new File(libDir, "ext");
} else if (type.equals("app")) {
libDir = new File(libDir, "applibs");
}
try {
List<UnprocessedChangeEvent> unprocessed =
new ArrayList<UnprocessedChangeEvent>();
// delete the file from the appropriate library directory
StringBuffer msg = new StringBuffer();
for (String libraryName : names) {
File libraryFile = new File(libDir, libraryName);
if (libraryFile.exists()) {
FileUtils.deleteFile(libraryFile);
PropertyChangeEvent pe = new PropertyChangeEvent(libDir,
"remove-library", libraryFile, null);
UnprocessedChangeEvent uce = new UnprocessedChangeEvent(
pe, "remove-library");
unprocessed.add(uce);
} else {
msg.append(localStrings.getLocalString("lfnf","Library file not found", libraryFile.getAbsolutePath()));
}
}
if (msg.length() > 0) {
logger.log(Level.WARNING, msg.toString());
report.setActionExitCode(ActionReport.ExitCode.WARNING);
report.setMessage(msg.toString());
}
// set the restart required flag
UnprocessedChangeEvents uces = new UnprocessedChangeEvents(
unprocessed);
List<UnprocessedChangeEvents> ucesList =
new ArrayList<UnprocessedChangeEvents>();
ucesList.add(uces);
ucl.unprocessedTransactedEvents(ucesList);
// touch the domain.xml so instances restart will synch
// over the libraries.
dxp.touch();
} catch (Exception e) {
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
report.setMessage(e.getMessage());
}
}