Search in sources :

Example 1 with DataPutObjectAcl

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);
}
Also used : AccessControlList(com.pspace.ifs.ksan.gw.format.AccessControlPolicy.AccessControlList) Grant(com.pspace.ifs.ksan.gw.format.AccessControlPolicy.AccessControlList.Grant) AccessControlPolicy(com.pspace.ifs.ksan.gw.format.AccessControlPolicy) Owner(com.pspace.ifs.ksan.gw.format.AccessControlPolicy.Owner) S3Bucket(com.pspace.ifs.ksan.gw.identity.S3Bucket) Metadata(com.pspace.ifs.ksan.objmanager.Metadata) DataPutObjectAcl(com.pspace.ifs.ksan.gw.data.DataPutObjectAcl) GWException(com.pspace.ifs.ksan.gw.exception.GWException)

Aggregations

DataPutObjectAcl (com.pspace.ifs.ksan.gw.data.DataPutObjectAcl)1 GWException (com.pspace.ifs.ksan.gw.exception.GWException)1 AccessControlPolicy (com.pspace.ifs.ksan.gw.format.AccessControlPolicy)1 AccessControlList (com.pspace.ifs.ksan.gw.format.AccessControlPolicy.AccessControlList)1 Grant (com.pspace.ifs.ksan.gw.format.AccessControlPolicy.AccessControlList.Grant)1 Owner (com.pspace.ifs.ksan.gw.format.AccessControlPolicy.Owner)1 S3Bucket (com.pspace.ifs.ksan.gw.identity.S3Bucket)1 Metadata (com.pspace.ifs.ksan.objmanager.Metadata)1