use of com.pspace.ifs.ksan.gw.exception.GWException in project ksan by infinistor.
the class S3Request method updateBucketAcl.
protected void updateBucketAcl(String bucket, String aclXml) throws GWException {
try {
setObjManager();
objManager.updateBucketAcl(bucket, aclXml);
} catch (Exception e) {
logger.error(e.getMessage());
throw new GWException(GWErrorCode.SERVER_ERROR, s3Parameter);
} finally {
try {
releaseObjManager();
} catch (Exception e) {
PrintStack.logging(logger, e);
throw new GWException(GWErrorCode.SERVER_ERROR, s3Parameter);
}
}
}
use of com.pspace.ifs.ksan.gw.exception.GWException in project ksan by infinistor.
the class S3Request method getSomeBucket.
protected Bucket getSomeBucket(String bucket) throws GWException {
checkBucket(bucket);
Bucket bucketInfo = null;
try {
setObjManager();
bucketInfo = objManager.getBucket(bucket);
if (bucketInfo != null) {
if (!bucketInfo.getAcl().startsWith(GWConstants.XML_VERSION)) {
bucketInfo.setAcl(GWUtils.makeOriginalXml(bucketInfo.getAcl(), s3Parameter));
}
}
} catch (ResourceNotFoundException e) {
throw new GWException(GWErrorCode.NO_SUCH_BUCKET, s3Parameter);
} catch (Exception e) {
PrintStack.logging(logger, e);
throw new GWException(GWErrorCode.SERVER_ERROR, s3Parameter);
} finally {
try {
releaseObjManager();
} catch (Exception e) {
PrintStack.logging(logger, e);
throw new GWException(GWErrorCode.SERVER_ERROR, s3Parameter);
}
}
if (bucketInfo == null) {
logger.info(GWConstants.LOG_BUCKET_IS_NOT_EXIST, bucket);
throw new GWException(GWErrorCode.NO_SUCH_BUCKET, s3Parameter);
}
return bucketInfo;
}
use of com.pspace.ifs.ksan.gw.exception.GWException in project ksan by infinistor.
the class S3Request method updateBucketReplication.
protected void updateBucketReplication(String bucket, String replica) throws GWException {
try {
setObjManager();
objManager.updateBucketReplication(bucket, replica);
} catch (Exception e) {
logger.error(e.getMessage());
throw new GWException(GWErrorCode.SERVER_ERROR, s3Parameter);
} finally {
try {
releaseObjManager();
} catch (Exception e) {
PrintStack.logging(logger, e);
throw new GWException(GWErrorCode.SERVER_ERROR, s3Parameter);
}
}
}
use of com.pspace.ifs.ksan.gw.exception.GWException in project ksan by infinistor.
the class S3Request method checkGrant.
protected boolean checkGrant(String id, String s3grant, AccessControlPolicy acp) throws GWException {
switch(s3grant) {
case GWConstants.GRANT_READ:
for (Grant grant : acp.aclList.grants) {
if (grant.permission.compareTo(GWConstants.GRANT_FULL_CONTROL) == 0) {
if (grant.grantee.type.compareTo(GWConstants.GROUP) == 0) {
if (grant.grantee.uri.compareTo(GWConstants.AWS_GRANT_URI_ALL_USERS) == 0 || grant.grantee.uri.compareTo(GWConstants.AWS_GRANT_URI_AUTHENTICATED_USERS) == 0) {
return true;
}
} else if (grant.grantee.type.compareTo(GWConstants.CANONICAL_USER) == 0) {
if (grant.grantee.id.compareTo(id) == 0) {
return true;
}
}
} else if (grant.permission.compareTo(GWConstants.GRANT_READ) == 0) {
if (grant.grantee.type.compareTo(GWConstants.GROUP) == 0) {
if (grant.grantee.uri.compareTo(GWConstants.AWS_GRANT_URI_ALL_USERS) == 0 || grant.grantee.uri.compareTo(GWConstants.AWS_GRANT_URI_AUTHENTICATED_USERS) == 0) {
return true;
}
} else if (grant.grantee.type.compareTo(GWConstants.CANONICAL_USER) == 0) {
if (grant.grantee.id.compareTo(id) == 0) {
return true;
}
}
}
}
break;
case GWConstants.GRANT_WRITE:
for (Grant grant : acp.aclList.grants) {
if (grant.permission.compareTo(GWConstants.GRANT_FULL_CONTROL) == 0) {
if (grant.grantee.type.compareTo(GWConstants.GROUP) == 0) {
if (grant.grantee.uri.compareTo(GWConstants.AWS_GRANT_URI_ALL_USERS) == 0 || grant.grantee.uri.compareTo(GWConstants.AWS_GRANT_URI_AUTHENTICATED_USERS) == 0) {
return true;
}
} else if (grant.grantee.type.compareTo(GWConstants.CANONICAL_USER) == 0) {
if (grant.grantee.id.compareTo(id) == 0) {
return true;
}
}
} else if (grant.permission.compareTo(GWConstants.GRANT_WRITE) == 0) {
if (grant.grantee.type.compareTo(GWConstants.GROUP) == 0) {
if (grant.grantee.uri.compareTo(GWConstants.AWS_GRANT_URI_ALL_USERS) == 0 || grant.grantee.uri.compareTo(GWConstants.AWS_GRANT_URI_AUTHENTICATED_USERS) == 0) {
return true;
}
} else if (grant.grantee.type.compareTo(GWConstants.CANONICAL_USER) == 0) {
if (grant.grantee.id.compareTo(id) == 0) {
return true;
}
}
}
}
break;
case GWConstants.GRANT_READ_ACP:
for (Grant grant : acp.aclList.grants) {
if (grant.permission.compareTo(GWConstants.GRANT_FULL_CONTROL) == 0) {
if (grant.grantee.type.compareTo(GWConstants.GROUP) == 0) {
if (grant.grantee.uri.compareTo(GWConstants.AWS_GRANT_URI_ALL_USERS) == 0 || grant.grantee.uri.compareTo(GWConstants.AWS_GRANT_URI_AUTHENTICATED_USERS) == 0) {
return true;
}
} else if (grant.grantee.type.compareTo(GWConstants.CANONICAL_USER) == 0) {
if (grant.grantee.id.compareTo(id) == 0) {
return true;
}
}
} else if (grant.permission.compareTo(GWConstants.GRANT_READ_ACP) == 0) {
if (grant.grantee.type.compareTo(GWConstants.GROUP) == 0) {
if (grant.grantee.uri.compareTo(GWConstants.AWS_GRANT_URI_ALL_USERS) == 0 || grant.grantee.uri.compareTo(GWConstants.AWS_GRANT_URI_AUTHENTICATED_USERS) == 0) {
return true;
}
} else if (grant.grantee.type.compareTo(GWConstants.CANONICAL_USER) == 0) {
if (grant.grantee.id.compareTo(id) == 0) {
return true;
}
}
}
}
break;
case GWConstants.GRANT_WRITE_ACP:
for (Grant grant : acp.aclList.grants) {
if (grant.permission.compareTo(GWConstants.GRANT_FULL_CONTROL) == 0) {
if (grant.grantee.type.compareTo(GWConstants.GROUP) == 0) {
if (grant.grantee.uri.compareTo(GWConstants.AWS_GRANT_URI_ALL_USERS) == 0 || grant.grantee.uri.compareTo(GWConstants.AWS_GRANT_URI_AUTHENTICATED_USERS) == 0) {
return true;
}
} else if (grant.grantee.type.compareTo(GWConstants.CANONICAL_USER) == 0) {
if (grant.grantee.id.compareTo(id) == 0) {
return true;
}
}
} else if (grant.permission.compareTo(GWConstants.GRANT_WRITE_ACP) == 0) {
if (grant.grantee.type.compareTo(GWConstants.GROUP) == 0) {
if (grant.grantee.uri.compareTo(GWConstants.AWS_GRANT_URI_ALL_USERS) == 0 || grant.grantee.uri.compareTo(GWConstants.AWS_GRANT_URI_AUTHENTICATED_USERS) == 0) {
return true;
}
} else if (grant.grantee.type.compareTo(GWConstants.CANONICAL_USER) == 0) {
if (grant.grantee.id.compareTo(id) == 0) {
return true;
}
}
}
}
break;
case GWConstants.GRANT_FULL_CONTROL:
for (Grant grant : acp.aclList.grants) {
if (grant.grantee.type.compareTo(GWConstants.GROUP) == 0) {
if (grant.grantee.uri.compareTo(GWConstants.AWS_GRANT_URI_ALL_USERS) == 0 || grant.grantee.uri.compareTo(GWConstants.AWS_GRANT_URI_AUTHENTICATED_USERS) == 0) {
return true;
}
} else if (grant.grantee.type.compareTo(GWConstants.CANONICAL_USER) == 0) {
if (grant.grantee.id.compareTo(id) == 0) {
return true;
}
}
}
break;
default:
logger.error(GWConstants.LOG_REQUEST_GRANT_NOT_DEFINED, s3grant);
new GWException(GWErrorCode.INTERNAL_SERVER_ERROR, s3Parameter);
}
return false;
}
use of com.pspace.ifs.ksan.gw.exception.GWException in project ksan by infinistor.
the class S3Request method deleteBucket.
protected void deleteBucket(String bucket) throws GWException {
boolean result = false;
try {
setObjManager();
result = objManager.isBucketDelete(bucket);
if (result) {
objManager.removeBucket(bucket);
}
} catch (Exception e) {
PrintStack.logging(logger, e);
throw new GWException(GWErrorCode.SERVER_ERROR, s3Parameter);
} finally {
try {
releaseObjManager();
} catch (Exception e) {
PrintStack.logging(logger, e);
throw new GWException(GWErrorCode.SERVER_ERROR, s3Parameter);
}
}
if (!result) {
logger.info(GWConstants.LOG_REQUEST_BUCKET_IS_NOT_EMPTY);
throw new GWException(GWErrorCode.BUCKET_NOT_EMPTY, s3Parameter);
}
}
Aggregations