log.info("Deploying decorator " + id + " to " + deployPath);
JarExpander.expand(event.getDeploymentObject().getFile(), deployPathFile);
File metaInf = new File(deployPathFile, "META-INF");
if (metaInf.exists())
{
DirectoryHelper cleanup = new DirectoryHelper(metaInf);
cleanup.remove();
cleanup.close();
}
// detect language/country localized decorator components
final List localeSpecificDeployPathsList = getLocaleSpecificDeployPaths(deployPathFile);
// deploy individual locale specific decorator components
Iterator deployPathsIter = localeSpecificDeployPathsList.iterator();
while (deployPathsIter.hasNext())
{
File localeDeployPathFile = (File) deployPathsIter.next();
// deploy to locale specific location
File deployToPathFile = new File(baseDeployPath
+ localeDeployPathFile.getPath().substring(deployPath.length())
+ File.separator + id);
log.info("Deploying locale specific decorator component to " + deployToPathFile.getPath());
deployToPathFile.mkdirs();
// deploy decorator components by moving from deployed decorator
File[] filesToDeploy = localeDeployPathFile.listFiles(new FileFilter()
{
public boolean accept(File pathname)
{
return !localeSpecificDeployPathsList.contains(pathname);
}
});
for (int i = 0; (i < filesToDeploy.length); i++)
{
filesToDeploy[i].renameTo(new File(deployToPathFile, filesToDeploy[i].getName()));
}
}
// cleanup locale specific deployment directories
Iterator cleanupDeployPathsIter = localeSpecificDeployPathsList.iterator();
while (cleanupDeployPathsIter.hasNext())
{
File cleanupLocaleDeployPathFile = (File) cleanupDeployPathsIter.next();
if (cleanupLocaleDeployPathFile.exists())
{
DirectoryHelper cleanup = new DirectoryHelper(cleanupLocaleDeployPathFile);
cleanup.remove();
cleanup.close();
}
}
log.info("Decorator " + id + " deployed successfuly.");
event.setStatus(DeploymentStatus.STATUS_OKAY);