Package org.exoplatform.commons.utils

Examples of org.exoplatform.commons.utils.Text$Bytes


    }

    public Text generateRenderMarkup(PortletInvocationResponse pir, WebuiRequestContext context) {
        PortalRequestContext prcontext = (PortalRequestContext) context;

        Text markup = null;
        if (pir instanceof FragmentResponse) {
            JavascriptManager jsMan = context.getJavascriptManager();
            jsMan.loadScriptResource(ResourceScope.PORTLET, getApplicationId());

            FragmentResponse fragmentResponse = (FragmentResponse) pir;
View Full Code Here


    public void processRender(UIPortlet<S, C> uicomponent, WebuiRequestContext context) throws Exception {
        PortalRequestContext prcontext = (PortalRequestContext) context;
        ExoContainer container = prcontext.getApplication().getApplicationServiceContainer();

        //
        Text markup = null;

        try {
            Map<String, String[]> paramMap = prcontext.getRequest().getParameterMap();
            if (paramMap.containsKey("removePP")) {
                UIPortal uiPortal = Util.getUIPortal();
                for (String publicParamName : paramMap.get("removePP")) {
                    uiPortal.getPublicParameters().remove(publicParamName);
                }
            }

            RenderInvocation renderInvocation = uicomponent.create(RenderInvocation.class, prcontext);

            String appStatus = uicomponent.getProperties().get("appStatus");
            if ("Window".equals(uicomponent.getPortletStyle()) && !("SHOW".equals(appStatus) || "HIDE".equals(appStatus))) {
                markup = Text.create("<span></span>");
            } else {
                int portalMode = Util.getUIPortalApplication().getModeState();

                // Check mode of portal, portlet and permission for viewable
                if ((portalMode == UIPortalApplication.NORMAL_MODE || portalMode == UIPortalApplication.APP_VIEW_EDIT_MODE
                        || portalMode == UIPortalApplication.CONTAINER_VIEW_EDIT_MODE || uicomponent.getCurrentPortletMode()
                        .equals(PortletMode.EDIT)) && uicomponent.hasPermission()) {
                    PortletInvocationResponse response = uicomponent.invoke(renderInvocation);
                    markup = uicomponent.generateRenderMarkup(response, prcontext);
                } else {
                    uicomponent.setConfiguredTitle(null);
                }
            }
        } catch (Exception e) {
            PortletContainerException pcException = new PortletContainerException(e);
            PortletExceptionHandleService portletExceptionService = uicomponent
                    .getApplicationComponent(PortletExceptionHandleService.class);
            if (portletExceptionService != null) {
                portletExceptionService.handle(pcException);
            }

            if (e instanceof NoSuchDataException) {
                UIPortalApplication uiApp = Util.getUIPortalApplication();
                uiApp.refreshCachedUI();
                markup = Text.create(context.getApplicationResourceBundle().getString("UIPortlet.message.staleData"));
            } else {
                // Log the error
                log.error("Portlet render threw an exception", pcException);

                //
                markup = Text.create(context.getApplicationResourceBundle().getString("UIPortlet.message.RuntimeError"));
            }
        }

        //
        if (context.useAjax() && !prcontext.getFullRender()) {
            if (markup != null) {
                markup.writeTo(prcontext.getWriter());
            }
        } else {
            WebuiApplication app = (WebuiApplication) prcontext.getApplication();
            ApplicationResourceResolver resolver = app.getResourceResolver();
            WebuiBindingContext bcontext = new WebuiBindingContext(resolver, context.getWriter(), uicomponent, prcontext);
View Full Code Here

     * @see PortletExceptionHandleService
     */
    public Text generateRenderMarkup(PortletInvocationResponse pir, WebuiRequestContext context) {
        PortalRequestContext prcontext = (PortalRequestContext) context;

        Text markup = null;
        if (pir instanceof FragmentResponse) {
            JavascriptManager jsMan = context.getJavascriptManager();
            jsMan.loadScriptResource(ResourceScope.PORTLET, getApplicationId());

            FragmentResponse fragmentResponse = (FragmentResponse) pir;
View Full Code Here

   {
      PortalRequestContext prcontext = (PortalRequestContext)context;
      ExoContainer container = prcontext.getApplication().getApplicationServiceContainer();

      //
      Text markup = null;
      String portletTitle = null;

      try
      {
       Map<String, String[]> paramMap = prcontext.getRequest().getParameterMap();
       if (paramMap.containsKey("removePP"))
       {
         UIPortal uiPortal = Util.getUIPortal();
         for (String publicParamName : paramMap.get("removePP"))
         {
           uiPortal.getPublicParameters().remove(publicParamName);
         }
       }
      
         RenderInvocation renderInvocation = uicomponent.create(RenderInvocation.class, prcontext);

         if (uicomponent.getCurrentWindowState() != WindowState.MINIMIZED)
         {
            String appStatus = uicomponent.getProperties().get("appStatus");
            if ("Window".equals(uicomponent.getPortletStyle())
               && !("SHOW".equals(appStatus) || "HIDE".equals(appStatus)))
            {
               markup = Text.create("<span></span>");
            }
            else
            {
               int portalMode = Util.getUIPortalApplication().getModeState();
              
               //Check mode of portal, portlet and permission for viewable
               if ((portalMode == UIPortalApplication.NORMAL_MODE || portalMode == UIPortalApplication.APP_VIEW_EDIT_MODE
                   || portalMode == UIPortalApplication.CONTAINER_VIEW_EDIT_MODE || uicomponent.getCurrentPortletMode().equals(PortletMode.EDIT))
                   && uicomponent.hasPermission())
               {
                  PortletInvocationResponse response = uicomponent.invoke(renderInvocation);
                  if (response instanceof FragmentResponse)
                  {
                    FragmentResponse fragmentResponse = (FragmentResponse)response;
                    switch (fragmentResponse.getType())
                    {
                    case FragmentResponse.TYPE_CHARS:
                      markup = Text.create(fragmentResponse.getContent());
                      break;
                    case FragmentResponse.TYPE_BYTES:
                      markup = Text.create(fragmentResponse.getBytes(), Charset.forName("UTF-8"));
                      break;
                    case FragmentResponse.TYPE_EMPTY:
                      markup = Text.create("");
                      break;
                    }
                    portletTitle = fragmentResponse.getTitle();

                    // setup portlet properties
                    if (fragmentResponse.getProperties() != null)
                    {
                      //setup transport headers
                      if (fragmentResponse.getProperties().getTransportHeaders() != null)
                      {
                        MultiValuedPropertyMap<String> transportHeaders =
                          fragmentResponse.getProperties().getTransportHeaders();
                        for (String key : transportHeaders.keySet())
                        {
                          for (String value : transportHeaders.getValues(key))
                          {
                            prcontext.getResponse().setHeader(key, value);
                          }
                        }
                      }
                     
                      //setup up portlet cookies
                      if (fragmentResponse.getProperties().getCookies() != null)
                      {
                         List<Cookie> cookies = fragmentResponse.getProperties().getCookies();
                         for (Cookie cookie : cookies)
                         {
                            prcontext.getResponse().addCookie(cookie);
                         }
                      }

                      //setup markup headers
                      if (fragmentResponse.getProperties().getMarkupHeaders() != null)
                      {
                        MultiValuedPropertyMap<Element> markupHeaders =
                          fragmentResponse.getProperties().getMarkupHeaders();

                        List<Element> markupElements = markupHeaders.getValues(MimeResponse.MARKUP_HEAD_ELEMENT);
                        if (markupElements != null)
                        {
                          for (Element element : markupElements)
                          {
                            if ("title".equals(element.getNodeName().toLowerCase()) && element.getFirstChild() != null)
                            {
                              String title = element.getFirstChild().getTextContent();
                              prcontext.getRequest().setAttribute(PortalRequestContext.REQUEST_TITLE, title);
                            }
                            else
                            {
                              prcontext.addExtraMarkupHeader(element);
                            }
                          }
                        }
                      }
                    }

                  }
                  else
                  {

                     PortletContainerException pcException;

                     if (response instanceof ErrorResponse)
                     {
                        ErrorResponse errorResponse = (ErrorResponse)response;
                        pcException =
                           new PortletContainerException(errorResponse.getMessage(), errorResponse.getCause());
                     }
                     else
                     {
                        pcException =
                           new PortletContainerException("Unknown invocation response type [" + response.getClass()
                              + "]. Expected a FragmentResponse or an ErrorResponse");
                     }

                     //
                     PortletExceptionHandleService portletExceptionService = uicomponent.getApplicationComponent(PortletExceptionHandleService.class);
                     if (portletExceptionService != null)
                     {
                        portletExceptionService.handle(pcException);
                     }

                     // Log the error
                     log.error("Portlet render threw an exception", pcException);

                     markup = Text.create(context.getApplicationResourceBundle().getString("UIPortlet.message.RuntimeError"));
                  }
               }
            }
         }
      }
      catch (Exception e)
      {
         PortletContainerException pcException = new PortletContainerException(e);
         PortletExceptionHandleService portletExceptionService = uicomponent.getApplicationComponent(PortletExceptionHandleService.class);
         if (portletExceptionService != null)
         {
            portletExceptionService.handle(pcException);
         }

         // Log the error
         log.error("Portlet render threw an exception", pcException);

         //
         markup = Text.create(context.getApplicationResourceBundle().getString("UIPortlet.message.RuntimeError"));
      }

      //
      if (portletTitle == null)
      {
         portletTitle = "Portlet";
      }

      //
      if (context.useAjax() && !prcontext.getFullRender())
      {
         if (markup != null)
         {
            markup.writeTo(prcontext.getWriter());
         }
      }
      else
      {
         WebuiApplication app = (WebuiApplication)prcontext.getApplication();
View Full Code Here

    }

    public Text generateRenderMarkup(PortletInvocationResponse pir, WebuiRequestContext context) {
        PortalRequestContext prcontext = (PortalRequestContext) context;

        Text markup = null;
        if (pir instanceof FragmentResponse) {
            FragmentResponse fragmentResponse = (FragmentResponse) pir;
            switch (fragmentResponse.getType()) {
                case FragmentResponse.TYPE_CHARS:
                    markup = Text.create(fragmentResponse.getContent());
View Full Code Here

    public void processRender(UIPortlet<S, C> uicomponent, WebuiRequestContext context) throws Exception {
        PortalRequestContext prcontext = (PortalRequestContext) context;
        ExoContainer container = prcontext.getApplication().getApplicationServiceContainer();

        //
        Text markup = null;

        try {
            Map<String, String[]> paramMap = prcontext.getRequest().getParameterMap();
            if (paramMap.containsKey("removePP")) {
                UIPortal uiPortal = Util.getUIPortal();
                for (String publicParamName : paramMap.get("removePP")) {
                    uiPortal.getPublicParameters().remove(publicParamName);
                }
            }

            RenderInvocation renderInvocation = uicomponent.create(RenderInvocation.class, prcontext);

            String appStatus = uicomponent.getProperties().get("appStatus");
            if ("Window".equals(uicomponent.getPortletStyle()) && !("SHOW".equals(appStatus) || "HIDE".equals(appStatus))) {
                markup = Text.create("<span></span>");
            } else {
                int portalMode = Util.getUIPortalApplication().getModeState();

                // Check mode of portal, portlet and permission for viewable
                if ((portalMode == UIPortalApplication.NORMAL_MODE || portalMode == UIPortalApplication.APP_VIEW_EDIT_MODE
                        || portalMode == UIPortalApplication.CONTAINER_VIEW_EDIT_MODE || uicomponent.getCurrentPortletMode()
                        .equals(PortletMode.EDIT)) && uicomponent.hasPermission()) {
                    PortletInvocationResponse response = uicomponent.invoke(renderInvocation);
                    markup = uicomponent.generateRenderMarkup(response, prcontext);
                } else {
                    uicomponent.setConfiguredTitle(null);
                }
            }
        } catch (Exception e) {
            PortletContainerException pcException = new PortletContainerException(e);
            PortletExceptionHandleService portletExceptionService = uicomponent
                    .getApplicationComponent(PortletExceptionHandleService.class);
            if (portletExceptionService != null) {
                portletExceptionService.handle(pcException);
            }

            // Log the error
            log.error("Portlet render threw an exception", pcException);

            //
            markup = Text.create(context.getApplicationResourceBundle().getString("UIPortlet.message.RuntimeError"));
        }

        //
        if (context.useAjax() && !prcontext.getFullRender()) {
            if (markup != null) {
                markup.writeTo(prcontext.getWriter());
            }
        } else {
            WebuiApplication app = (WebuiApplication) prcontext.getApplication();
            ApplicationResourceResolver resolver = app.getResourceResolver();
            WebuiBindingContext bcontext = new WebuiBindingContext(resolver, context.getWriter(), uicomponent, prcontext);
View Full Code Here

   {
      PortalRequestContext prcontext = (PortalRequestContext)context;
      ExoContainer container = prcontext.getApplication().getApplicationServiceContainer();

      //
      Text markup = null;
      String portletTitle = null;

      try
      {
       Map<String, String[]> paramMap = prcontext.getRequest().getParameterMap();
       if (paramMap.containsKey("removePP"))
       {
         UIPortal uiPortal = Util.getUIPortal();
         for (String publicParamName : paramMap.get("removePP"))
         {
           uiPortal.getPublicParameters().remove(publicParamName);
         }
       }
      
         RenderInvocation renderInvocation = uicomponent.create(RenderInvocation.class, prcontext);

         if (uicomponent.getCurrentWindowState() != WindowState.MINIMIZED)
         {
            String appStatus = uicomponent.getProperties().get("appStatus");
            if ("Window".equals(uicomponent.getPortletStyle())
               && !("SHOW".equals(appStatus) || "HIDE".equals(appStatus)))
            {
               markup = Text.create("<span></span>");
            }
            else
            {
               int portalMode = Util.getUIPortalApplication().getModeState();
               if (portalMode % 2 == 0 || uicomponent.getCurrentPortletMode().equals(PortletMode.EDIT))
               {
                  PortletInvocationResponse response = uicomponent.invoke(renderInvocation);
                  if (response instanceof FragmentResponse)
                  {
                    FragmentResponse fragmentResponse = (FragmentResponse)response;
                    switch (fragmentResponse.getType())
                    {
                    case FragmentResponse.TYPE_CHARS:
                      markup = Text.create(fragmentResponse.getContent());
                      break;
                    case FragmentResponse.TYPE_BYTES:
                      markup = Text.create(fragmentResponse.getBytes(), Charset.forName("UTF-8"));
                      break;
                    case FragmentResponse.TYPE_EMPTY:
                      markup = Text.create("");
                      break;
                    }
                    portletTitle = fragmentResponse.getTitle();

                    // setup portlet properties
                    if (fragmentResponse.getProperties() != null)
                    {
                      //setup transport headers
                      if (fragmentResponse.getProperties().getTransportHeaders() != null)
                      {
                        MultiValuedPropertyMap<String> transportHeaders =
                          fragmentResponse.getProperties().getTransportHeaders();
                        for (String key : transportHeaders.keySet())
                        {
                          for (String value : transportHeaders.getValues(key))
                          {
                            prcontext.getResponse().setHeader(key, value);
                          }
                        }
                      }
                     
                      //setup up portlet cookies
                      if (fragmentResponse.getProperties().getCookies() != null)
                      {
                         List<Cookie> cookies = fragmentResponse.getProperties().getCookies();
                         for (Cookie cookie : cookies)
                         {
                            prcontext.getResponse().addCookie(cookie);
                         }
                      }

                      //setup markup headers
                      if (fragmentResponse.getProperties().getMarkupHeaders() != null)
                      {
                        MultiValuedPropertyMap<Element> markupHeaders =
                          fragmentResponse.getProperties().getMarkupHeaders();

                        List<Element> markupElements = markupHeaders.getValues(MimeResponse.MARKUP_HEAD_ELEMENT);
                        if (markupElements != null)
                        {
                          for (Element element : markupElements)
                          {
                            if ("title".equals(element.getNodeName().toLowerCase()) && element.getFirstChild() != null)
                            {
                              String title = element.getFirstChild().getTextContent();
                              prcontext.getRequest().setAttribute(PortalRequestContext.REQUEST_TITLE, title);
                            }
                            else
                            {
                              prcontext.addExtraMarkupHeader(element);
                            }
                          }
                        }
                      }
                    }

                  }
                  else
                  {

                     PortletContainerException pcException;

                     if (response instanceof ErrorResponse)
                     {
                        ErrorResponse errorResponse = (ErrorResponse)response;
                        pcException =
                           new PortletContainerException(errorResponse.getMessage(), errorResponse.getCause());
                     }
                     else
                     {
                        pcException =
                           new PortletContainerException("Unknown invocation response type [" + response.getClass()
                              + "]. Expected a FragmentResponse or an ErrorResponse");
                     }

                     PortletExceptionHandleService portletExceptionService =
                        (PortletExceptionHandleService)container
                           .getComponentInstanceOfType(PortletExceptionHandleService.class);
                     portletExceptionService.handle(pcException);

                     markup = Text.create("This portlet encountered an error and could not be displayed.");
                  }
               }
            }
         }
      }
      catch (Exception e)
      {
         PortletContainerException pcException = new PortletContainerException(e);
         PortletExceptionHandleService portletExceptionService =
            (PortletExceptionHandleService)container.getComponentInstanceOfType(PortletExceptionHandleService.class);
         if (portletExceptionService != null)
         {
             portletExceptionService.handle(pcException);
         }
         else
         {
           log.warn("Could not find the PortletExceptionHandleService in the exo container");
         }

         markup = Text.create("This portlet encountered an error and could not be displayed.");
      }

      //
      if (portletTitle == null)
      {
         portletTitle = "Portlet";
      }

      //
      if (context.useAjax() && !prcontext.getFullRender())
      {
         if (markup != null)
         {
            markup.writeTo(prcontext.getWriter());
         }
      }
      else
      {
         WebuiApplication app = (WebuiApplication)prcontext.getApplication();
View Full Code Here

    public void processRender(UIPortlet<S, C> uicomponent, WebuiRequestContext context) throws Exception {
        PortalRequestContext prcontext = (PortalRequestContext) context;
        ExoContainer container = prcontext.getApplication().getApplicationServiceContainer();

        //
        Text markup = null;

        try {
            Map<String, String[]> paramMap = prcontext.getRequest().getParameterMap();
            if (paramMap.containsKey("removePP")) {
                UIPortal uiPortal = Util.getUIPortal();
                for (String publicParamName : paramMap.get("removePP")) {
                    uiPortal.getPublicParameters().remove(publicParamName);
                }
            }

            RenderInvocation renderInvocation = uicomponent.create(RenderInvocation.class, prcontext);

            String appStatus = uicomponent.getProperties().get("appStatus");
            if ("Window".equals(uicomponent.getPortletStyle()) && !("SHOW".equals(appStatus) || "HIDE".equals(appStatus))) {
                markup = Text.create("<span></span>");
            } else {
                // Check mode of portal, portlet and permission for viewable
                if ((Util.getUIPortalApplication().getEditMode() != EditMode.BLOCK || uicomponent.getCurrentPortletMode()
                        .equals(PortletMode.EDIT)) && uicomponent.hasAccessPermission()) {
                    PortletInvocationResponse response = uicomponent.invoke(renderInvocation);
                    markup = uicomponent.generateRenderMarkup(response, prcontext);
                } else {
                    uicomponent.setConfiguredTitle(null);
                }
            }
        } catch (Exception e) {
            PortletContainerException pcException = new PortletContainerException(e);
            PortletExceptionHandleService portletExceptionService = uicomponent
                    .getApplicationComponent(PortletExceptionHandleService.class);
            if (portletExceptionService != null) {
                portletExceptionService.handle(pcException);
            }

            if (e instanceof NoSuchDataException) {
                UIPortalApplication uiApp = Util.getUIPortalApplication();
                uiApp.refreshCachedUI();
                markup = Text.create(context.getApplicationResourceBundle().getString("UIPortlet.message.staleData"));
            } else {
                // Log the error
                log.error("Portlet render threw an exception", pcException);

                //
                markup = Text.create(context.getApplicationResourceBundle().getString("UIPortlet.message.RuntimeError"));
            }
        }

        //
        if (context.useAjax() && !prcontext.getFullRender()) {
            if (markup != null) {
                markup.writeTo(prcontext.getWriter());
            }
        } else {
            WebuiApplication app = (WebuiApplication) prcontext.getApplication();
            ApplicationResourceResolver resolver = app.getResourceResolver();
            WebuiBindingContext bcontext = new WebuiBindingContext(resolver, context.getWriter(), uicomponent, prcontext);
View Full Code Here

     * @see PortletExceptionHandleService
     */
    public Text generateRenderMarkup(PortletInvocationResponse pir, WebuiRequestContext context) {
        PortalRequestContext prcontext = (PortalRequestContext) context;

        Text markup = null;
        if (pir instanceof FragmentResponse) {
            JavascriptManager jsMan = context.getJavascriptManager();
            jsMan.loadScriptResource(ResourceScope.PORTLET, getApplicationId());

            FragmentResponse fragmentResponse = (FragmentResponse) pir;
View Full Code Here

TOP

Related Classes of org.exoplatform.commons.utils.Text$Bytes

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.