Package nexj.core.rpc

Examples of nexj.core.rpc.RequestException


               {
                  receive(createMessage(message), m_channel, context);
               }
               else
               {
                  throw new RequestException("err.rpc.jms.unknownMessage");
               }
            }
         }

         public void err(Throwable t, InvocationContext context) throws Throwable
View Full Code Here


   {
      String sAction = request.getHeader("SOAPAction");

      if (sAction == null)
      {
         throw new RequestException("err.rpc.soap.missingActionHeader");
      }

      int i = 0;
      int k = sAction.length();

      if (i < k && sAction.charAt(i) == '"')
      {
         ++i;
      }

      if (k > i && sAction.charAt(k - 1) == '"')
      {
         --k;
      }
     
      sAction = sAction.substring(i, k);

      if (!sAction.equals("Server#invoke"))
      {
         throw new RequestException("err.rpc.soap.action", new Object[]{sAction});
      }
   }
View Full Code Here

   {
      String sPath = m_request.getPathInfo();

      if (sPath == null || sPath.length() <= 1)
      {
         throw new RequestException("err.rpc.http.channel");
      }

      int i = sPath.indexOf('/', 1);
      String sChannel;

      if (i < 0)
      {
         sChannel = sPath.substring(1);
         sPath = "";
      }
      else
      {
         sChannel = sPath.substring(1, i);
         sPath = sPath.substring(i);
      }

      Metadata metadata = m_context.getMetadata();
      Channel channel = metadata.getChannel(sChannel);

      if (!(channel instanceof HTTPChannel) || !channel.isReceivable())
      {
         throw new RPCException("err.rpc.http.notReceiver", new Object[]{sChannel});
      }
     
      HTTPChannel http = (HTTPChannel)channel;

      if (http.isSecure() && !m_request.isSecure())
      {
         throw new RequestException("err.rpc.http.insecure", new Object[]{sChannel});
      }

      // Deny anonymous access to non-anonymous channels, and vice-versa
      if (HTTPUtil.isAnonymousRequest(m_request, metadata))
      {
View Full Code Here

        
         return paramMap;
      }
      catch (IOException e)
      {
         throw new RequestException("err.rpc.attachment", e);
      }
   }
View Full Code Here

      {
         Object req = paramMap.get("request");

         if (!(req instanceof String[]) || ((String[])req).length != 1)
         {
            throw new RequestException("err.rpc.attachment");
         }

         req = ((String[])req)[0];

         if (m_bURLEncoded)
View Full Code Here

            metaclass = m_context.getMetadata().findMetaclass(sClassName);

            if (metaclass == null)
            {
               throw new RequestException("err.rpc.xml.class", new Object[]{sClassName});
            }
         }

         sContext = (nClassEndIndex < sContext.length()) ? sContext.substring(nClassEndIndex + 1) : "";

         String sMethod = getMethod();

         if (metaclass == null && sMethod.equals(HTTP.METHOD_GET))
         {
            // Generate schema

            XSDGenerator generator;

            if (getParameter("xsd") != null)
            {
               generator = new XSDGenerator();
            }
            else if (m_bWrapped)
            {
               if (getParameter("basic") != null)
               {
                  generator = new WSDLBasicGenerator(SOAP_ACTION_BASIC);
               }
               else
               {
                  generator = new WSDLGenerator(SOAP_ACTION_DEFAULT);
               }
            }
            else
            {
               generator = new WADLGenerator();
            }

            generator.setCompatible(StringUtil.isEmpty(getParameter("compatible")) ||
                                    StringUtil.parseBoolean(getParameter("compatible")));
            generator.setIncludeDocumentation(getParameter("doc") != null);

            String sMask = getParameter("mask");

            if (sMask != null)
            {
               generator.setMask(sMask.split("\\s+"));
            }

            String sScope = getParameter("scope");

            if ("none".equals(sScope) || "generic".equals(sScope))
            {
               generator.setScope(XSDGenerator.SCOPE_GENERIC);
            }
            else if ("state".equals(sScope))
            {
               generator.setScope(XSDGenerator.SCOPE_STATE);
            }
            else if ("behavior".equals(sScope) || "behaviour".equals(sScope))
            {
               generator.setScope(XSDGenerator.SCOPE_BEHAVIOUR);
            }
            else if (sScope != null)
            {
               throw new IllegalArgumentException("Invalid SCOPE value.");
            }

            List metaclassList = Collections.list(new IteratorEnumeration(m_context.getMetadata().getMetaclassIterator()));

            Collections.sort(metaclassList, Metaclass.COMPARATOR);

            setResponseContentType(generator.getMIMEType());

            Writer writer = getWriter();

            writer.write(XML_HEADER);
            generator.generate(writer, metaclassList.iterator(), m_request.getRequestURL().toString());
         }
         else
         {
            // Invoke the generic server

            Object request;

            try
            {
               request = unmarshal(metaclass, sContext);
            }
            catch (Exception e)
            {
               if (e instanceof ClassCastException ||
                  e instanceof NumberFormatException ||
                  e instanceof TypeConversionException)
               {
                  throw new RequestException("err.rpc.xml.request", e);
               }

               throw e;
            }

            Server server = (Server)m_server.getInstance(m_context);
            Object response;

            if (request instanceof Invoker)
            {
               Invoker invoker = (Invoker)request;

               invoker.setLocale(m_request.getLocale());
               response = invoker.invoke(server);
            }
            else if (request instanceof Request)
            {
               response = server.invoke((Request)request);
            }
            else
            {
               throw new RequestException("err.rpc.xml.request");
            }

            if (sMethod.equals(HTTP.METHOD_DELETE))
            {
               return;
View Full Code Here

   /**
    * @return An invalid method exception.
    */
   protected RequestException createMethodException()
   {
      throw new RequestException("err.rpc.xml.method",
         new Object[]{getMethod(), getRequestURI()});
   }
View Full Code Here

TOP

Related Classes of nexj.core.rpc.RequestException

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.