private void checkScriptDeployment(Set<DesignDeployment> deploymentsToUpdate, DesignSyncStatus currentDeployments, ModuleFile file) throws InstantiationException, IllegalAccessException, IOException, WGDesignSyncException {
String fileName = file.getFile().getName().getBaseName().toLowerCase();
String fileSuffix = "." + file.getFile().getName().getExtension();
ScriptInformation info = DesignDirectory.getScriptInformationBySuffix(fileSuffix);
if (info == null && !fileName.endsWith(DesignDirectory.SUFFIX_METADATA)) {
// Won't process files of unknown suffix
return;
}
// Filter out scripts that could collide with metadata module names
if (info != null && info.getType().equals(WGCSSJSModule.CODETYPE_XML)) {
if (fileName.startsWith(WGCSSJSModule.METADATA_MODULE_QUALIFIER)) {
return;
}
}
// Determine designName and see if there is an deployment
String designDocumentKey = WGDesignDocument.buildDesignDocumentKey(WGDocument.TYPE_CSSJS, file.getModuleName(), file.getCategory());
ScriptDeployment deployment = (ScriptDeployment) _syncStatus.getScriptDeployments().get(designDocumentKey);
if (deployment != null && !deployment.isDeleted()) {
currentDeployments.putDeployment(designDocumentKey, deployment);
if (deployment.isUpdated()) {
deploymentsToUpdate.add(deployment);
deployment.setWarnedAboutDuplicate(false);
}
checkForScriptDuplicate(file, info, deployment);
}
else {
// We won't create an new deployment for a metadata file only. A code file must be present
if (info == null) {
return;
}
// Create a new deployment
deployment = new ScriptDeployment(_syncStatus, designDocumentKey, file.getFile(), info.getType());
ScriptDeployment oldDeployment = (ScriptDeployment) currentDeployments.putDeployment(designDocumentKey, deployment);
if (oldDeployment != null) {
checkForScriptDuplicate(file, info, oldDeployment);
}
deploymentsToUpdate.add(deployment);