Package javax.portlet

Examples of javax.portlet.PortletException


        PluginListType data = (PluginListType) request.getPortletSession(true).getAttribute(SERVER_CONFIG_LIST_SESSION_KEY);
        if (data==null) {
            try {
                data = pluginInstaller.createPluginListForRepositories(null);
            } catch (NoSuchStoreException e) {
                throw new PortletException("Server in unknown state", e);
            }
        }
        return data;
    }
View Full Code Here


                        break;
                    }
                }
            }
            if (plugin == null) {
                throw new PortletException("No configuration found for '" + configId + "'");
            }
        }
        return installList;
    }
View Full Code Here

                    }
                }
                if (keys != null && keys.length == 1) {
                    setProperty(connector, "keyAlias", keys[0]);
                } else {
                    throw new PortletException("Cannot handle keystores with anything but 1 unlocked private key");
                }
            } catch (KeystoreException e) {
                throw new PortletException(e);
            }
        }
    }
View Full Code Here

                statusMsgs[1] = fullStatusMessage;
            } finally {
                mgr.release();
            }
        } catch (Exception e) {
            throw new PortletException(e);
        }
        return statusMsgs;
    }
View Full Code Here

    private PortletRequestDispatcher helpView;

    public void processAction(ActionRequest actionRequest,
                              ActionResponse actionResponse) throws PortletException, IOException {
        if (!PortletFileUpload.isMultipartContent(actionRequest)) {
            throw new PortletException("Expected file upload");
        }

        File rootDir = new File(System.getProperty("java.io.tmpdir"));
        PortletFileUpload uploader = new PortletFileUpload(new DiskFileItemFactory(10240, rootDir));
        File moduleFile = null;
        File planFile = null;
        String startApp = null;
        String redeploy = null;
        try {
            List items = uploader.parseRequest(actionRequest);
            for (Iterator i = items.iterator(); i.hasNext();) {
                FileItem item = (FileItem) i.next();
                if (!item.isFormField()) {
                    String fieldName = item.getFieldName();
                    String name = item.getName().trim();
                    File file;
                    if (name.length() == 0) {
                        file = null;
                    } else {
                        // Firefox sends basename, IE sends full path
                        int index = name.lastIndexOf('\\');
                        if (index != -1) {
                            name = name.substring(index + 1);
                        }
                        file = new File(rootDir, name);
                    }
                    if ("module".equals(fieldName)) {
                        moduleFile = file;
                    } else if ("plan".equals(fieldName)) {
                        planFile = file;
                    }
                    if (file != null) {
                        try {
                            item.write(file);
                        } catch (Exception e) {
                            throw new PortletException(e);
                        }
                    }
                } else {
                    // retrieve 'startApp' form field value
                    if ("startApp".equalsIgnoreCase(item.getFieldName())) {
                        startApp = item.getString();
                    } else if ("redeploy".equalsIgnoreCase(item.getFieldName())) {
                        redeploy = item.getString();
                    }
                }
            }
        } catch (FileUploadException e) {
            throw new PortletException(e);
        }
        DeploymentFactoryManager dfm = DeploymentFactoryManager.getInstance();
        FileInputStream fis = null;
        try {
            DeploymentManager mgr = dfm.getDeploymentManager("deployer:geronimo:inVM", null, null);
            try {
                boolean isRedeploy = redeploy != null && !redeploy.equals("");
                if(mgr instanceof JMXDeploymentManager) {
                    ((JMXDeploymentManager)mgr).setLogConfiguration(false, true);
                }
                Target[] all = mgr.getTargets();
                if (null == all) {
                    throw new IllegalStateException("No target to distribute to");
                }

                ProgressObject progress;
                if(isRedeploy) {
                    TargetModuleID[] targets = identifyTargets(moduleFile, planFile, mgr.getAvailableModules(null, all));
                    if(targets.length == 0) {
                        throw new PortletException("Unable to identify modules to replace.  Please include a Geronimo deployment plan or use the command-line deployment tool.");
                    }
                    progress = mgr.redeploy(targets, moduleFile, planFile);
                } else {
                    progress = mgr.distribute(new Target[] {all[0]}, moduleFile, planFile);
                }
                while(progress.getDeploymentStatus().isRunning()) {
                    Thread.sleep(100);
                }
               
                String abbrStatusMessage;
                String fullStatusMessage = null;
                if(progress.getDeploymentStatus().isCompleted()) {
                    abbrStatusMessage = "The application was successfully "+(isRedeploy ? "re" : "")+"deployed.<br/>";
                    // start installed app/s
                    if (!isRedeploy && startApp != null && !startApp.equals("")) {
                        progress = mgr.start(progress.getResultTargetModuleIDs());
                        while(progress.getDeploymentStatus().isRunning()) {
                            Thread.sleep(100);
                        }
                        abbrStatusMessage+="The application was successfully started";
                    }
                } else {
                    fullStatusMessage = progress.getDeploymentStatus().getMessage();
                    // for the abbreviated status message clip off everything
                    // after the first line, which in most cases means the gnarly stacktrace
                    abbrStatusMessage = "Deployment failed:<br/>"
                                      + fullStatusMessage.substring(0, fullStatusMessage.indexOf('\n'));
                    // try to provide an upgraded version of the plan
                    try {
                        if (planFile != null && planFile.exists()) {
                            byte[] plan = new byte[(int) planFile.length()];
                            fis = new FileInputStream(planFile);
                            fis.read(plan);
                            DocumentBuilder documentBuilder = XmlUtil.newDocumentBuilderFactory().newDocumentBuilder();
                            Document doc = documentBuilder.parse(new ByteArrayInputStream(plan));
                            // v1.1 switched from configId to moduleId
                            String configId = doc.getDocumentElement().getAttribute("configId");
                            if (configId != null && !("".equals(configId))) {
                                StringWriter sw = new StringWriter();
                                new Upgrade1_0To1_1().upgrade(new ByteArrayInputStream(plan), sw);
                                // have to store the original and upgraded plans in the session
                                // because the buffer size for render parameters is sometimes not
                                // big enough
                                actionRequest.getPortletSession().setAttribute(MIGRATED_PLAN_PARM, sw.getBuffer());
                                actionRequest.getPortletSession().setAttribute(ORIGINAL_PLAN_PARM, new String(plan));
                            }
                        }
                    } catch (Exception e) {
                        // cannot provide a migrated plan in this case, most likely
                        // because the deployment plan would not parse. a valid
                        // status message has already been provided in this case
                    }
                }
                // have to store the status messages in the portlet session
                // because the buffer size for render parameters is sometimes not big enough
                actionRequest.getPortletSession().setAttribute(FULL_STATUS_PARM, fullStatusMessage);
                actionRequest.getPortletSession().setAttribute(ABBR_STATUS_PARM, abbrStatusMessage);
            } finally {
                mgr.release();
                if (fis!=null) fis.close();
                if(moduleFile != null && moduleFile.exists()) {
                    if(!moduleFile.delete()) {
                        log.debug("Unable to delete temporary file "+moduleFile);
                        moduleFile.deleteOnExit();
                    }
                }
                if(planFile != null && planFile.exists()) {
                    if(!planFile.delete()) {
                        log.debug("Unable to delete temporary file "+planFile);
                        planFile.deleteOnExit();
                    }
                }
            }
        } catch (Exception e) {
            throw new PortletException(e);
        }
    }
View Full Code Here

                    name = name.substring(0, pos);
                }
                modules.addAll(ConfigIDExtractor.identifyTargetModuleIDs(allModules, Artifact.DEFAULT_GROUP_ID+"/"+name+"//", true));
            }
        } catch (IOException e) {
            throw new PortletException("Unable to read input files: "+e.getMessage());
        } catch (DeploymentException e) {
            throw new PortletException(e.getMessage(), e);
        }
        return (TargetModuleID[]) modules.toArray(new TargetModuleID[modules.size()]);
    }
View Full Code Here

                        if (file != null) {
                            try {
                                item.write(file);
                            } catch (Exception e) {
                                throw new PortletException(e);
                            }
                        }
                        // This is not the file itself, but one of the form fields for the URI
                    } else {
                        String fieldName = item.getFieldName().trim();
                        if ("group".equals(fieldName)) {
                            group = item.getString().trim();
                        } else if ("artifact".equals(fieldName)) {
                            artifact = item.getString().trim();
                        } else if ("version".equals(fieldName)) {
                            version = item.getString().trim();
                        } else if ("fileType".equals(fieldName)) {
                            fileType = item.getString().trim();
                        }
                    }
                }


                repo.copyToRepository(file, new Artifact(group, artifact, version, fileType), new FileWriteMonitor() {
                    public void writeStarted(String fileDescription, int fileSize) {
                        log.info("Copying into repository " + fileDescription + "...");
                    }

                    public void writeProgress(int bytes) {
                    }

                    public void writeComplete(int bytes) {
                        log.info("Finished.");
                    }
                });
            } catch (FileUploadException e) {
                throw new PortletException(e);
            }
        } catch (PortletException e) {
            throw e;
        }
    }
View Full Code Here

            Collections.sort(list);

            request.setAttribute("org.apache.geronimo.console.repo.list", list);

        } catch (Exception e) {
            throw new PortletException(e);
        }

        normalView.include(request, response);
    }
View Full Code Here

        try {
            DownloadResults downloadResults = pluginInstaller.installPluginList("repository", relativeServerPath, installList);
            archiver.archive(relativeServerPath, "var/temp", new Artifact(groupId, artifactId, version, format));
        } catch (Exception e) {
            throw new PortletException("Could not assemble server", e);
        }
        return INDEX_MODE;
    }
View Full Code Here

        List<InstallResults> dependencies = new ArrayList<InstallResults>();
        if (results != null) {
            if(results.isFailed()) {
                //TODO is this an appropriate way to explain failure?
                throw new PortletException("Unable to install configuration", results.getFailure());
            }
            for (Artifact uri: results.getDependenciesInstalled()) {
                dependencies.add(new InstallResults(uri.toString(), "installed"));
            }
            for (Artifact uri: results.getDependenciesPresent()) {
View Full Code Here

TOP

Related Classes of javax.portlet.PortletException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.