use of com.pspace.ifs.ksan.gw.data.DataPutObjectAcl in project ksan by infinistor.
the class PutObjectAcl method process.
@Override
public void process() throws GWException {
logger.info(GWConstants.LOG_PUT_OBJECT_ACL_START);
String bucket = s3Parameter.getBucketName();
String object = s3Parameter.getObjectName();
initBucketInfo(bucket);
S3Bucket s3Bucket = new S3Bucket();
s3Bucket.setCors(getBucketInfo().getCors());
s3Bucket.setAccess(getBucketInfo().getAccess());
s3Parameter.setBucket(s3Bucket);
GWUtils.checkCors(s3Parameter);
if (s3Parameter.isPublicAccess() && GWUtils.isIgnorePublicAcls(s3Parameter)) {
throw new GWException(GWErrorCode.ACCESS_DENIED, s3Parameter);
}
DataPutObjectAcl dataPutObjectAcl = new DataPutObjectAcl(s3Parameter);
dataPutObjectAcl.extract();
String versionId = dataPutObjectAcl.getVersionId();
Metadata objMeta = null;
if (Strings.isNullOrEmpty(versionId)) {
objMeta = open(bucket, object);
} else {
objMeta = open(bucket, object, versionId);
}
objMeta.setAcl(GWUtils.makeOriginalXml(objMeta.getAcl(), s3Parameter));
checkGrantObjectOwner(s3Parameter.isPublicAccess(), objMeta, String.valueOf(s3Parameter.getUser().getUserId()), GWConstants.GRANT_WRITE_ACP);
accessControlPolicy = new AccessControlPolicy();
accessControlPolicy.aclList = new AccessControlList();
accessControlPolicy.aclList.grants = new ArrayList<Grant>();
accessControlPolicy.owner = new Owner();
accessControlPolicy.owner.id = String.valueOf(s3Parameter.getUser().getUserId());
accessControlPolicy.owner.displayName = s3Parameter.getUser().getUserName();
String xml = GWUtils.makeAclXml(accessControlPolicy, null, dataPutObjectAcl.hasAclKeyword(), dataPutObjectAcl.getAclXml(), dataPutObjectAcl.getAcl(), getBucketInfo(), String.valueOf(s3Parameter.getUser().getUserId()), s3Parameter.getUser().getUserName(), dataPutObjectAcl.getGrantRead(), dataPutObjectAcl.getGrantWrite(), dataPutObjectAcl.getGrantFullControl(), dataPutObjectAcl.getGrantReadAcp(), dataPutObjectAcl.getGrantWriteAcp(), s3Parameter);
logger.debug(GWConstants.LOG_ACL, xml);
objMeta.setAcl(xml);
updateObjectAcl(objMeta);
s3Parameter.getResponse().setStatus(HttpServletResponse.SC_OK);
}
Aggregations