protected void clearInstallParameters(String pkgId) { getContext().getRequest().setAttribute(getStorageKey(pkgId), null); }
Form[] forms = installTask.getPackage().getInstallForms(); if (forms == null || forms.length < formId - 1) { return getView("installError").arg("e", new NuxeoException("No form with Id " + formId + " for package " + pkgId)).arg("source", source); FormData fdata = getContext().getForm(); Map<String, String> params = getInstallParameters(pkgId); for (Field field : form.getFields()) { String data = fdata.getString(field.getName()); storeInstallParameters(pkgId, params); if (formId + 1 == forms.length) { return doInstall(pkgId, source); } else { return showInstallForm(pkgId, formId + 1, source); return getView("installError").arg("e", e).arg("source", source);
@Path(value = "run/{pkgId}") public Object doInstall(@PathParam("pkgId") String pkgId, @QueryParam("source") String source) { if (!RequestHelper.isInternalLink(getContext())) { return getView("installError").arg("e", new NuxeoException("Installation seems to have been started from an external link.")).arg( "source", source); if (InstallAfterRestart.isNeededForPackage(pkg)) { InstallAfterRestart.addPackageForInstallation(pkg.getId()); return getView("installOnRestart").arg("pkg", pkg).arg("source", source); Map<String, String> params = getInstallParameters(pkgId); try { installTask.run(params); log.error("Error during installation of " + pkgId, e); installTask.rollback(); return getView("installError").arg("e", e).arg("source", source); clearInstallParameters(pkgId); return getView("installedOK").arg("installTask", installTask).arg("pkg", pkg).arg("source", source); } catch (PackageException e) { log.error("Error during installation of " + pkgId, e); return getView("installError").arg("e", e).arg("source", source);
return showTermsAndConditions(pkgId, source, depCheck); return getView("dependencyError").arg("resolution", resolution).arg("pkg", pkg).arg("source", source); } else { autoMode = true; return getView("displayDependencies").arg("resolution", resolution).arg("pkg", pkg).arg( "source", source).arg("autoMode", autoMode); return getView("canNotInstall").arg("status", status).arg("pkg", pkg).arg("source", source); needWizard = true; return getView("startInstall").arg("status", status).arg("needWizard", needWizard).arg("installTask", installTask).arg("pkg", pkg).arg("source", source); } catch (PackageException e) { log.error("Error during first step of installation", e); return getView("installError").arg("e", e).arg("source", source);
public Object doBulkInstall(@PathParam("pkgId") String pkgId, @QueryParam("source") String source, @QueryParam("confirm") Boolean confirm) { if (!RequestHelper.isInternalLink(getContext())) { return getView("installError").arg("e", new NuxeoException("Installation seems to have been started from an external link.")).arg( "source", source); return getView("installError").arg("e", new NuxeoException("Some packages need to be downloaded before running bulk installation")).arg( "source", source); Package pkg = pus.getPackage(id); if (pkg == null) { return getView("installError").arg("e", new NuxeoException("Unable to find local package " + id)).arg( "source", source); InstallAfterRestart.addPackageForInstallation(id); return getView("bulkInstallOnRestart").arg("pkgIds", pkgIds).arg("rmPkgIds", rmPkgIds).arg("source", source); } else { return getView("bulkInstallOnRestartConfirm").arg("pkgIds", pkgIds).arg("rmPkgIds", rmPkgIds).arg( "warns", warns).arg("descs", descs).arg("source", source).arg("pkgId", pkgId); return getView("installError").arg("e", e).arg("source", source);
@GET @Produces("text/html") @Path(value = "showTermsAndConditions/{pkgId}") public Object showTermsAndConditions(@PathParam("pkgId") String pkgId, @QueryParam("source") String source, @QueryParam("depCheck") Boolean depCheck) { if (depCheck == null) { depCheck = true; } try { PackageUpdateService pus = Framework.getService(PackageUpdateService.class); LocalPackage pkg = pus.getPackage(pkgId); String content = pkg.getTermsAndConditionsContent(); return getView("termsAndConditions").arg("pkg", pkg).arg("source", source).arg("content", content).arg( "depCheck", depCheck); } catch (PackageException e) { log.error("Error during terms and conditions phase ", e); return getView("installError").arg("e", e).arg("source", source); } }
Form[] forms = installTask.getPackage().getInstallForms(); if (forms == null || forms.length < formId - 1) { return getView("installError").arg("e", new NuxeoException("No form with Id " + formId + " for package " + pkgId)).arg("source", source); FormData fdata = getContext().getForm(); Map<String, String> params = getInstallParameters(pkgId); for (Field field : form.getFields()) { String data = fdata.getString(field.getName()); storeInstallParameters(pkgId, params); if (formId + 1 == forms.length) { return doInstall(pkgId, source); } else { return showInstallForm(pkgId, formId + 1, source); return getView("installError").arg("e", e).arg("source", source);
@Path(value = "run/{pkgId}") public Object doInstall(@PathParam("pkgId") String pkgId, @QueryParam("source") String source) { if (!RequestHelper.isInternalLink(getContext())) { return getView("installError").arg("e", new NuxeoException("Installation seems to have been started from an external link.")).arg( "source", source); if (InstallAfterRestart.isNeededForPackage(pkg)) { InstallAfterRestart.addPackageForInstallation(pkg.getId()); return getView("installOnRestart").arg("pkg", pkg).arg("source", source); Map<String, String> params = getInstallParameters(pkgId); try { installTask.run(params); log.error("Error during installation of " + pkgId, e); installTask.rollback(); return getView("installError").arg("e", e).arg("source", source); clearInstallParameters(pkgId); return getView("installedOK").arg("installTask", installTask).arg("pkg", pkg).arg("source", source); } catch (PackageException e) { log.error("Error during installation of " + pkgId, e); return getView("installError").arg("e", e).arg("source", source);
return showTermsAndConditions(pkgId, source, depCheck); return getView("dependencyError").arg("resolution", resolution).arg("pkg", pkg).arg("source", source); } else { autoMode = true; return getView("displayDependencies").arg("resolution", resolution).arg("pkg", pkg).arg( "source", source).arg("autoMode", autoMode); return getView("canNotInstall").arg("status", status).arg("pkg", pkg).arg("source", source); needWizard = true; return getView("startInstall").arg("status", status).arg("needWizard", needWizard).arg("installTask", installTask).arg("pkg", pkg).arg("source", source); } catch (PackageException e) { log.error("Error during first step of installation", e); return getView("installError").arg("e", e).arg("source", source);
public Object doBulkInstall(@PathParam("pkgId") String pkgId, @QueryParam("source") String source, @QueryParam("confirm") Boolean confirm) { if (!RequestHelper.isInternalLink(getContext())) { return getView("installError").arg("e", new NuxeoException("Installation seems to have been started from an external link.")).arg( "source", source); return getView("installError").arg("e", new NuxeoException("Some packages need to be downloaded before running bulk installation")).arg( "source", source); Package pkg = pus.getPackage(id); if (pkg == null) { return getView("installError").arg("e", new NuxeoException("Unable to find local package " + id)).arg( "source", source); InstallAfterRestart.addPackageForInstallation(id); return getView("bulkInstallOnRestart").arg("pkgIds", pkgIds).arg("rmPkgIds", rmPkgIds).arg("source", source); } else { return getView("bulkInstallOnRestartConfirm").arg("pkgIds", pkgIds).arg("rmPkgIds", rmPkgIds).arg( "warns", warns).arg("descs", descs).arg("source", source).arg("pkgId", pkgId); return getView("installError").arg("e", e).arg("source", source);
@GET @Produces("text/html") @Path(value = "showTermsAndConditions/{pkgId}") public Object showTermsAndConditions(@PathParam("pkgId") String pkgId, @QueryParam("source") String source, @QueryParam("depCheck") Boolean depCheck) { if (depCheck == null) { depCheck = true; } try { PackageUpdateService pus = Framework.getLocalService(PackageUpdateService.class); LocalPackage pkg = pus.getPackage(pkgId); String content = pkg.getTermsAndConditionsContent(); return getView("termsAndConditions").arg("pkg", pkg).arg("source", source).arg("content", content).arg( "depCheck", depCheck); } catch (PackageException e) { log.error("Error during terms and conditions phase ", e); return getView("installError").arg("e", e).arg("source", source); } }
@SuppressWarnings("unchecked") protected Map<String, String> getInstallParameters(String pkgId) { Map<String, String> params = (Map<String, String>) getContext().getRequest().getAttribute(getStorageKey(pkgId)); if (params == null) { params = new HashMap<>(); } return params; }
@GET @Produces("text/html") @Path(value = "form/{pkgId}/{formId}") public Object showInstallForm(@PathParam("pkgId") String pkgId, @PathParam("formId") int formId, @QueryParam("source") String source) { PackageUpdateService pus = Framework.getLocalService(PackageUpdateService.class); try { LocalPackage pkg = pus.getPackage(pkgId); Task installTask = pkg.getInstallTask(); Form[] forms = installTask.getPackage().getInstallForms(); if (forms == null || forms.length < formId - 1) { return getView("installError").arg("e", new NuxeoException("No form with Id " + formId + " for package " + pkgId)).arg("source", source); } return getView("showInstallForm").arg("form", forms[formId]).arg("pkg", pkg).arg("source", source).arg( "step", formId + 1).arg("steps", forms.length); } catch (PackageException e) { log.error("Error during displaying Form nb " + formId, e); return getView("installError").arg("e", e).arg("source", source); } }
protected void storeInstallParameters(String pkgId, Map<String, String> params) { getContext().getRequest().setAttribute(getStorageKey(pkgId), params); }
@GET @Produces("text/html") @Path(value = "form/{pkgId}/{formId}") public Object showInstallForm(@PathParam("pkgId") String pkgId, @PathParam("formId") int formId, @QueryParam("source") String source) { PackageUpdateService pus = Framework.getService(PackageUpdateService.class); try { LocalPackage pkg = pus.getPackage(pkgId); Task installTask = pkg.getInstallTask(); Form[] forms = installTask.getPackage().getInstallForms(); if (forms == null || forms.length < formId - 1) { return getView("installError").arg("e", new NuxeoException("No form with Id " + formId + " for package " + pkgId)).arg("source", source); } return getView("showInstallForm").arg("form", forms[formId]).arg("pkg", pkg).arg("source", source).arg( "step", formId + 1).arg("steps", forms.length); } catch (PackageException e) { log.error("Error during displaying Form nb " + formId, e); return getView("installError").arg("e", e).arg("source", source); } }
@SuppressWarnings("unchecked") protected Map<String, String> getInstallParameters(String pkgId) { Map<String, String> params = (Map<String, String>) getContext().getRequest().getAttribute(getStorageKey(pkgId)); if (params == null) { params = new HashMap<>(); } return params; }
protected void storeInstallParameters(String pkgId, Map<String, String> params) { getContext().getRequest().setAttribute(getStorageKey(pkgId), params); }
protected void clearInstallParameters(String pkgId) { getContext().getRequest().setAttribute(getStorageKey(pkgId), null); }