Package org.exist.xquery

Examples of org.exist.xquery.Variable


  {
   
    final SessionModule myModule = (SessionModule)context.getModule(SessionModule.NAMESPACE_URI);
   
    // session object is read from global variable $session
    final Variable var = myModule.resolveVariable( SessionModule.SESSION_VAR );
   
    if( var == null || var.getValue() == null ) {
      // throw( new XPathException( this, "Session not set" ) );
      return( XPathUtil.javaObjectToXPath( Integer.valueOf(-1), context ) );
    }
   
    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 ) );
View Full Code Here


    public Sequence eval(Sequence[] args, Sequence contextSequence)
            throws XPathException {
     
        final SessionModule myModule = (SessionModule)context.getModule(SessionModule.NAMESPACE_URI);
        // session object is read from global variable $session
    final Variable var = myModule.resolveVariable(SessionModule.SESSION_VAR);
    if(var == null || var.getValue() == null) {
      //Always called as "invalidate") because the translation is made at compile time     
      if (!isCalledAs("invalidate"))
        {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
View Full Code Here

   * @param user  The User to cache in the session
   * @param createSession  Create session?
   */
  private void cacheUserInHttpSession( Subject user, boolean createSession ) throws XPathException
  {
    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

   * @param createSession  Create session?
   */
  private Variable getSessionVar( boolean createSession ) throws XPathException
  {
    final SessionModule sessionModule = (SessionModule)context.getModule( SessionModule.NAMESPACE_URI );
        Variable var = sessionModule.resolveVariable( SessionModule.SESSION_VAR );
   
    if( createSession && ( var == null || var.getValue() == null ) ) {
      SessionWrapper session  = null;
      final RequestModule reqModule = (RequestModule)context.getModule( RequestModule.NAMESPACE_URI );
   
      // request object is read from global variable $request
      final Variable reqVar = reqModule.resolveVariable( RequestModule.REQUEST_VAR );
     
      if( reqVar == null || reqVar.getValue() == null ) {
          logger.error("No request object found in the current XQuery context.");

          throw( new XPathException( this, "No request object found in the current XQuery context." ) );
      }
      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 );
      }
View Full Code Here

    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 );
     
View Full Code Here

        }

        final ResponseModule myModule = (ResponseModule)context.getModule(ResponseModule.NAMESPACE_URI);
       
        // response object is read from global variable $response
        final Variable respVar = myModule.resolveVariable(ResponseModule.RESPONSE_VAR);
       
        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();
View Full Code Here

      context.setDebuggeeJoint(joint);
     
      String idesession = "";
      if (context.isVarDeclared(Debuggee.SESSION)) {
        try {
          Variable var = context.resolveVariable(Debuggee.SESSION);
          idesession = var.getValue().toString();
        } catch (XPathException e) {
        }
      }
     
      String idekey = "";
      if (context.isVarDeclared(Debuggee.IDEKEY)) {
        try {
          Variable var = context.resolveVariable(Debuggee.IDEKEY);
          idekey = var.getValue().toString();
        } catch (XPathException e) {
        }
      }
     
      joint.continuation(new Init(session, idesession, idekey));
View Full Code Here

        final ResponseModule myModule = (ResponseModule) context
            .getModule(ResponseModule.NAMESPACE_URI);
        if (myModule == null)
          {return;}
        // response servlet object is read from global variable $response
        final Variable var = myModule.resolveVariable(ResponseModule.RESPONSE_VAR);
       
        if (var != null && var.getValue() != null) {
          final JavaObjectValue value = (JavaObjectValue) var.getValue()
              .itemAt(0);
          if (value != null
              && value.getObject() instanceof ResponseWrapper) {
            // have to take in account that if the header has allready been explicitely set
            // by the XQuery script, we should not modify it .
View Full Code Here

TOP

Related Classes of org.exist.xquery.Variable

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.