Examples of PortletMessage


Examples of org.apache.pluto.portlet.admin.bean.PortletMessage

   */
  public String processFileUpload(ActionRequest request, ActionResponse response) {
    final String METHOD_NAME = "processFileUpload(request,response)";
    String fileName = null;
    String serverFileName = null;
    request.getPortletSession().setAttribute(PlutoAdminConstants.MESSAGE_ATTR, new PortletMessage("Deployment unsuccessful", PortletMessageType.ERROR));
    // Check the request content type to see if it starts with multipart/
    if (PortletDiskFileUpload.isMultipartContent(request))
    {

      PortletDiskFileUpload dfu = new PortletDiskFileUpload();

      //maximum allowed file upload size (10 MB)
      dfu.setSizeMax(10 * 1000 * 1000);

      //maximum size in memory (vs disk) (100 KB)
      dfu.setSizeThreshold(100 * 1000);

        try
        {
            //get the FileItems
            List fileItems = dfu.parseRequest(request);
            Iterator iter = fileItems.iterator();
            while (iter.hasNext())
            {
                FileItem item = (FileItem) iter.next();
                if (item.isFormField())
                {
                    //pass along to render request
                    String fieldName = item.getFieldName();
                    String value = item.getString();
                    response.setRenderParameter(fieldName, value);
                }
                else
                {
                    //write the uploaded file to a new location
                    fileName = item.getName();
                    String contentType = item.getContentType();
                    long size = item.getSize();
                    response.setRenderParameter("size", Long.toString(size));
                    response.setRenderParameter("contentType", contentType);
                    String tempDir = System.getProperty("java.io.tmpdir");
                    serverFileName = getRootFilename(File.separatorChar, fileName);
                    File serverFile = new File(tempDir, serverFileName);
                    item.write(serverFile);
                    response.setRenderParameter("serverFileName",  serverFileName);

                    //Add to portletentityregistry.xml
          int index = serverFileName.indexOf(".war");
          String context = "";
          if ( index != -1) {
            context = serverFileName.substring(0, index);
          } else {
            context = serverFileName;
          }
              //Check to see if a record exists
                  PortletEntityRegistryXao xao = new PortletEntityRegistryXao();
              boolean appExists = xao.applicationExists(context);
          ArrayList  argList = createDeploymentArgs(serverFileName, tempDir, request, appExists);
          Map pmap = (HashMap) request.getPortletSession().getAttribute(PlutoAdminConstants.PORTLET_MAP_ATTR);
          logDebug(METHOD_NAME, "Arguments for Deploy.main():");
          String[] args = arrayListToStringArray(argList);
          for (int i =0; i < args.length; i++) {
            logDebug(METHOD_NAME, "args["+i+"]="+args[i]);
          }
                org.apache.pluto.portalImpl.Deploy.main(args);
                if (appExists) {
                  request.getPortletSession().setAttribute(PlutoAdminConstants.MESSAGE_ATTR, new PortletMessage("Deployment of the new portlet app has been successful, but the portlet app record '" + context + "' already exists in portletentityregistry.xml. " +
                      "This may have occurred if the portlet was previously partially deployed. If that is the case, continue with this screen and the next to register the portlet in pageregistry.xml. " +
                      "If you are deploying a previously deployed portlet app, you should be able to see your changes if you select the portlet from the navigation bar. " +
                      "However, caching of the old app may require that you restart Pluto to see the new changes.", PortletMessageType.INFO));
                } else {
                  request.getPortletSession().setAttribute(PlutoAdminConstants.MESSAGE_ATTR, new PortletMessage("Deployment and addition to portletentityregistry.xml successful.", PortletMessageType.SUCCESS));
                }
             }
            }
        }
        catch (FileUploadException e){
            String msg = "File Upload Exception: " + e.getMessage();
            logError(METHOD_NAME, msg, e);
            throw new PlutoAdminException(e);
        } catch (Exception e) {
            String msg = "Exception: " + e.getMessage();
            logError(METHOD_NAME, msg, e);
            throw new PlutoAdminException(e);
        }
    } else {
        //set an error message
        request.getPortletSession().setAttribute(PlutoAdminConstants.MESSAGE_ATTR, new PortletMessage("No file appears to have been selected.", PortletMessageType.ERROR));
    }
    logMethodEnd(METHOD_NAME, serverFileName);
    return serverFileName;
  }
View Full Code Here

Examples of org.apache.pluto.portlet.admin.bean.PortletMessage

          if (page != null && !service.pageExists(name)) {
            service.setPage(request);
            //forward to page layout page
            _incView = "/portlets/admin/PageRegistryAdd2.jsp";
          } else {
            session.setAttribute(PlutoAdminConstants.MESSAGE_ATTR, new PortletMessage("Page '" + name + "' already exists in pageregistry.xml", PortletMessageType.INFO));
            _incView = "/portlets/admin/DeployWarView.jsp";
          }
          response.setPortletMode(PortletMode.VIEW);

        } else if (action.equals("savepagelayout")) {

          service.savePageLayout(request);
          //forward to first page
          request.getPortletSession().setAttribute(PlutoAdminConstants.MESSAGE_ATTR, new PortletMessage("Deployment successful. Please restart the Pluto portal.", PortletMessageType.SUCCESS));
          _incView = "/portlets/admin/DeployWarView.jsp";
          response.setPortletMode(PortletMode.VIEW);
        }

      } catch (Throwable e) {
        log("Error! ", e);
          request.getPortletSession().setAttribute(PlutoAdminConstants.MESSAGE_ATTR, new PortletMessage("A problem has occurred: " + e.getMessage() + ". Please check the servlet container's error log.", PortletMessageType.ERROR));
      }
    }
View Full Code Here

Examples of org.apache.pluto.portlet.admin.bean.PortletMessage

    PortletRequest request = (PortletRequest)pageContext.getRequest().getAttribute(Constants.PORTLET_REQUEST);
    PortletSession session = request.getPortletSession();
    Throwable error = (Throwable)session.getAttribute(PlutoAdminConstants.ERROR_ATTR);
    session.removeAttribute(PlutoAdminConstants.ERROR_ATTR);
    PortletMessage oMsg = (PortletMessage)session.getAttribute(PlutoAdminConstants.MESSAGE_ATTR);
    session.removeAttribute(PlutoAdminConstants.MESSAGE_ATTR);

    try {
      JspWriter out = pageContext.getOut();
      if (message != null ) {
        if (cssClass == null) {
          cssClass = PortletMessageType.getTypeByName(messageType).CssClass;
        }
        out.print(wrapHtml(message, cssClass));
      } else if (oMsg != null ) {
        out.print(wrapHtml(oMsg.getMessage(), oMsg.getType().CssClass));
      } else if (error != null ) {
        StringBuffer sb = new StringBuffer();
        sb.append(error.getMessage());
        if (error.getCause() != null) {
          sb.append("<br>Underlying Exception cause: ");
View Full Code Here

Examples of org.apache.pluto.portlet.admin.bean.PortletMessage

          if (page != null && !service.pageExists(name)) {
            service.setPage(request);
            //forward to page layout page
            _incView = "/portlets/admin/PageRegistryAdd2.jsp";
          } else {
            session.setAttribute(PlutoAdminConstants.MESSAGE_ATTR, new PortletMessage("Page '" + name + "' already exists in pageregistry.xml", PortletMessageType.INFO));
            _incView = "/portlets/admin/DeployWarView.jsp";
          }
          response.setPortletMode(PortletMode.VIEW);

        } else if (action.equals("savepagelayout")) {

          service.savePageLayout(request);
          //forward to first page
          request.getPortletSession().setAttribute(PlutoAdminConstants.MESSAGE_ATTR, new PortletMessage("Deployment successful. Please restart the Pluto portal.", PortletMessageType.SUCCESS));
          _incView = "/portlets/admin/DeployWarView.jsp";
          response.setPortletMode(PortletMode.VIEW);
        }

      } catch (Throwable e) {
        log("Error! ", e);
          request.getPortletSession().setAttribute(PlutoAdminConstants.MESSAGE_ATTR, new PortletMessage("A problem has occurred: " + e.getMessage() + ". Please check the log file for details.", PortletMessageType.ERROR));
      }
    }
View Full Code Here

Examples of org.apache.pluto.portlet.admin.bean.PortletMessage

   */
  public String processFileUpload(ActionRequest request, ActionResponse response) {
    final String METHOD_NAME = "processFileUpload(request,response)";
    String fileName = null;
    String serverFileName = null;
    request.getPortletSession().setAttribute(PlutoAdminConstants.MESSAGE_ATTR, new PortletMessage("Deployment unsuccessful", PortletMessageType.ERROR));
    // Check the request content type to see if it starts with multipart/
    if (PortletDiskFileUpload.isMultipartContent(request))
    {

      PortletDiskFileUpload dfu = new PortletDiskFileUpload();

      //maximum allowed file upload size (10 MB)
      dfu.setSizeMax(10 * 1000 * 1000);

      //maximum size in memory (vs disk) (100 KB)
      dfu.setSizeThreshold(100 * 1000);

        try
        {
            //get the FileItems
            List fileItems = dfu.parseRequest(request);
            Iterator iter = fileItems.iterator();
            while (iter.hasNext())
            {
                FileItem item = (FileItem) iter.next();
                if (item.isFormField())
                {
                    //pass along to render request
                    String fieldName = item.getFieldName();
                    String value = item.getString();
                    response.setRenderParameter(fieldName, value);
                }
                else
                {
                    //write the uploaded file to a new location
                    fileName = item.getName();
                    String contentType = item.getContentType();
                    long size = item.getSize();
                    response.setRenderParameter("size", Long.toString(size));
                    response.setRenderParameter("contentType", contentType);
                    String tempDir = System.getProperty("java.io.tmpdir");
                    serverFileName = getRootFilename(File.separatorChar, fileName);
                    File serverFile = new File(tempDir, serverFileName);
                    item.write(serverFile);
                    response.setRenderParameter("serverFileName",  serverFileName);

                    //Add to portletentityregistry.xml
          int index = serverFileName.indexOf(".war");
          String context = "";
          if ( index != -1) {
            context = serverFileName.substring(0, index);
          } else {
            context = serverFileName;
          }
              //Check to see if a record exists
                  PortletEntityRegistryXao xao = new PortletEntityRegistryXao();
              boolean appExists = xao.applicationExists(context);
          ArrayList  argList = createDeploymentArgs(serverFileName, tempDir, request, appExists, context);
          Map pmap = (HashMap) request.getPortletSession().getAttribute(PlutoAdminConstants.PORTLET_MAP_ATTR);
          logDebug(METHOD_NAME, "Arguments for Deploy.main():");
          String[] args = arrayListToStringArray(argList);
          for (int i =0; i < args.length; i++) {
            logDebug(METHOD_NAME, "args["+i+"]="+args[i]);
          }
                org.apache.pluto.portalImpl.Deploy.main(args);
                if (appExists) {
                  request.getPortletSession().setAttribute(PlutoAdminConstants.MESSAGE_ATTR, new PortletMessage("Deployment of the new portlet app has been successful, but the portlet app record '" + context + "' already exists in portletentityregistry.xml. " +
                      "This may have occurred if the portlet was previously partially deployed. If that is the case, continue with this screen and the next to register the portlet in pageregistry.xml. " +
                      "If you are deploying a previously deployed portlet app, you should be able to see your changes if you select the portlet from the navigation bar. " +
                      "However, caching of the old app may require that you restart Pluto to see the new changes.", PortletMessageType.INFO));
                } else {
                  request.getPortletSession().setAttribute(PlutoAdminConstants.MESSAGE_ATTR, new PortletMessage("Deployment and addition to portletentityregistry.xml successful.", PortletMessageType.SUCCESS));
                }
             }
            }
        }
        catch (FileUploadException e){
            String msg = "File Upload Exception: " + e.getMessage();
            logError(METHOD_NAME, msg, e);
            throw new PlutoAdminException(e);
        } catch (Exception e) {
            String msg = "Exception: " + e.getMessage();
            logError(METHOD_NAME, msg, e);
            throw new PlutoAdminException(e);
        }
    } else {
        //set an error message
        request.getPortletSession().setAttribute(PlutoAdminConstants.MESSAGE_ATTR, new PortletMessage("No file appears to have been selected.", PortletMessageType.ERROR));
    }
    logMethodEnd(METHOD_NAME, serverFileName);
    return serverFileName;
  }
View Full Code Here

Examples of org.apache.pluto.portlet.admin.bean.PortletMessage

    PortletRequest request = (PortletRequest)pageContext.getRequest().getAttribute(Constants.PORTLET_REQUEST);
    PortletSession session = request.getPortletSession();
    Throwable error = (Throwable)session.getAttribute(PlutoAdminConstants.ERROR_ATTR);
    session.removeAttribute(PlutoAdminConstants.ERROR_ATTR);
    PortletMessage oMsg = (PortletMessage)session.getAttribute(PlutoAdminConstants.MESSAGE_ATTR);
    session.removeAttribute(PlutoAdminConstants.MESSAGE_ATTR);

    try {
      JspWriter out = pageContext.getOut();
      if (message != null ) {
        if (cssClass == null) {
          cssClass = PortletMessageType.getTypeByName(messageType).CssClass;
        }
        out.print(wrapHtml(message, cssClass));
      } else if (oMsg != null ) {
        out.print(wrapHtml(oMsg.getMessage(), oMsg.getType().CssClass));
      } else if (error != null ) {
        StringBuffer sb = new StringBuffer();
        sb.append(error.getMessage());
        if (error.getCause() != null) {
          sb.append("<br>Underlying Exception cause: ");
View Full Code Here

Examples of org.apache.pluto.portlet.admin.bean.PortletMessage

  public String processFileUpload(ActionRequest request, ActionResponse response) {
    final String METHOD_NAME = "processFileUpload(request,response)";
    String fileName = null;
    String serverFileName = null;
    boolean modifyWebXml = true;
    request.getPortletSession().setAttribute(PlutoAdminConstants.MESSAGE_ATTR, new PortletMessage("Deployment unsuccessful", PortletMessageType.ERROR));
    // Check the request content type to see if it starts with multipart/
    if (PortletDiskFileUpload.isMultipartContent(request))
    {

      PortletDiskFileUpload dfu = new PortletDiskFileUpload();

      //maximum allowed file upload size (10 MB)
      dfu.setSizeMax(10 * 1000 * 1000);

      //maximum size in memory (vs disk) (100 KB)
      dfu.setSizeThreshold(100 * 1000);

        try
        {
            //get the FileItems
            List fileItems = dfu.parseRequest(request);
            Iterator iter = fileItems.iterator();
            while (iter.hasNext())
            {
                FileItem item = (FileItem) iter.next();
                if (item.isFormField())
                {
                    //pass along to render request
                    String fieldName = item.getFieldName();
                    String value = item.getString();
                    response.setRenderParameter(fieldName, value);
                    if (fieldName.equalsIgnoreCase("NoWebXmlModification")) {
                        String noWebXmlModification = item.getString();
                        logWarn(METHOD_NAME, "Don't modify web.xml? " + noWebXmlModification);
                        if (noWebXmlModification != null) {
                          modifyWebXml = false;
                        }
                    }
                }
                else
                {
                    //write the uploaded file to a new location
                    fileName = item.getName();
                    String contentType = item.getContentType();
                    long size = item.getSize();
                    response.setRenderParameter("size", Long.toString(size));
                    response.setRenderParameter("contentType", contentType);
                    String tempDir = System.getProperty("java.io.tmpdir");
                    serverFileName = getRootFilename(File.separatorChar, fileName);
                    File serverFile = new File(tempDir, serverFileName);
                    item.write(serverFile);
                    response.setRenderParameter("serverFileName",  serverFileName);

                    //Add to portletentityregistry.xml
          int index = serverFileName.indexOf(".war");
          String context = "";
          if ( index != -1) {
            context = serverFileName.substring(0, index);
          } else {
            context = serverFileName;
          }
              //Check to see if a record exists
                  PortletEntityRegistryXao xao = new PortletEntityRegistryXao();
              boolean appExists = xao.applicationExists(context);
          ArrayList  argList = createDeploymentArgs(serverFileName, tempDir, request, appExists, context);
          Map pmap = (HashMap) request.getPortletSession().getAttribute(PlutoAdminConstants.PORTLET_MAP_ATTR);
          logDebug(METHOD_NAME, "Arguments for Deploy.main():");
          String[] args = arrayListToStringArray(argList);
          for (int i =0; i < args.length; i++) {
            logDebug(METHOD_NAME, "args["+i+"]="+args[i]);
          }
                org.apache.pluto.portalImpl.Deploy.main(args);
                //NEW: Update web.xml with new servlet elements
                if (modifyWebXml) {
                  updateWebXml(context);
                }
                if (appExists) {
                  request.getPortletSession().setAttribute(PlutoAdminConstants.MESSAGE_ATTR, new PortletMessage("Deployment of the new portlet app has been successful, but the portlet app record '" + context + "' already exists in portletentityregistry.xml. " +
                      "This may have occurred if the portlet was previously partially deployed. If that is the case, continue with this screen and the next to register the portlet in pageregistry.xml. " +
                      "If you are deploying a previously deployed portlet app, click on the 'Deploy War home' link below and then the 'Hot deploy . . .' link on the resulting page to see your redeployed portlet. " +
                      "However, caching of the old app may require that you restart Pluto to see the new changes.", PortletMessageType.INFO));
                } else {
                  request.getPortletSession().setAttribute(PlutoAdminConstants.MESSAGE_ATTR, new PortletMessage("Deployment and addition to portletentityregistry.xml successful.", PortletMessageType.SUCCESS));
                }
             }
            }
        }
        catch (FileUploadException e){
            String msg = "File Upload Exception: " + e.getMessage();
            logError(METHOD_NAME, msg, e);
            throw new PlutoAdminException(e);
        } catch (Exception e) {
            String msg = "Exception: " + e.getMessage();
            logError(METHOD_NAME, msg, e);
            throw new PlutoAdminException(e);
        }
    } else {
        //set an error message
        request.getPortletSession().setAttribute(PlutoAdminConstants.MESSAGE_ATTR, new PortletMessage("No file appears to have been selected.", PortletMessageType.ERROR));
    }
    logMethodEnd(METHOD_NAME, serverFileName);
    return serverFileName;
  }
View Full Code Here

Examples of org.apache.pluto.portlet.admin.bean.PortletMessage

          if (page != null && !service.pageExists(name)) {
            service.setPage(request);
            //forward to page layout page
            _incView = "/portlets/admin/PageRegistryAdd2.jsp";
          } else {
            session.setAttribute(PlutoAdminConstants.MESSAGE_ATTR, new PortletMessage("Page '" + name + "' already exists in pageregistry.xml", PortletMessageType.INFO));
            _incView = "/portlets/admin/DeployWarView.jsp";
          }
          response.setPortletMode(PortletMode.VIEW);

        } else if (action.equals("savepagelayout")) {

          service.savePageLayout(request);
          //forward to first page
          request.getPortletSession().setAttribute(PlutoAdminConstants.MESSAGE_ATTR, new PortletMessage("Deployment successful. Please restart the Pluto portal or click the hot deploy link below.", PortletMessageType.SUCCESS));
          _incView = "/portlets/admin/DeployWarView.jsp";
          response.setPortletMode(PortletMode.VIEW);
        }

      } catch (Throwable e) {
        log("Error! ", e);
          request.getPortletSession().setAttribute(PlutoAdminConstants.MESSAGE_ATTR, new PortletMessage("A problem has occurred: " + e.getMessage() + ". Please check the log file for details.", PortletMessageType.ERROR));
      }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.