*/
private void printPageInstall1(HttpServletResponse response, HttpServletRequest request,
VariablesSecureApp vars, String recordId, boolean islocal, InputStream obx,
String[] updateModules) throws IOException, ServletException {
final String discard[] = { "", "", "", "", "", "" };
Module module = null;
// Remote installation is only allowed for heartbeat enabled instances
if (!islocal && !isHeartbeatEnabled()) {
response.sendRedirect(strDireccion
+ "/ad_forms/Heartbeat.html?Command=DEFAULT_MODULE&inpcRecordId=" + recordId);
}
if (!islocal && (updateModules == null || updateModules.length == 0)) {
// if it is a remote installation get the module from webservice,
// other case the obx file is passed as an InputStream
try {
final WebServiceImplServiceLocator loc = new WebServiceImplServiceLocator();
final WebServiceImpl ws = loc.getWebService();
module = ws.moduleDetail(recordId);
} catch (final Exception e) {
log4j.error(e);
}
} else {
discard[4] = "core";
}
Module[] inst = null;
Module[] upd = null;
OBError message = null;
boolean found = false;
boolean check;
VersionUtility.setPool(this);
// Craete a new ImportModule instance which will be used to check
// depencecies and to process the installation
final ImportModule im = new ImportModule(this, vars.getSessionValue("#sourcePath"), vars);
im.setInstallLocal(islocal);
try {
// check the dependenies and obtain the modules to install/update
if (!islocal) {
final String[] installableModules = { module != null ? module.getModuleVersionID() : "" };
check = im.checkDependenciesId(installableModules, updateModules);
} else {
check = im.checkDependenciesFile(obx);
}
// Check commercial modules can be installed
if (check) { // dependencies are statisfied, show modules to install
// installOrig includes also the module to install
final Module[] installOrig = im.getModulesToInstall();
// check commercial modules and show error page if not allowed to install
if (!checkCommercialModules(im, response, vars)) {
return;
}
if (installOrig == null || installOrig.length == 0)
discard[0] = "modulesToinstall";
else {
if (!islocal && module != null) {
inst = new Module[installOrig.length - 1]; // to remove
// the module
// itself
// check if the version for the selected module is the
// selected one
int j = 0;
for (int i = 0; i < installOrig.length; i++) {
found = installOrig[i].getModuleID().equals(module.getModuleID());
if (found && !module.getModuleVersionID().equals(installOrig[i].getModuleVersionID())) {
message = new OBError();
message.setType("Warning");
message.setTitle(Utility.messageBD(this, message.getType(), vars.getLanguage()));
message.setMessage(module.getName()
+ " "
+ module.getVersionNo()
+ " "
+ Utility.messageBD(this, "OtherModuleVersionToinstallOrigall", vars
.getLanguage()) + " " + installOrig[i].getVersionNo());
}
if (found) {
module = installOrig[i];
} else {
inst[j] = installOrig[i];
j++;
}
}
} else {
inst = installOrig;
}
}
upd = im.getModulesToUpdate();
// after all the checks, save the ImportModule object in session
// to take it in next steps
vars.setSessionObject("InstallModule|ImportModule", im);
} else { // Dependencies not satisfied, do not show continue button
message = im.getCheckError();
discard[5] = "discardContinue";
}
if (upd == null || upd.length == 0)
discard[1] = "updateModules";
if (inst == null || inst.length == 0)
discard[2] = "installModules";
if ((upd == null || upd.length == 0) && (inst == null || inst.length == 0)
&& (module == null)) {
discard[3] = "discardAdditional";
discard[5] = "discardContinue";
}
} catch (final Exception e) {
log4j.error(e);
message = new OBError();
message.setType("Error");
message.setTitle(Utility.messageBD(this, message.getType(), vars.getLanguage()));
message.setMessage(e.toString());
}
final XmlDocument xmlDocument = xmlEngine.readXmlTemplate(
"org/openbravo/erpCommon/ad_forms/ModuleManagement_InstallP1", discard).createXmlDocument();
xmlDocument.setParameter("directory", "var baseDirectory = \"" + strReplaceWith + "/\";\n");
xmlDocument.setParameter("language", "defaultLang=\"" + vars.getLanguage() + "\";");
xmlDocument.setParameter("theme", vars.getTheme());
if (inst != null && inst.length > 0)
xmlDocument.setData("installs", FieldProviderFactory.getFieldProviderArray(inst));
if (upd != null && upd.length > 0)
xmlDocument.setData("updates", FieldProviderFactory.getFieldProviderArray(upd));
xmlDocument.setParameter("inpLocalInstall", islocal ? "Y" : "N");
if (!islocal && module != null) {
xmlDocument.setParameter("key", recordId);
xmlDocument.setParameter("moduleID", module.getModuleID());
xmlDocument.setParameter("moduleName", module.getName());
xmlDocument.setParameter("moduleVersion", module.getVersionNo());
xmlDocument.setParameter("linkCore", module.getModuleVersionID());
}
{
if (message != null) {
xmlDocument.setParameter("messageType", message.getType());
xmlDocument.setParameter("messageTitle", message.getTitle());