Package org.apache.slide.common

Examples of org.apache.slide.common.ServiceAccessException


    long start = System.currentTimeMillis();
        DirContext ctx = null;
        try {
            ctx = getContext();
        } catch ( ServiceConnectionFailedException e ) {
            throw new ServiceAccessException(this, e);
        }
        Uri parentUri = uri.getParentUri();
    String objectName = getObjectNameFromUri( uri );
   
    Vector parentBindings = new Vector();
    Vector childBindings = new Vector();

    // As long as this node isn't the root node create a parent binding.
    // This doesn't appear to do anything, but just in case.
    if ( !uri.toString().equals( "/" ) ) {
      parentBindings.add( new ObjectNode.Binding( objectName, parentUri.toString() ) );
    }
   
    SearchControls controls = new SearchControls();
    controls.setSearchScope( searchScope );

    // If the uri matches the scope create a SubjectNode with bindings for all
    // of the results from a jndi search
    if ( uri.isStoreRoot() ) {
     
      try {
        NamingEnumeration results = ctx.search(
          container,
          filter,
          controls );

        if ( !results.hasMore() ) {
          getLogger().log(
            name + ": No objects found in container " + container +
            " that match filter " + filter + ".",
            LOG_CHANNEL,
            Logger.WARNING );
        }
        while ( results.hasMore() ) {
          SearchResult result = null;
          try {
            result = (SearchResult)results.next();
          } catch ( NamingException e ) {
            getLogger().log(
              name + ": Error getting next search result.",
              e, LOG_CHANNEL, Logger.ERROR );
          }
          String name = result.getName();
          if ( !validatePathName( name ) ) {
            continue;
          }
          String value = parseLdapName(name);
          if (principalNameAttribute != null) {
            String uriValue = ((String)result.getAttributes().get(principalNameAttribute).get()).toLowerCase();
            objectNameMap.put(uriValue, value);
            value = uriValue;
          }
         
          getLogger().log(
            name + ": Creating child binding \"" + value + "\" for \"" +
            uri.toString() + "\".",
            LOG_CHANNEL, Logger.DEBUG );
         
          childBindings.add(
            new ObjectNode.Binding( value, uri.toString() + "/" + value ) );

        }
      } catch ( NamingException e ) {
        getLogger().log(
          name + ": Error during search.",
          e, LOG_CHANNEL, Logger.ERROR );
      }
    } else {
      // If the uri matches the scope + something try to do a lookup
      // of the "+ something" in LDAP.
     
      try {
        if (principalNameAttribute != null && objectNameMap.get(objectName) == null)
          retrieveObject(parentUri);
        NamingEnumeration results = ctx.search(
          container,
          rdnAttribute + "=" + (principalNameAttribute != null ? (String)objectNameMap.get(objectName) : objectName),
          controls);

        if ( !results.hasMore() ) {
                    if (ctx != null) {
                        closeContext(ctx);
                    }
          throw new ObjectNotFoundException( uri );
        }
      } catch ( NamingException e ) {
        getLogger().log(
          name + ": Error retrieving " + uri.toString(),
          e, LOG_CHANNEL, Logger.ERROR );
                if (ctx != null) {
                    closeContext(ctx);
                }
        throw new ServiceAccessException( this, e );
      }
    }

    getLogger().log( name + ": Creating SubjectNode for \"" + uri.toString() + "\".",
      LOG_CHANNEL, Logger.DEBUG );
View Full Code Here


    long start = System.currentTimeMillis();
        DirContext ctx = null;
        try {
            ctx = getContext();
        } catch ( ServiceConnectionFailedException e ) {
            throw new ServiceAccessException(this, e);
        }
   
    String objectName = getObjectNameFromUri( uri );
   
    Hashtable props = new Hashtable();
   
    String resourceType = "<collection/>";
    if ( !uri.isStoreRoot() ) {
      resourceType += "<principal/>";
    }
    props.put(
      "DAV:resourcetype",
      new NodeProperty( "resourcetype", resourceType, "DAV:", "", false ) );
    props.put(
      "DAV:displayname",
      new NodeProperty( "displayname", (!uri.isStoreRoot() && principalNameAttribute != null?(String)objectNameMap.get(objectName):objectName), "DAV:", "", false ) );
   
    // The storeRoot isn't a real object so it doesn't have any parameters to look up
    if ( !uri.isStoreRoot() ) {
           
      String localFilter = rdnAttribute + "=" + (principalNameAttribute != null?(String)objectNameMap.get(objectName):objectName);
       
      SearchControls controls = new SearchControls();
      controls.setSearchScope( searchScope );
      controls.setReturningAttributes( descriptorAttributes );
     
      try {
        NamingEnumeration results = ctx.search(
          container,
          localFilter,
          controls );

        if ( !results.hasMore() ) {
                    if (ctx != null) {
                        closeContext(ctx);
                    }
          throw new RevisionDescriptorNotFoundException( uri.toString() );
        }
        while ( results.hasMore() ) {
          SearchResult result = null;
          try {
            result = (SearchResult)results.next();
          } catch ( NamingException e ) {
            getLogger().log(
              name + ": Error getting search result with filter: " + localFilter +
              " from container: " + container + ".",
              LOG_CHANNEL, Logger.ERROR );
                        if (ctx != null) {
                            closeContext(ctx);
                        }
            throw new ServiceAccessException( this, e );
          }
         
          NamingEnumeration attributes = result.getAttributes().getAll();
          while ( attributes.hasMore() ) {
            Attribute attribute = (Attribute)attributes.next();
View Full Code Here

      } finally {
        close(statement);
      }
    } catch (SQLException e) {
      getLogger().log(e, LOG_CHANNEL, Logger.ERROR);
      throw new ServiceAccessException(service, e);
    }
  }
View Full Code Here

      } finally {
        close(statement);
      }
    } catch (Exception e) {
      getLogger().log(e, LOG_CHANNEL, Logger.ERROR);
      throw new ServiceAccessException(service, e);
    }
  }
View Full Code Here

      } finally {
        close(statement);
      }
    } catch (SQLException e) {
      getLogger().log(e, LOG_CHANNEL, Logger.ERROR);
      throw new ServiceAccessException(service, e);
    }
  }
View Full Code Here

      } finally {
        close(statement);
      }
    } catch (SQLException e) {
      getLogger().log(e, LOG_CHANNEL, Logger.ERROR);
      throw new ServiceAccessException(service, e);
    }
  }
View Full Code Here

      statement.setString(3, permission.getActionUri());
            statement.setString(3, revisionNumber.toString());
      statement.executeUpdate();
    } catch (SQLException e) {
      getLogger().log(e, LOG_CHANNEL, Logger.ERROR);
      throw new ServiceAccessException(service, e);
    } finally {
      close(statement);
    }
  }
View Full Code Here

          "delete from PERMISSIONS where PERMISSIONS.OBJECT_ID = URI.URI_ID and URI.URI_STRING = ?");
      statement.setString(1, uri.toString());
      statement.executeUpdate();
    } catch (SQLException e) {
      getLogger().log(e, LOG_CHANNEL, Logger.ERROR);
      throw new ServiceAccessException(service, e);
    } finally {
      close(statement);
    }
  }
View Full Code Here

   
        if (sqlstate != null) {
            if (sqlstate.startsWith("23")) {
                getLogger().log(e.getErrorCode() + ": Deadlock resolved on " + uri,
                    LOG_CHANNEL, Logger.WARNING);
                return new ServiceAccessException(service, new ConflictException(uri));
            } else if (sqlstate.startsWith("40")) {
                getLogger().log(
                    e.getErrorCode() + ": Deadlock resolved on " + uri,
                    LOG_CHANNEL,
                    Logger.WARNING);
                return new ServiceAccessException(service, new ConflictException(uri));
            } else {
                getLogger().log(
                    "SQL error "
                        + e.getErrorCode()
                        + " on "
                        + uri
                        + ": "
                        + e.getMessage(),
                    LOG_CHANNEL,
                    Logger.ERROR);

                return new ServiceAccessException(service, e);
            }
        }
        else {
            return super.createException(e, uri);
        }
View Full Code Here

        try {
            statement = conn.prepareStatement(query);
            statement.executeUpdate();
            return true;
        } catch (SQLException e) {
            throw new ServiceAccessException(service, e);
        } finally {
            close(statement);
        }

    }
View Full Code Here

TOP

Related Classes of org.apache.slide.common.ServiceAccessException

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.