use of com.pspace.ifs.ksan.gw.exception.GWException in project ksan by infinistor.
the class GetObject method process.
@Override
public void process() throws GWException {
logger.info(GWConstants.LOG_GET_OBJECT_START);
String bucket = s3Parameter.getBucketName();
initBucketInfo(bucket);
String object = s3Parameter.getObjectName();
logger.debug(GWConstants.LOG_BUCKET_OBJECT, bucket, object);
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);
}
DataGetObject dataGetObject = new DataGetObject(s3Parameter);
dataGetObject.extract();
String versionId = dataGetObject.getVersionId();
String range = dataGetObject.getRange();
String ifMatch = dataGetObject.getIfMatch();
String ifNoneMatch = dataGetObject.getIfNoneMatch();
String ifModifiedSince = dataGetObject.getIfModifiedSince();
String ifUnmodifiedSince = dataGetObject.getIfUnmodifiedSince();
String versioningStatus = getBucketVersioning(bucket);
Metadata objMeta = null;
if (Strings.isNullOrEmpty(versionId)) {
objMeta = open(bucket, object);
versionId = objMeta.getVersionId();
} else {
objMeta = open(bucket, object, versionId);
}
logger.debug(GWConstants.LOG_OBJECT_META, objMeta.toString());
objMeta.setAcl(GWUtils.makeOriginalXml(objMeta.getAcl(), s3Parameter));
checkGrantObject(s3Parameter.isPublicAccess(), objMeta, String.valueOf(s3Parameter.getUser().getUserId()), GWConstants.GRANT_READ);
S3Metadata s3Metadata = null;
// meta info
ObjectMapper objectMapper = new ObjectMapper();
try {
logger.debug(GWConstants.LOG_META, objMeta.getMeta());
s3Metadata = objectMapper.readValue(objMeta.getMeta(), S3Metadata.class);
} catch (JsonProcessingException e) {
PrintStack.logging(logger, e);
throw new GWException(GWErrorCode.SERVER_ERROR, s3Parameter);
}
// check customer-key
if (!Strings.isNullOrEmpty(s3Metadata.getCustomerKey())) {
if (!Strings.isNullOrEmpty(dataGetObject.getServerSideEncryptionCustomerKey())) {
if (!s3Metadata.getCustomerKey().equals(dataGetObject.getServerSideEncryptionCustomerKey())) {
logger.warn(GWConstants.LOG_GET_OBJECT_CUSTOMER_KEY_NO_MATCH);
throw new GWException(GWErrorCode.KEY_DOES_NOT_MATCH, s3Parameter);
}
} else {
logger.warn(GWConstants.ENCRYPTION_CUSTOMER_KEY_IS_NULL);
throw new GWException(GWErrorCode.BAD_REQUEST, s3Parameter);
}
}
// Check match
if (!Strings.isNullOrEmpty(ifMatch)) {
logger.debug(GWConstants.LOG_GET_OBJECT_IF_MATCH_ETAG, s3Metadata.getETag(), ifMatch.replace(GWConstants.DOUBLE_QUOTE, ""));
if (!s3Metadata.getETag().equals(ifMatch.replace(GWConstants.DOUBLE_QUOTE, ""))) {
logger.error(GWConstants.LOG_GET_OBJECT_ETAG_DIFFERENT);
throw new GWException(GWErrorCode.PRECONDITION_FAILED, s3Parameter);
}
}
if (!Strings.isNullOrEmpty(ifNoneMatch)) {
logger.debug(GWConstants.LOG_GET_OBJECT_IF_NONE_MATCH_ETAG, s3Metadata.getETag(), ifNoneMatch.replace(GWConstants.DOUBLE_QUOTE, ""));
if (s3Metadata.getETag().equals(ifNoneMatch.replace(GWConstants.DOUBLE_QUOTE, ""))) {
logger.error(GWConstants.LOG_GET_OBJECT_ETAG_SAME);
throw new GWException(GWErrorCode.DOES_NOT_MATCH, String.format(GWConstants.LOG_ETAG_IS_MISMATCH), s3Parameter);
}
}
if (!Strings.isNullOrEmpty(ifModifiedSince)) {
Date modifiedSince = new Date(ifModifiedSince);
if (s3Metadata.getLastModified().before(modifiedSince)) {
throw new GWException(GWErrorCode.DOES_NOT_MATCH, String.format(GWConstants.LOG_MATCH_BEFORE, s3Metadata.getLastModified(), modifiedSince), s3Parameter);
}
}
if (!Strings.isNullOrEmpty(ifUnmodifiedSince)) {
Date unmodifiedSince = new Date(ifUnmodifiedSince);
if (s3Metadata.getLastModified().after(unmodifiedSince)) {
throw new GWException(GWErrorCode.PRECONDITION_FAILED, String.format(GWConstants.LOG_MATCH_AFTER, s3Metadata.getLastModified(), unmodifiedSince), s3Parameter);
}
}
ResultRange resultRange = new ResultRange(range, s3Metadata, s3Parameter);
addMetadataToResponse(s3Parameter.getResponse(), s3Metadata, resultRange.getContentLengthHeaders(), resultRange.getStreamSize());
S3ObjectOperation objectOperation = new S3ObjectOperation(objMeta, s3Metadata, s3Parameter, versionId, null);
try {
objectOperation.getObject(resultRange.getS3Range());
} catch (Exception e) {
PrintStack.logging(logger, e);
throw new GWException(GWErrorCode.SERVER_ERROR, s3Parameter);
}
s3Parameter.getResponse().setStatus(resultRange.getStatus());
}
use of com.pspace.ifs.ksan.gw.exception.GWException in project ksan by infinistor.
the class GetObjectRetention method process.
@Override
public void process() throws GWException {
logger.info(GWConstants.LOG_GET_OBJECT_RETENTION_START);
String bucket = s3Parameter.getBucketName();
initBucketInfo(bucket);
String object = s3Parameter.getObjectName();
logger.debug(GWConstants.LOG_BUCKET_OBJECT, bucket, object);
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);
}
DataGetObjectRetention dataGetObjectRetention = new DataGetObjectRetention(s3Parameter);
dataGetObjectRetention.extract();
String versionId = dataGetObjectRetention.getVersionId();
Metadata objMeta = null;
if (Strings.isNullOrEmpty(versionId)) {
objMeta = open(bucket, object);
} else {
objMeta = open(bucket, object, versionId);
}
logger.debug(GWConstants.LOG_OBJECT_META, objMeta.toString());
objMeta.setAcl(GWUtils.makeOriginalXml(objMeta.getAcl(), s3Parameter));
checkGrantObjectOwner(s3Parameter.isPublicAccess(), objMeta, String.valueOf(s3Parameter.getUser().getUserId()), GWConstants.GRANT_READ);
String meta = objMeta.getMeta();
S3Metadata s3Metadata;
try {
s3Metadata = new ObjectMapper().readValue(meta, S3Metadata.class);
} catch (JsonProcessingException e) {
PrintStack.logging(logger, e);
throw new GWException(GWErrorCode.SERVER_ERROR, s3Parameter);
}
if (!Strings.isNullOrEmpty(s3Metadata.getLockMode())) {
XMLOutputFactory xmlOutputFactory = XMLOutputFactory.newFactory();
javax.xml.stream.XMLStreamWriter xml;
try {
xml = xmlOutputFactory.createXMLStreamWriter(s3Parameter.getResponse().getOutputStream());
xml.writeStartDocument();
xml.writeStartElement(GWConstants.RETENTION);
writeSimpleElement(xml, GWConstants.XML_MODE, s3Metadata.getLockMode());
writeSimpleElement(xml, GWConstants.RETAIN_UNTIL_DATE, s3Metadata.getLockExpires());
xml.writeEndElement();
xml.flush();
} catch (XMLStreamException | IOException e) {
PrintStack.logging(logger, e);
throw new GWException(GWErrorCode.SERVER_ERROR, s3Parameter);
}
} else {
throw new GWException(GWErrorCode.INVALID_REQUEST, s3Parameter);
}
s3Parameter.getResponse().setStatus(HttpServletResponse.SC_OK);
}
use of com.pspace.ifs.ksan.gw.exception.GWException in project ksan by infinistor.
the class GetObjectTagging method process.
@Override
public void process() throws GWException {
logger.info(GWConstants.LOG_GET_OBJECT_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);
}
DataGetObjectTagging dataGetObjectTagging = new DataGetObjectTagging(s3Parameter);
dataGetObjectTagging.extract();
String object = s3Parameter.getObjectName();
String versionId = dataGetObjectTagging.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_READ);
String taggingInfo = objMeta.getTag();
logger.info(GWConstants.LOG_TAGGING, taggingInfo);
if (Strings.isNullOrEmpty(taggingInfo)) {
XMLOutputFactory xmlOutputFactory = XMLOutputFactory.newFactory();
javax.xml.stream.XMLStreamWriter xml;
try {
xml = xmlOutputFactory.createXMLStreamWriter(s3Parameter.getResponse().getOutputStream());
xml.writeStartDocument();
xml.writeStartElement(GWConstants.TAGGING);
xml.writeDefaultNamespace(GWConstants.AWS_XMLNS);
xml.writeStartElement(GWConstants.TAG_SET);
xml.writeEndElement();
xml.writeEndElement();
xml.flush();
} catch (XMLStreamException e) {
PrintStack.logging(logger, e);
throw new GWException(GWErrorCode.SERVER_ERROR, s3Parameter);
} catch (IOException e) {
PrintStack.logging(logger, e);
throw new GWException(GWErrorCode.SERVER_ERROR, s3Parameter);
}
} else {
try {
if (!Strings.isNullOrEmpty(taggingInfo)) {
s3Parameter.getResponse().setContentType(GWConstants.XML_CONTENT_TYPE);
s3Parameter.getResponse().getOutputStream().write(taggingInfo.getBytes());
}
} catch (IOException e) {
PrintStack.logging(logger, e);
throw new GWException(GWErrorCode.SERVER_ERROR, s3Parameter);
}
}
s3Parameter.getResponse().setStatus(HttpServletResponse.SC_OK);
}
use of com.pspace.ifs.ksan.gw.exception.GWException in project ksan by infinistor.
the class ListMultipartUploads method process.
@Override
public void process() throws GWException {
logger.info(GWConstants.LOG_LIST_MULTIPART_UPLOADS_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);
}
checkGrantBucket(s3Parameter.isPublicAccess(), String.valueOf(s3Parameter.getUser().getUserId()), GWConstants.GRANT_READ);
DataListMultipartUploads dataListMultipartUploads = new DataListMultipartUploads(s3Parameter);
dataListMultipartUploads.extract();
String delimiter = dataListMultipartUploads.getDelimiter();
String encodingType = dataListMultipartUploads.getEncodingType();
String prefix = dataListMultipartUploads.getPrefix();
String keyMarker = dataListMultipartUploads.getKeyMarker();
String uploadIdMarker = dataListMultipartUploads.getUploadIdMarker();
String maxUploads = dataListMultipartUploads.getMaxUploads();
if (Strings.isNullOrEmpty(maxUploads)) {
maxUploads = GWConstants.DEFAULT_MAX_KEYS;
} else {
if (Integer.valueOf(maxUploads) < 0) {
throw new GWException(GWErrorCode.INVALID_ARGUMENT, s3Parameter);
}
}
ResultUploads resultUploads = null;
ObjMultipart objMultipart = null;
try {
objMultipart = new ObjMultipart(bucket);
resultUploads = objMultipart.getUploads(bucket, delimiter, prefix, keyMarker, uploadIdMarker, Integer.valueOf(maxUploads));
} catch (UnknownHostException e) {
PrintStack.logging(logger, e);
throw new GWException(GWErrorCode.INTERNAL_SERVER_ERROR, s3Parameter);
} catch (Exception e) {
PrintStack.logging(logger, e);
throw new GWException(GWErrorCode.INTERNAL_SERVER_ERROR, s3Parameter);
}
s3Parameter.getResponse().setCharacterEncoding(GWConstants.CHARSET_UTF_8);
XMLOutputFactory xmlOutputFactory = XMLOutputFactory.newInstance();
try (Writer writer = s3Parameter.getResponse().getWriter()) {
s3Parameter.getResponse().setContentType(GWConstants.XML_CONTENT_TYPE);
XMLStreamWriter xmlStreamWriter = xmlOutputFactory.createXMLStreamWriter(writer);
xmlStreamWriter.writeStartDocument();
xmlStreamWriter.writeStartElement(GWConstants.LIST_MULTIPART_UPLOADS_RESULT);
xmlStreamWriter.writeDefaultNamespace(GWConstants.AWS_XMLNS);
writeSimpleElement(xmlStreamWriter, GWConstants.BUCKET, bucket);
if (prefix == null) {
xmlStreamWriter.writeEmptyElement(GWConstants.XML_PREFIX);
} else {
writeSimpleElement(xmlStreamWriter, GWConstants.XML_PREFIX, GWUtils.encodeBlob(encodingType, prefix));
}
writeSimpleElement(xmlStreamWriter, GWConstants.XML_MAX_UPLOADS, String.valueOf(maxUploads));
if (keyMarker == null) {
xmlStreamWriter.writeEmptyElement(GWConstants.XML_KEY_MARKER);
} else {
writeSimpleElement(xmlStreamWriter, GWConstants.XML_KEY_MARKER, GWUtils.encodeBlob(encodingType, keyMarker));
}
if (uploadIdMarker == null) {
xmlStreamWriter.writeEmptyElement(GWConstants.XML_UPLOADID_MARKER);
} else {
writeSimpleElement(xmlStreamWriter, GWConstants.XML_UPLOADID_MARKER, GWUtils.encodeBlob(encodingType, uploadIdMarker));
}
if (delimiter != null) {
writeSimpleElement(xmlStreamWriter, GWConstants.XML_DELIMITER, GWUtils.encodeBlob(encodingType, delimiter));
}
if (encodingType != null && encodingType.equals(GWConstants.URL)) {
writeSimpleElement(xmlStreamWriter, GWConstants.XML_ENCODING_TYPE, encodingType);
}
if (resultUploads.isTruncated()) {
writeSimpleElement(xmlStreamWriter, GWConstants.XML_IS_TRUNCATED, GWConstants.XML_TRUE);
writeSimpleElement(xmlStreamWriter, GWConstants.XML_NEXT_KEY_MARKER, GWUtils.encodeBlob(encodingType, resultUploads.getKeyMarker()));
writeSimpleElement(xmlStreamWriter, GWConstants.XML_NEXT_UPLOADID_MARKER, GWUtils.encodeBlob(encodingType, resultUploads.getUploadIdMarker()));
} else {
writeSimpleElement(xmlStreamWriter, GWConstants.XML_IS_TRUNCATED, GWConstants.XML_FALSE);
}
for (Upload upload : resultUploads.getList()) {
xmlStreamWriter.writeStartElement(GWConstants.XML_UPLOAD);
writeSimpleElement(xmlStreamWriter, GWConstants.KEY, upload.getObject());
writeSimpleElement(xmlStreamWriter, GWConstants.XML_UPLOADID, upload.getUploadId());
writeInitiatorStanza(xmlStreamWriter);
writeOwnerInfini(xmlStreamWriter, upload.getOwnerID(), upload.getOwnerName());
writeSimpleElement(xmlStreamWriter, GWConstants.STORAGE_CLASS, GWConstants.AWS_TIER_STANTARD);
writeSimpleElement(xmlStreamWriter, GWConstants.XML_INITIATED, formatDate(upload.getChangeTime()));
xmlStreamWriter.writeEndElement();
logger.debug(GWConstants.LOG_LIST_MULTIPART_UPLOADS_KEY, upload.getObject());
logger.debug(GWConstants.LOG_LIST_MULTIPART_UPLOADS_UPLOADID, upload.getUploadId());
logger.debug(GWConstants.LOG_LIST_MULTIPART_UPLOADS_CHANGE_TIME, formatDate(upload.getChangeTime()));
}
xmlStreamWriter.writeEndElement();
xmlStreamWriter.flush();
} catch (IOException e) {
PrintStack.logging(logger, e);
throw new GWException(GWErrorCode.SERVER_ERROR, s3Parameter);
} catch (XMLStreamException 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 ListObjectVersions method process.
@Override
public void process() throws GWException {
logger.info(GWConstants.LOG_LIST_OBJECT_VERSIONS_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);
}
checkGrantBucket(s3Parameter.isPublicAccess(), String.valueOf(s3Parameter.getUser().getUserId()), GWConstants.GRANT_READ);
DataListObjectVersions dataListObjectVersions = new DataListObjectVersions(s3Parameter);
dataListObjectVersions.extract();
String delimiter = dataListObjectVersions.getDelimiter();
String encodingType = dataListObjectVersions.getEncodingType();
String keyMarker = dataListObjectVersions.getKeyMarker();
String maxKeys = dataListObjectVersions.getMaxKeys();
String prefix = dataListObjectVersions.getPrefix();
String versionIdMarker = dataListObjectVersions.getVersionIdMarker();
S3ObjectList s3ObjectList = new S3ObjectList();
s3ObjectList.setDelimiter(delimiter);
s3ObjectList.setEncodingType(encodingType);
s3ObjectList.setKeyMarker(keyMarker);
s3ObjectList.setMaxKeys(maxKeys);
if (Strings.isNullOrEmpty(s3ObjectList.getMaxKeys())) {
s3ObjectList.setMaxKeys(GWConstants.DEFAULT_MAX_KEYS);
}
logger.debug(GWConstants.LOG_LIST_OBJECT_VERSIONS_MAXKEYS, s3ObjectList.getMaxKeys());
if (Integer.valueOf(s3ObjectList.getMaxKeys()) < 0) {
throw new GWException(GWErrorCode.INVALID_ARGUMENT, s3Parameter);
}
s3ObjectList.setPrefix(prefix);
s3ObjectList.setVersionIdMarker(versionIdMarker);
s3Parameter.getResponse().setCharacterEncoding(GWConstants.CHARSET_UTF_8);
XMLOutputFactory xmlOutputFactory = XMLOutputFactory.newInstance();
ObjectListParameter objectListParameter = listObjectVersions(bucket, s3ObjectList);
try (Writer writer = s3Parameter.getResponse().getWriter()) {
s3Parameter.getResponse().setContentType(GWConstants.XML_CONTENT_TYPE);
XMLStreamWriter xmlStreamWriter = xmlOutputFactory.createXMLStreamWriter(writer);
xmlStreamWriter.writeStartDocument();
xmlStreamWriter.writeStartElement(GWConstants.LIST_VERSIONS_RESULT);
xmlStreamWriter.writeDefaultNamespace(GWConstants.AWS_XMLNS);
writeSimpleElement(xmlStreamWriter, GWConstants.XML_NAME, bucket);
if (prefix == null) {
xmlStreamWriter.writeEmptyElement(GWConstants.XML_PREFIX);
} else {
writeSimpleElement(xmlStreamWriter, GWConstants.XML_PREFIX, GWUtils.encodeBlob(encodingType, prefix));
}
writeSimpleElement(xmlStreamWriter, GWConstants.XML_MAX_KEYS, String.valueOf(s3ObjectList.getMaxKeys()));
if (keyMarker == null) {
xmlStreamWriter.writeEmptyElement(GWConstants.XML_KEY_MARKER);
} else {
writeSimpleElement(xmlStreamWriter, GWConstants.XML_KEY_MARKER, GWUtils.encodeBlob(encodingType, keyMarker));
}
if (versionIdMarker == null) {
xmlStreamWriter.writeEmptyElement(GWConstants.XML_VERSIONID_MARKER);
} else {
writeSimpleElement(xmlStreamWriter, GWConstants.XML_VERSIONID_MARKER, GWUtils.encodeBlob(encodingType, versionIdMarker));
}
logger.debug(GWConstants.LOG_LIST_OBJECT_VERSIONS_PARAMETER_INFO, objectListParameter, objectListParameter.getObjects());
writeSimpleElement(xmlStreamWriter, GWConstants.XML_KEY_COUNT, String.valueOf(objectListParameter.getObjects().size()));
if (delimiter != null) {
writeSimpleElement(xmlStreamWriter, GWConstants.XML_DELIMITER, GWUtils.encodeBlob(encodingType, delimiter));
}
if (encodingType != null && encodingType.equals(GWConstants.URL)) {
writeSimpleElement(xmlStreamWriter, GWConstants.XML_ENCODING_TYPE, encodingType);
}
if (objectListParameter.isTruncated()) {
writeSimpleElement(xmlStreamWriter, GWConstants.XML_IS_TRUNCATED, GWConstants.XML_TRUE);
writeSimpleElement(xmlStreamWriter, GWConstants.XML_NEXT_KEY_MARKER, GWUtils.encodeBlob(encodingType, objectListParameter.getNextMarker()));
writeSimpleElement(xmlStreamWriter, GWConstants.XML_NEXT_VERSIONID_MARKER, GWUtils.encodeBlob(encodingType, objectListParameter.getNextVersion()));
} else {
writeSimpleElement(xmlStreamWriter, GWConstants.XML_IS_TRUNCATED, GWConstants.XML_FALSE);
}
for (S3Metadata s3Metadata : objectListParameter.getObjects()) {
if (s3Metadata != null) {
if (s3Metadata.getDeleteMarker() != null) {
if (s3Metadata.getDeleteMarker().compareTo(GWConstants.OBJECT_TYPE_MARK) == 0) {
xmlStreamWriter.writeStartElement(GWConstants.XML_DELETE_MARKER);
} else {
xmlStreamWriter.writeStartElement(GWConstants.VERSION);
}
writeSimpleElement(xmlStreamWriter, GWConstants.KEY, GWUtils.encodeBlob(encodingType, s3Metadata.getName()));
if (s3Metadata.getLastModified() != null) {
writeSimpleElement(xmlStreamWriter, GWConstants.LAST_MODIFIED, formatDate(s3Metadata.getLastModified()));
}
if (s3Metadata.getETag() != null) {
writeSimpleElement(xmlStreamWriter, GWConstants.ETAG, GWUtils.maybeQuoteETag(s3Metadata.getETag()));
}
writeSimpleElement(xmlStreamWriter, GWConstants.XML_SIZE, s3Metadata.getSize().toString());
writeSimpleElement(xmlStreamWriter, GWConstants.STORAGE_CLASS, s3Metadata.getTier());
writeSimpleElement(xmlStreamWriter, GWConstants.VERSIONID, s3Metadata.getVersionId());
writeSimpleElement(xmlStreamWriter, GWConstants.XML_IS_LATEST, s3Metadata.getIsLatest());
writeOwnerInfini(xmlStreamWriter, s3Metadata.getOwnerId(), s3Metadata.getOwnerName());
xmlStreamWriter.writeEndElement();
logger.debug(GWConstants.LOG_LIST_OBJECT_VERSIONS_INFO, s3Metadata.getName(), s3Metadata.getVersionId());
}
}
}
for (Entry<String, String> entry : objectListParameter.getCommonPrefixes().entrySet()) {
xmlStreamWriter.writeStartElement(GWConstants.XML_COMMON_PREFIXES);
writeSimpleElement(xmlStreamWriter, GWConstants.XML_PREFIX, GWUtils.encodeBlob(encodingType, entry.getValue()));
xmlStreamWriter.writeEndElement();
}
xmlStreamWriter.writeEndElement();
xmlStreamWriter.flush();
} catch (IOException e) {
PrintStack.logging(logger, e);
throw new GWException(GWErrorCode.SERVER_ERROR, s3Parameter);
} catch (XMLStreamException e) {
PrintStack.logging(logger, e);
throw new GWException(GWErrorCode.SERVER_ERROR, s3Parameter);
}
}
Aggregations