Package com.cloud.bridge.service.controller.s3

Examples of com.cloud.bridge.service.controller.s3.ServiceProvider


        // to buckets, wherever the request is made up of a service endpoint followed by a /, in AWS S3 this always
        // conveys a ListAllMyBuckets command

        if  ( (serviceEndpoint.equalsIgnoreCase( host )) && (pathInfo.equalsIgnoreCase("/")) ) {
            request.setAttribute(S3Constants.BUCKET_ATTR_KEY, "/");
            return new S3BucketAction();   // for ListAllMyBuckets
        }

        // Because there is a leading / at position 0 of pathInfo, now subtract this to process the remainder 
        pathInfo = pathInfo.substring(1);

        if (ServiceProvider.getInstance().getUseSubDomain())

        {      
            // -> verify the format of the bucket name
            int endPos = host.indexOf( ServiceProvider.getInstance().getMasterDomain());
            if ( endPos > 0 )
            {
                bucketName = host.substring(0, endPos);
                S3Engine.verifyBucketName( bucketName, false );
                request.setAttribute(S3Constants.BUCKET_ATTR_KEY, bucketName);
            }
            else request.setAttribute(S3Constants.BUCKET_ATTR_KEY, "");

            if (pathInfo == null || pathInfo.equalsIgnoreCase("/"))
            {
                return new S3BucketAction();
            }
            else {
                String objectKey = pathInfo.substring(1);
                request.setAttribute(S3Constants.OBJECT_ATTR_KEY, objectKey);
                return new S3ObjectAction();
            }
        }

        else

        {

            int endPos = pathInfo.indexOf('/')// Subsequent / character?

            if (endPos < 1)
            {
                bucketName = pathInfo;
                S3Engine.verifyBucketName( bucketName, false );
                request.setAttribute(S3Constants.BUCKET_ATTR_KEY, bucketName);
                return new S3BucketAction();
            }
            else
            {
                bucketName = pathInfo.substring(0, endPos);
                key        = pathInfo.substring(endPos + 1);     
                S3Engine.verifyBucketName( bucketName, false );

                if (!key.isEmpty())
                {
                    request.setAttribute(S3Constants.BUCKET_ATTR_KEY, bucketName);
                    request.setAttribute(S3Constants.OBJECT_ATTR_KEY, pathInfo.substring(endPos + 1));
                    return new S3ObjectAction();
                }
                else {
                    request.setAttribute(S3Constants.BUCKET_ATTR_KEY, bucketName);
                    return new S3BucketAction();
                }
            }
        }
    }
View Full Code Here


        String host            = request.getHeader("Host");
       
        // -> a request of "/" on the service endpoint means do a list all my buckets command
        if (serviceEndpoint.equalsIgnoreCase( host )) {
          request.setAttribute(S3Constants.BUCKET_ATTR_KEY, "/");
          return new S3BucketAction();
        }
       
        // -> verify the format of the bucket name
        int endPos = host.indexOf( ServiceProvider.getInstance().getMasterDomain());
        if ( endPos > 0 )
        {
           bucketName = host.substring(0, endPos);
           S3Engine.verifyBucketName( bucketName, false );
           request.setAttribute(S3Constants.BUCKET_ATTR_KEY, bucketName);
        }
        else request.setAttribute(S3Constants.BUCKET_ATTR_KEY, "");
       
        if (pathInfo == null || pathInfo.equalsIgnoreCase("/"))
        {
          return new S3BucketAction();
        }
        else {
          String objectKey = pathInfo.substring(1);
          request.setAttribute(S3Constants.OBJECT_ATTR_KEY, objectKey);
          return new S3ObjectAction();
        }
      }
      else
      {
        if(pathInfo == null || pathInfo.equalsIgnoreCase("/")) {
          logger.warn("Invalid REST request URI " + pathInfo);
          return null;
        }
       
        int endPos = pathInfo.indexOf('/', 1);
        if ( endPos > 0 )
        {
           bucketName = pathInfo.substring(1, endPos);
             key        = pathInfo.substring(endPos + 1);     
              S3Engine.verifyBucketName( bucketName, false );
        
           if (!key.isEmpty())
           {
               request.setAttribute(S3Constants.BUCKET_ATTR_KEY, bucketName);
              request.setAttribute(S3Constants.OBJECT_ATTR_KEY, pathInfo.substring(endPos + 1));
              return new S3ObjectAction();
           }
           else {
                request.setAttribute(S3Constants.BUCKET_ATTR_KEY, bucketName);
                return new S3BucketAction();
           }
        }
        else {
           String bucket = pathInfo.substring(1);
           request.setAttribute(S3Constants.BUCKET_ATTR_KEY, bucket);
           return new S3BucketAction();
        }
      }
    }
View Full Code Here

        // to buckets, wherever the request is made up of a service endpoint followed by a /, in AWS S3 this always
        // conveys a ListAllMyBuckets command

        if ((serviceEndpoint.equalsIgnoreCase(host)) && (pathInfo.equalsIgnoreCase("/"))) {
            request.setAttribute(S3Constants.BUCKET_ATTR_KEY, "/");
            return new S3BucketAction();   // for ListAllMyBuckets
        }

        // Because there is a leading / at position 0 of pathInfo, now subtract this to process the remainder
        pathInfo = pathInfo.substring(1);

        if (ServiceProvider.getInstance().getUseSubDomain())

        {
            // -> verify the format of the bucket name
            int endPos = host.indexOf(ServiceProvider.getInstance().getMasterDomain());
            if (endPos > 0) {
                bucketName = host.substring(0, endPos);
                S3Engine.verifyBucketName(bucketName, false);
                request.setAttribute(S3Constants.BUCKET_ATTR_KEY, bucketName);
            } else
                request.setAttribute(S3Constants.BUCKET_ATTR_KEY, "");

            if (pathInfo == null || pathInfo.equalsIgnoreCase("/")) {
                return new S3BucketAction();
            } else {
                String objectKey = pathInfo.substring(1);
                request.setAttribute(S3Constants.OBJECT_ATTR_KEY, objectKey);
                return new S3ObjectAction();
            }
        }

        else

        {

            int endPos = pathInfo.indexOf('/')// Subsequent / character?

            if (endPos < 1) {
                bucketName = pathInfo;
                S3Engine.verifyBucketName(bucketName, false);
                request.setAttribute(S3Constants.BUCKET_ATTR_KEY, bucketName);
                return new S3BucketAction();
            } else {
                bucketName = pathInfo.substring(0, endPos);
                key = pathInfo.substring(endPos + 1);
                S3Engine.verifyBucketName(bucketName, false);

                if (!key.isEmpty()) {
                    request.setAttribute(S3Constants.BUCKET_ATTR_KEY, bucketName);
                    request.setAttribute(S3Constants.OBJECT_ATTR_KEY, pathInfo.substring(endPos + 1));
                    return new S3ObjectAction();
                } else {
                    request.setAttribute(S3Constants.BUCKET_ATTR_KEY, bucketName);
                    return new S3BucketAction();
                }
            }
        }
    }
View Full Code Here

      // to buckets, wherever the request is made up of a service endpoint followed by a /, in AWS S3 this always
      // conveys a ListAllMyBuckets command
     
    if  ( (serviceEndpoint.equalsIgnoreCase( host )) && (pathInfo.equalsIgnoreCase("/")) ) {
      request.setAttribute(S3Constants.BUCKET_ATTR_KEY, "/");
      return new S3BucketAction();   // for ListAllMyBuckets
    }

    // Because there is a leading / at position 0 of pathInfo, now subtract this to process the remainder 
    pathInfo = pathInfo.substring(1);
         
      if (ServiceProvider.getInstance().getUseSubDomain())
       
          {      
        // -> verify the format of the bucket name
        int endPos = host.indexOf( ServiceProvider.getInstance().getMasterDomain());
        if ( endPos > 0 )
        {
           bucketName = host.substring(0, endPos);
           S3Engine.verifyBucketName( bucketName, false );
           request.setAttribute(S3Constants.BUCKET_ATTR_KEY, bucketName);
        }
        else request.setAttribute(S3Constants.BUCKET_ATTR_KEY, "");
       
        if (pathInfo == null || pathInfo.equalsIgnoreCase("/"))
        {
          return new S3BucketAction();
        }
        else {
          String objectKey = pathInfo.substring(1);
          request.setAttribute(S3Constants.OBJECT_ATTR_KEY, objectKey);
          return new S3ObjectAction();
        }
      }
     
      else
       
      {
            
        int endPos = pathInfo.indexOf('/')// Subsequent / character?
       
          if (endPos < 1)
          {
             bucketName = pathInfo;
             S3Engine.verifyBucketName( bucketName, false );
              request.setAttribute(S3Constants.BUCKET_ATTR_KEY, bucketName);
              return new S3BucketAction();
           }
          else
        {
           bucketName = pathInfo.substring(0, endPos);
             key        = pathInfo.substring(endPos + 1);     
              S3Engine.verifyBucketName( bucketName, false );
        
           if (!key.isEmpty())
           {
               request.setAttribute(S3Constants.BUCKET_ATTR_KEY, bucketName);
              request.setAttribute(S3Constants.OBJECT_ATTR_KEY, pathInfo.substring(endPos + 1));
              return new S3ObjectAction();
           }
           else {
                request.setAttribute(S3Constants.BUCKET_ATTR_KEY, bucketName);
                return new S3BucketAction();
           }
        }
      }
    }
View Full Code Here

        // to buckets, wherever the request is made up of a service endpoint followed by a /, in AWS S3 this always
        // conveys a ListAllMyBuckets command

        if  ( (serviceEndpoint.equalsIgnoreCase( host )) && (pathInfo.equalsIgnoreCase("/")) ) {
            request.setAttribute(S3Constants.BUCKET_ATTR_KEY, "/");
            return new S3BucketAction();   // for ListAllMyBuckets
        }

        // Because there is a leading / at position 0 of pathInfo, now subtract this to process the remainder 
        pathInfo = pathInfo.substring(1);

        if (ServiceProvider.getInstance().getUseSubDomain())

        {      
            // -> verify the format of the bucket name
            int endPos = host.indexOf( ServiceProvider.getInstance().getMasterDomain());
            if ( endPos > 0 )
            {
                bucketName = host.substring(0, endPos);
                S3Engine.verifyBucketName( bucketName, false );
                request.setAttribute(S3Constants.BUCKET_ATTR_KEY, bucketName);
            }
            else request.setAttribute(S3Constants.BUCKET_ATTR_KEY, "");

            if (pathInfo == null || pathInfo.equalsIgnoreCase("/"))
            {
                return new S3BucketAction();
            }
            else {
                String objectKey = pathInfo.substring(1);
                request.setAttribute(S3Constants.OBJECT_ATTR_KEY, objectKey);
                return new S3ObjectAction();
            }
        }

        else

        {

            int endPos = pathInfo.indexOf('/')// Subsequent / character?

            if (endPos < 1)
            {
                bucketName = pathInfo;
                S3Engine.verifyBucketName( bucketName, false );
                request.setAttribute(S3Constants.BUCKET_ATTR_KEY, bucketName);
                return new S3BucketAction();
            }
            else
            {
                bucketName = pathInfo.substring(0, endPos);
                key        = pathInfo.substring(endPos + 1);     
                S3Engine.verifyBucketName( bucketName, false );

                if (!key.isEmpty())
                {
                    request.setAttribute(S3Constants.BUCKET_ATTR_KEY, bucketName);
                    request.setAttribute(S3Constants.OBJECT_ATTR_KEY, pathInfo.substring(endPos + 1));
                    return new S3ObjectAction();
                }
                else {
                    request.setAttribute(S3Constants.BUCKET_ATTR_KEY, bucketName);
                    return new S3BucketAction();
                }
            }
        }
    }
View Full Code Here

                return new S3BucketAction();
            }
            else {
                String objectKey = pathInfo.substring(1);
                request.setAttribute(S3Constants.OBJECT_ATTR_KEY, objectKey);
                return new S3ObjectAction();
            }
        }

        else

        {

            int endPos = pathInfo.indexOf('/')// Subsequent / character?

            if (endPos < 1)
            {
                bucketName = pathInfo;
                S3Engine.verifyBucketName( bucketName, false );
                request.setAttribute(S3Constants.BUCKET_ATTR_KEY, bucketName);
                return new S3BucketAction();
            }
            else
            {
                bucketName = pathInfo.substring(0, endPos);
                key        = pathInfo.substring(endPos + 1);     
                S3Engine.verifyBucketName( bucketName, false );

                if (!key.isEmpty())
                {
                    request.setAttribute(S3Constants.BUCKET_ATTR_KEY, bucketName);
                    request.setAttribute(S3Constants.OBJECT_ATTR_KEY, pathInfo.substring(endPos + 1));
                    return new S3ObjectAction();
                }
                else {
                    request.setAttribute(S3Constants.BUCKET_ATTR_KEY, bucketName);
                    return new S3BucketAction();
                }
View Full Code Here

            authenticateRequest( request, params );
        }
        catch (Exception e)
        { logger.warn("Authentication details insufficient"); }

        return new S3ObjectAction();

    }
View Full Code Here

          return new S3BucketAction();
        }
        else {
          String objectKey = pathInfo.substring(1);
          request.setAttribute(S3Constants.OBJECT_ATTR_KEY, objectKey);
          return new S3ObjectAction();
        }
      }
      else
      {
        if(pathInfo == null || pathInfo.equalsIgnoreCase("/")) {
          logger.warn("Invalid REST request URI " + pathInfo);
          return null;
        }
       
        int endPos = pathInfo.indexOf('/', 1);
        if ( endPos > 0 )
        {
           bucketName = pathInfo.substring(1, endPos);
             key        = pathInfo.substring(endPos + 1);     
              S3Engine.verifyBucketName( bucketName, false );
        
           if (!key.isEmpty())
           {
               request.setAttribute(S3Constants.BUCKET_ATTR_KEY, bucketName);
              request.setAttribute(S3Constants.OBJECT_ATTR_KEY, pathInfo.substring(endPos + 1));
              return new S3ObjectAction();
           }
           else {
                request.setAttribute(S3Constants.BUCKET_ATTR_KEY, bucketName);
                return new S3BucketAction();
           }
View Full Code Here

            if (pathInfo == null || pathInfo.equalsIgnoreCase("/")) {
                return new S3BucketAction();
            } else {
                String objectKey = pathInfo.substring(1);
                request.setAttribute(S3Constants.OBJECT_ATTR_KEY, objectKey);
                return new S3ObjectAction();
            }
        }

        else

        {

            int endPos = pathInfo.indexOf('/')// Subsequent / character?

            if (endPos < 1) {
                bucketName = pathInfo;
                S3Engine.verifyBucketName(bucketName, false);
                request.setAttribute(S3Constants.BUCKET_ATTR_KEY, bucketName);
                return new S3BucketAction();
            } else {
                bucketName = pathInfo.substring(0, endPos);
                key = pathInfo.substring(endPos + 1);
                S3Engine.verifyBucketName(bucketName, false);

                if (!key.isEmpty()) {
                    request.setAttribute(S3Constants.BUCKET_ATTR_KEY, bucketName);
                    request.setAttribute(S3Constants.OBJECT_ATTR_KEY, pathInfo.substring(endPos + 1));
                    return new S3ObjectAction();
                } else {
                    request.setAttribute(S3Constants.BUCKET_ATTR_KEY, bucketName);
                    return new S3BucketAction();
                }
            }
View Full Code Here

            authenticateRequest(request, params);
        } catch (Exception e) {
            logger.warn("Authentication details insufficient");
        }

        return new S3ObjectAction();

    }
View Full Code Here

TOP

Related Classes of com.cloud.bridge.service.controller.s3.ServiceProvider

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.