}
}
public boolean perform(final PolicyBuilderManager manager) {
final PolicyFactory factory = PolicyFactory.getDefaultInstance();
FileEx sourceDirEx = new FileEx(sourceDirectory);
sourceDirEx.forEachDirectory(new FileExOperation() {
public void perform(File policyDir) {
try {
logger.info("processing-policy",
policyDir.getName());
// Figure out the location of the component.
String policyName = policyDir.getName() + "." +
FileExtension.IMAGE_COMPONENT.getExtension();
if (componentNamePrefix != null) {
policyName = componentNamePrefix + policyName;
}
// Create the component, if any.
VariablePolicyBuilder policyBuilder = (VariablePolicyBuilder)
manager.getPolicyBuilder(policyName);
// Check to see whether the existing container should
// be updated, or a new one created.
boolean update = (policyBuilder != null && replace);
if (policyBuilder != null) {
if (replace) {
// ... then remove it
logger.info("removing-existing", policyName);
manager.removePolicyBuilder(policyName);
} else {
// ... else all we can do is log a warning.
logger.info("found-existing-ignoring-new",
new Object[] {policyName});
}
}
if (policyBuilder == null) {
policyBuilder = factory.createVariablePolicyBuilder(
PolicyType.IMAGE);
policyBuilder.setName(policyName);
update = false;
} else {
update = true;