// 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();
}
}
}
}