Package org.exist.xquery.value

Examples of org.exist.xquery.value.JavaObjectValue


   
    if( var.getValue().getItemType() != Type.JAVA_OBJECT ) {
      throw( new XPathException( this, "Variable $session is not bound to a Java object." ) );
    }

    final JavaObjectValue session = (JavaObjectValue)var.getValue().itemAt( 0 );
   
    if( session.getObject() instanceof SessionWrapper ) {
      try {
        final long lastAccessedTime = ( (SessionWrapper)session.getObject() ).getLastAccessedTime();
        return new DateTimeValue(new Date(lastAccessedTime));
      }
      catch( final IllegalStateException ise ) {
        return new DateTimeValue(new Date(0));
      }
View Full Code Here


    final Variable var = myModule.resolveVariable(RequestModule.REQUEST_VAR);
    if(var == null || var.getValue() == null)
      {throw new XPathException(this, "No request object found in the current XQuery context.");}
    if (var.getValue().getItemType() != Type.JAVA_OBJECT)
      {throw new XPathException(this, "Variable $request is not bound to an Java object.");}
    final JavaObjectValue value = (JavaObjectValue) var.getValue().itemAt(0);
   
    if(value.getObject() instanceof RequestWrapper)
    {
      final RequestWrapper request = (RequestWrapper)value.getObject();
   
      //get the username and password parameters
      final String userName = args[0].getStringValue();
      final String passwd = args[1].getStringValue();
     
View Full Code Here

    }
   
    // get parameters
    final String url = args[0].getStringValue();
   
    final JavaObjectValue value = (JavaObjectValue)
      var.getValue().itemAt(0);
    if(value.getObject() instanceof ResponseWrapper) {
      return new AnyURIValue(((ResponseWrapper)value.getObject()).encodeURL(url));
    } else {
      throw new XPathException(this, "Variable $response is not bound to a Response object.");
    }
  }
View Full Code Here

   
    if( var.getValue().getItemType() != Type.JAVA_OBJECT ) {
      throw( new XPathException( this, "Variable $session is not bound to a Java object." ) );
    }

    final JavaObjectValue session = (JavaObjectValue)var.getValue().itemAt( 0 );
   
    if( session.getObject() instanceof SessionWrapper ) {
      try {
        final int interval = ( (SessionWrapper)session.getObject() ).getMaxInactiveInterval();
        return( XPathUtil.javaObjectToXPath( Integer.valueOf(interval), context ) );
      }
      catch( final IllegalStateException ise ) {
        return( XPathUtil.javaObjectToXPath( Integer.valueOf(-1), context ) );
      }
View Full Code Here

        {throw new XPathException(this, SessionModule.SESSION_VAR + " not set");}
      return Sequence.EMPTY_SEQUENCE;
    }
    if(var.getValue().getItemType() != Type.JAVA_OBJECT)
      {throw new XPathException(this, SessionModule.SESSION_VAR + " is not bound to a Java object.");}
    final JavaObjectValue value = (JavaObjectValue) var.getValue().itemAt(0);
    if(value.getObject() instanceof SessionWrapper) {
      final SessionWrapper session = (SessionWrapper)value.getObject();
      session.invalidate();
      return Sequence.EMPTY_SEQUENCE;
    } else
      {throw new XPathException(this, SessionModule.SESSION_VAR + " is not bound to a session object");}
    }
View Full Code Here

  {
    final Variable var = getSessionVar( createSession );
   
        if( var != null && var.getValue() != null ) {
        if( var.getValue().getItemType() == Type.JAVA_OBJECT ) {
            final JavaObjectValue session = (JavaObjectValue) var.getValue().itemAt(0);
           
            if( session.getObject() instanceof SessionWrapper ) {
              ((SessionWrapper)session.getObject()).setAttribute( XQueryContext.HTTP_SESSIONVAR_XMLDB_USER, user );
            }
        }
      }
  }
View Full Code Here

      if( reqVar.getValue().getItemType() != Type.JAVA_OBJECT ) {
          logger.error( "Variable $request is not bound to an Java object.");
        throw( new XPathException( this, "Variable $request is not bound to an Java object." ) );
      }
     
      final JavaObjectValue reqValue = (JavaObjectValue)reqVar.getValue().itemAt( 0) ;
     
      if( reqValue.getObject() instanceof RequestWrapper ) {
        session = ((RequestWrapper)reqValue.getObject()).getSession( true );
        var = sessionModule.declareVariable( SessionModule.SESSION_VAR, session );
      }
    }
    return( var );
  }
View Full Code Here

  
   * @param context
   */
  static JavaObjectValue createSession( XQueryContext context, Function fn ) throws XPathException
  {
    JavaObjectValue ret = null;
   
    final RequestModule myModule = (RequestModule)context.getModule( RequestModule.NAMESPACE_URI );
   
    // request object is read from global variable $request
    final Variable var = myModule.resolveVariable( RequestModule.REQUEST_VAR );
   
    if( var == null || var.getValue() == null ) {
      throw( new XPathException( fn, "No request object found in the current XQuery context." ) );
    }
 
    if( var.getValue().getItemType() != Type.JAVA_OBJECT ) {
      throw( new XPathException( fn, "Variable $request is not bound to an Java object." ) );
    }

    final JavaObjectValue value = (JavaObjectValue)var.getValue().itemAt( 0 );
   
    if( value.getObject() instanceof RequestWrapper ) {
      final SessionModule  sessionModule   = (SessionModule)context.getModule( SessionModule.NAMESPACE_URI );
      final SessionWrapper session       = ((RequestWrapper)value.getObject()).getSession( true );
     
      sessionModule.declareVariable( SessionModule.SESSION_VAR, session );
      ret = (JavaObjectValue)sessionModule.resolveVariable( SessionModule.SESSION_VAR ).getValue().itemAt( 0 );
    } else {
      throw( new XPathException( fn, "Variable $request is not bound to a Request object." ) );
View Full Code Here

        if(respVar == null)
            {throw new XPathException(this, "No response object found in the current XQuery context.");}
       
        if(respVar.getValue().getItemType() != Type.JAVA_OBJECT)
            {throw new XPathException(this, "Variable $response is not bound to an Java object.");}
        final JavaObjectValue respValue = (JavaObjectValue) respVar.getValue().itemAt(0);
       
        if (!"org.exist.http.servlets.HttpResponseWrapper".equals(respValue.getObject().getClass().getName()))
            {throw new XPathException(this, signature.toString() + " can only be used within the EXistServlet or XQueryServlet");}
       
        final ResponseWrapper response = (ResponseWrapper) respValue.getObject();
       
        final String mediaType = serializeOptions.getProperty("media-type", "application/xml");
        final String encoding = serializeOptions.getProperty("encoding", "UTF-8");
        if(mediaType != null) {
            response.setContentType(mediaType + "; charset=" + encoding);
View Full Code Here

       
        Sequence result;
    if (bestMethod instanceof Constructor<?>) {
      try {
        final Object object = ((Constructor<?>) bestMethod).newInstance(params);
                result = new JavaObjectValue(object);
      } catch (final IllegalArgumentException e) {
        throw new XPathException(this,
          "illegal argument to constructor "
            + bestMethod.toString()
            + ": "
View Full Code Here

TOP

Related Classes of org.exist.xquery.value.JavaObjectValue

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.