Package it.eng.spago.base

Examples of it.eng.spago.base.SourceBean


    //**************** END MODFIFICATION ZERBETTO 09-10-2006 ****************
     
      Monitor monitor = null;
      PortletTracer.info(Constants.NOME_MODULO, "AdapterPortlet", "processService", "Invocato");
        try {
            SourceBean serviceRequest = null;
            EMFErrorHandler emfErrorHandler = null;
           
            RequestContainer requestContainer = new RequestContainer();
            RequestContainer.setRequestContainer(requestContainer);
            ResponseContainer responseContainer = new ResponseContainer();
            ResponseContainer.setResponseContainer(responseContainer);
            RequestContextIFace requestContext = new DefaultRequestContext(requestContainer,
                    responseContainer);
           
            // try to get from the request the loopback attribute. If present the method has to serve
            // a loopback request (the method has been called from the doRenderService)
            // if not present is a normal request
            boolean isLoop = request.getAttribute(Constants.PUBLISHING_MODE_LOOPBACK) != null;
            if(isLoop) {
              // remove from the request the loopback attribute
              request.removeAttribute(Constants.PUBLISHING_MODE_LOOPBACK);
              //String responseContainerName = (String)request.getAttribute(Constants.RESPONSE_CONTAINER);
             
              //**************** START MODFIFICATION ZERBETTO 09-10-2006 ****************
              // get from the session the previous response container name
              //String responseContainerName = (String)request.getPortletSession().getAttribute(RESPONSE_CONTAINER_NAME);
              // get from the session the previous response container
              //ResponseContainer loopbackResponseContainer = (ResponseContainer)request.getPortletSession().getAttribute(responseContainerName);
              ResponseContainer loopbackResponseContainer = (ResponseContainer)request.getPortletSession().getAttribute(Constants.RESPONSE_CONTAINER);
              //**************** END MODFIFICATION ZERBETTO 09-10-2006 ****************
             
                TracerSingleton.log(
                    Constants.NOME_MODULO,
                    TracerSingleton.DEBUG,
                    "AdapterPortlet::service: loop-back rilevato");
                serviceRequest =
                    loopbackResponseContainer.getLoopbackServiceRequest();
                if (serviceRequest == null)
                    serviceRequest = new SourceBean(Constants.SERVICE_REQUEST);
                else {
                    Object newServiceRequest =
                        serviceRequest.getAttribute(Constants.SERVICE_REQUEST);
                    if ((newServiceRequest != null)
                        && (newServiceRequest instanceof SourceBean))
                        serviceRequest = (SourceBean) newServiceRequest;
                } // if (serviceRequest == null)
                emfErrorHandler = loopbackResponseContainer.getErrorHandler();
                if (emfErrorHandler == null)
                    emfErrorHandler = new EMFErrorHandler();
            } // if (isLoop)
            else {
              monitor = MonitorFactory.start("controller.adapter.portlet");
              serviceRequest = new SourceBean(Constants.SERVICE_REQUEST);
              requestContainer.setServiceRequest(serviceRequest);
             
                boolean isMultipart = false;
               
                // only an ActionRequest can have a multipart content
                if (request instanceof ActionRequest && PortletFileUpload.isMultipartContent((ActionRequest) request)) {
                  isMultipart = true;
                }
               
                if (isMultipart) {
                  handleMultipartForm((ActionRequest) request, requestContext);
                } else {
                  handleSimpleForm(request, requestContext);
                }
             
              // ***************** START SERVICE ***********************************************
              String actionName = (String) request.getAttribute("ACTION_NAME");
              if(actionName!=null) {
                request.removeAttribute("ACTION_NAME");
                serviceRequest.setAttribute("ACTION_NAME", actionName);
                serviceRequest.setAttribute(NEW_SESSION, "TRUE");
              }
              String page = (String)request.getAttribute("PAGE");
              if(page!=null) {
                request.removeAttribute("PAGE");
                serviceRequest.setAttribute("PAGE", page);
                serviceRequest.setAttribute(NEW_SESSION, "TRUE");
             
            // *******************************************************************************************
              emfErrorHandler = new EMFErrorHandler();
            }
           
            //***************** NAVIGATION CONTROL *******************************************************
            String navigation = getInitParameter("light_navigation");
            if ("enabled".equalsIgnoreCase(navigation)) {
              serviceRequest = LightNavigationManager.controlLightNavigation(request, serviceRequest);
            }
            //updates service request after LightNavigationManager control
            requestContainer.setServiceRequest(serviceRequest);
            //********************************************************************************************
           
            boolean isRequestedSessionIdValid = true;
            PortletSession session = request.getPortletSession(true);
            /*
            if (session.isNew()) {
                String newSessionString =
                    (String) (serviceRequest.getAttribute(NEW_SESSION));
                isRequestedSessionIdValid =
                    ((newSessionString != null)
                        && (newSessionString.equalsIgnoreCase("TRUE")));
            } // if (session.isNew())
            */
            synchronized (session) {
               
              // try to get the previous request container. Download from the session the previous
              // request container name and if it isn't null (it's null only formthe first invocation)
              //use it for download the request container object
              RequestContainer parentRequestContainer = null;
             
              //**************** START MODFIFICATION ZERBETTO 09-10-2006 ****************
              //String parentRequestContainerName =
              //  (String) session.getAttribute(REQUEST_CONTAINER_NAME);
              //if(parentRequestContainerName != null) {
              //  parentRequestContainer = (RequestContainer) session.getAttribute(parentRequestContainerName);
              //}
              parentRequestContainer = (RequestContainer) session.getAttribute(Constants.REQUEST_CONTAINER);
              //**************** END MODFIFICATION ZERBETTO 09-10-2006 ****************

                if (!Navigator.isNavigatorEnabled()) {
                    if (parentRequestContainer == null)
                        requestContainer.setSessionContainer(
                            new PortletSessionContainer(true));
                    else
                        requestContainer.setSessionContainer(
                            parentRequestContainer.getSessionContainer());
                }
                else {
                    if (parentRequestContainer == null)
                        requestContainer.setSessionContainer(
                            new PortletSessionContainer(true));
                    else {
                        requestContainer.setSessionContainer(
                            new PortletSessionContainer(false));
                        requestContainer.setParent(parentRequestContainer);
                    } // if (parentRequestContainer == null) else
                } // if (!Navigator.isNavigatorEnabled())
               
                //**************** START MODFIFICATION ZERBETTO 09-10-2006 ****************
                //session.setAttribute(Constants.REQUEST_CONTAINER, requestContainer);
                //**************** END MODFIFICATION ZERBETTO 09-10-2006 ****************
               
            } // synchronized (session)
            if (!isRequestedSessionIdValid) {
                TracerSingleton.log(
                    Constants.NOME_MODULO,
                    TracerSingleton.WARNING,
                    "AdapterPortlet::processAction: sessione scaduta !");
                SessionExpiredUtility.setSessionExpiredAction(serviceRequest);
            } // if (!isRequestedSessionIdValid)
           
            requestContainer.setAttribute(
                    HTTP_SESSION_ID,
                    request.getPortletSession().getId());
            String channelType = "PORTLET";
            String channelTypeParameter =
                (String) (serviceRequest.getAttribute(Constants.CHANNEL_TYPE));
            String channelTypeHeader =
                (String) (requestContainer.getAttribute(HTTP_ACCEPT_HEADER));
            if (((channelTypeParameter != null)
                && channelTypeParameter.equalsIgnoreCase(Constants.WAP_CHANNEL))
                || ((channelTypeHeader != null)
                    && (channelTypeHeader.indexOf(WAP_MIME_TYPE) != -1)))
                channelType = Constants.WAP_CHANNEL;
            requestContainer.setChannelType(channelType);


            TracerSingleton.log(
                Constants.NOME_MODULO,
                TracerSingleton.DEBUG,
                "AdapterPortlet::processAction: requestContainer",
                requestContainer);
            TracerSingleton.log(
                Constants.NOME_MODULO,
                TracerSingleton.DEBUG,
                "AdapterPortlet::processAction: sessionContainer",
                requestContainer.getSessionContainer());

            responseContainer.setErrorHandler(emfErrorHandler);
            SourceBean serviceResponse =
                new SourceBean(Constants.SERVICE_RESPONSE);
            responseContainer.setServiceResponse(serviceResponse);
            try {
                Navigator.checkNavigation(requestContainer);
            } // try
            catch (NavigationException ne) {
View Full Code Here


  private final static String INCLUDES_TAG = "INCLUDES";
  private final static String INCLUDE_TAG = "INCLUDE";
  private final static String URL_TAG = "URL";
 
  public void initIncludes() {
    SourceBean includesSB;
    List includeSBList;
    SourceBean includeSB;
    List urlSBList;
    SourceBean urlSB;
   
    includes = new HashMap();
    enabledIncludes = new LinkedHashSet();
   
    includesSB = (SourceBean) getConfigSourceBean().getAttribute(INCLUDES_TAG);
    if(includesSB == null) {
      logger.debug("Tag [" + INCLUDES_TAG + "] not specifeid in [engine-config.xml] file");
      return;
    }
   
    includeSBList = includesSB.getAttributeAsList(INCLUDE_TAG);
    if(includeSBList == null || includeSBList.size() == 0) {
      logger.debug("Tag [" + INCLUDES_TAG + "] does not contains any [" + INCLUDE_TAG + "] tag");
      return;
    }
   
    for(int i = 0; i < includeSBList.size(); i++) {
      includeSB = (SourceBean)includeSBList.get(i);
      String name = (String)includeSB.getAttribute("name");
      String bydefault = (String)includeSB.getAttribute("default");
     
      logger.debug("Include [" + name + "]: [" + bydefault + "]");
     
      List urls = new ArrayList();
     
      urlSBList = includeSB.getAttributeAsList(URL_TAG);
      for(int j = 0; j < urlSBList.size(); j++) {
        urlSB = (SourceBean)urlSBList.get(j);
        String url = urlSB.getCharacters();
        urls.add(url);
        logger.debug("Url [" + name + "] added to include list");
      }
     
      includes.put(name, urls);
View Full Code Here

     * @param requestContext the request context
     *
     * @throws Exception the exception
     */
    private void handleMultipartForm(ActionRequest request, RequestContextIFace requestContext) throws Exception {
      SourceBean serviceRequest = requestContext.getServiceRequest();
     
      // Create a factory for disk-based file items
      FileItemFactory factory = new DiskFileItemFactory();
     
        // Create a new file upload handler
      PortletFileUpload upload = new PortletFileUpload(factory);

        // Parse the request
        List fileItems = upload.parseRequest(request);
        Iterator iter = fileItems.iterator();
        while (iter.hasNext()) {
            FileItem item = (FileItem) iter.next();

            if (item.isFormField()) {
                String name = item.getFieldName();
                String value = item.getString();
                serviceRequest.setAttribute(name, value);
            } else {
                processFileField(item, requestContext);
            }
        }
    }
View Full Code Here

     * @param requestContext the request context
     *
     * @throws SourceBeanException the source bean exception
     */
    private void handleSimpleForm(PortletRequest request, RequestContextIFace requestContext) throws SourceBeanException {
      SourceBean serviceRequest = requestContext.getServiceRequest();
      Enumeration names = request.getParameterNames();
        while (names.hasMoreElements()) {
            String parameterName = (String) names.nextElement();
            String[] parameterValues =
                request.getParameterValues(parameterName);
            if (parameterValues != null)
                for (int i = 0; i < parameterValues.length; i++)
                    serviceRequest.setAttribute(
                        parameterName,
                        parameterValues[i]);
        } // while (names.hasMoreElements())
  }   
View Full Code Here

              if (publisherType
                  .equalsIgnoreCase(Constants.LOOP_PUBLISHER_TYPE)
                  || publisherType.equalsIgnoreCase(SERVLET_PUBLISHER_TYPE)
                  || publisherType.equalsIgnoreCase(JSP_PUBLISHER_TYPE)) {           
                  Iterator iterator = resources.iterator();
                  SourceBean resourceSourceBean = null;               
                while (iterator.hasNext()) {
                  resourceSourceBean = (SourceBean)iterator.next();
                  if ( ((String)resourceSourceBean.getAttribute("mode")).equalsIgnoreCase(portletMode) )
                    break;
                }
                if (resourceSourceBean == null) {
                    TracerSingleton.log(Constants.NOME_MODULO, TracerSingleton.MAJOR,
                          "AdapterPortlet::doView: no resources defined for mode " + portletMode);
                } else
                  resource = (String)resourceSourceBean.getAttribute("resource");
                                                           
                  RouterPortlet router = new RouterPortlet(resource);
                  try {
                    //**************** START MODFIFICATION ZERBETTO 09-10-2006 ****************
                      //router.setParameter(Constants.REQUEST_CONTAINER, requestContainerName);
View Full Code Here

    return config;
  }
 
  public IConnection getConnection(String connectionName) {
    IConnection connection = null;
    SourceBean connSb;
    String connectionType;
   
    if(connectionName == null) return null;
   
    try {
      connSb = (SourceBean)config.getFilteredSourceBeanAttribute("CONNECTIONS-CONFIGURATION.CONNECTION", "name", connectionName);
      connectionType = (String)connSb.getAttribute("type");
     
      if(connectionType == null) {
        logger.error("Attribute 'type' of connection " + connectionName + " is not setted");
      }else if(connectionType.equalsIgnoreCase("jndi")) {
        connection = new JNDIConnection(connSb);
View Full Code Here

    RequestContainer requestContainer = requestContext.getRequestContainer();
    ResponseContainer responseContainer = requestContext.getResponseContainer();

    // Prepare service request for loopback management
        try {
            SourceBean loopbackServiceRequest = new SourceBean(Constants.SERVICE_REQUEST);
            loopbackServiceRequest.setAttribute(Navigator.NAVIGATOR_DISABLED, "TRUE");
           
            SourceBean renderingConfig = publisher.getRenderingConfig();
            List resourcesConfig = renderingConfig.getAttributeAsList("RESOURCES.PARAMETER");
            for (int j = 0; j < resourcesConfig.size(); j++) {
                SourceBean consequence = (SourceBean) resourcesConfig.get(j);
                String parameterName = (String) consequence.getAttribute("NAME");
                String parameterScope = (String) consequence.getAttribute("SCOPE");
                String parameterType = (String) consequence.getAttribute("TYPE");
                String parameterValue = (String) consequence.getAttribute("VALUE");
                Object inParameterValue = null;
                if (parameterType.equalsIgnoreCase("ABSOLUTE"))
                    inParameterValue = parameterValue;
                else {
                  inParameterValue = ContextScooping.getScopedParameter(requestContainer,
View Full Code Here

    return connection;
  }
 
  public String getDefaultConnectionName() {
    String defaultConnectionName = null;
    SourceBean connSb;
   
    connSb = (SourceBean)config.getAttribute("CONNECTIONS-CONFIGURATION");
    defaultConnectionName = (String)connSb.getAttribute("defaultConnectionName");
   
    return defaultConnectionName;
  }
View Full Code Here

 
  public String getPublisherName(RequestContainer request,
      ResponseContainer response) {
    logger.debug("IN");
    String publisherName = null;
    SourceBean serviceResponse = response.getServiceResponse();
    publisherName = (String) serviceResponse.getAttribute(PUBLISHER_NAME);
    logger.debug("OUT: publisherName = " + publisherName);
    return publisherName;
  }
View Full Code Here

    List roles = new ArrayList();
    ConfigSingleton config = ConfigSingleton.getInstance();
    List sb_roles = config.getAttributeAsList("AUTHORIZATIONS.ENTITIES.ROLES.ROLE");
    Iterator iter_sb_roles = sb_roles.iterator();
    while(iter_sb_roles.hasNext()) {
      SourceBean roleSB = (SourceBean)iter_sb_roles.next();
      String roleName = (String)roleSB.getAttribute("roleName");
      String roleDescription = (String)roleSB.getAttribute("description");
      Role role = new Role(roleName, roleDescription);
      logger.debug("ADD: roleName="+roleName);
      roles.add(role);
    }
    logger.debug("OUT");
View Full Code Here

TOP

Related Classes of it.eng.spago.base.SourceBean

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.