use of com.pspace.ifs.ksan.gw.data.DataPutBucketTagging in project ksan by infinistor.
the class PutBucketTagging method process.
@Override
public void process() throws GWException {
logger.info(GWConstants.LOG_PUT_BUCKET_TAGGING_START);
String bucket = s3Parameter.getBucketName();
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);
}
checkGrantBucketOwner(s3Parameter.isPublicAccess(), String.valueOf(s3Parameter.getUser().getUserId()), GWConstants.GRANT_WRITE_ACP);
DataPutBucketTagging dataPutBucketTagging = new DataPutBucketTagging(s3Parameter);
dataPutBucketTagging.extract();
String taggingXml = dataPutBucketTagging.getTaggingXml();
logger.debug(GWConstants.LOG_PUT_BUCKET_TAGGING, taggingXml);
try {
Tagging tagging = new XmlMapper().readValue(taggingXml, Tagging.class);
// 중복 지우기 item이 10개 미만이기 때문에 for loop가 빠름
if (tagging != null) {
if (tagging.tagset != null && tagging.tagset.tags != null) {
for (Tag t : tagging.tagset.tags) {
// key, value 길이 체크
if (t.key.length() > 128) {
throw new GWException(GWErrorCode.INVALID_TAG, s3Parameter);
}
if (t.value.length() > 256) {
throw new GWException(GWErrorCode.INVALID_TAG, s3Parameter);
}
}
}
if (tagging.tagset != null && tagging.tagset.tags != null) {
if (tagging.tagset.tags.size() > 10) {
throw new GWException(GWErrorCode.BAD_REQUEST, s3Parameter);
}
}
}
} catch (IOException e) {
PrintStack.logging(logger, e);
throw new GWException(GWErrorCode.SERVER_ERROR, s3Parameter);
}
updateBucketTagging(bucket, taggingXml);
s3Parameter.getResponse().setStatus(HttpServletResponse.SC_OK);
}
Aggregations