Skip to content

Commit

Permalink
encoding+ v2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ulrichsralf committed Oct 1, 2018
1 parent 5097105 commit 9c309b1
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 16 deletions.
2 changes: 1 addition & 1 deletion ladon-s3-server-boot/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>de.mindconsulting</groupId>
<artifactId>ladon-s3-server-boot</artifactId>
<version>1.2.0</version>
<version>2.0.0</version>
<packaging>jar</packaging>

<name>s3-server-boot</name>
Expand Down
2 changes: 1 addition & 1 deletion ladon-s3-server-fs/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>de.mindconsulting</groupId>
<artifactId>ladon-s3-server-fs</artifactId>
<version>1.2.0</version>
<version>2.0.0</version>
<build>
<plugins>
<plugin>
Expand Down
2 changes: 1 addition & 1 deletion ladon-s3-server-osgi-starter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>de.mindconsulting</groupId>
<artifactId>ladon-s3-server-osgi-starter</artifactId>
<version>1.2.0</version>
<version>2.0.0</version>
<build>
<plugins>
<plugin>
Expand Down
2 changes: 1 addition & 1 deletion ladon-s3-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>de.mindconsulting</groupId>
<artifactId>ladon-s3-server</artifactId>
<version>1.2.0</version>
<version>2.0.0</version>
<build>
<plugins>
<plugin>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package de.mc.ladon.s3server.common;

import de.mc.ladon.s3server.entities.api.S3CallContext;

import java.net.URLEncoder;

public class EncodingUtil {
private EncodingUtil() {
}

public static String getEncoded(S3CallContext callContext, String value) {
if (value == null) return null;
if (callContext.getParams().getEncodingType() != null) {
return URLEncoder.encode(value);
} else {
return value;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import javax.xml.bind.annotation.XmlRootElement;
import java.util.List;

import static de.mc.ladon.s3server.common.EncodingUtil.getEncoded;

/**
* @author Ralf Ulrich on 17.02.16.
*/
Expand All @@ -34,10 +36,10 @@ public ListBucketResult(S3CallContext callContext,
CommonPrefixes commonPrefixes,
boolean isTruncated) {
this.name = bucketName;
this.prefix = callContext.getParams().getPrefix();
this.marker = callContext.getParams().getMarker();
this.prefix = getEncoded(callContext,callContext.getParams().getPrefix());
this.marker = getEncoded(callContext,callContext.getParams().getMarker());
this.maxKeys = callContext.getParams().getMaxKeys();
this.delimiter = callContext.getParams().getDelimiter();
this.delimiter = getEncoded(callContext,callContext.getParams().getDelimiter());
this.isTruncated = isTruncated;
this.contentsList = contentsList;
this.commonPrefixes = commonPrefixes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@

package de.mc.ladon.s3server.jaxb.entities;

import de.mc.ladon.s3server.common.EncodingUtil;
import de.mc.ladon.s3server.entities.api.S3CallContext;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElements;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.List;

import static de.mc.ladon.s3server.common.EncodingUtil.*;

/**
* @author Ralf Ulrich on 17.02.16.
*/
Expand All @@ -23,26 +26,31 @@ public class ListVersionsResult {
private String nextKeyMarker;
private String nextVersionIdMarker;
private Integer maxKeys;
private String delimiter;
private Boolean isTruncated;
private List<AbstractVersionElement> versions;
private CommonPrefixes commonPrefixes;

public ListVersionsResult() {
}

public ListVersionsResult(S3CallContext callContext,
String bucketName,
List<AbstractVersionElement> versions,
CommonPrefixes commonPrefixes,
boolean isTruncated,
String nextKeyMarker,
String nextVersionIdMarker) {
this.name = bucketName;
this.prefix = callContext.getParams().getPrefix();
this.prefix = getEncoded(callContext, callContext.getParams().getPrefix());
this.keyMarker = callContext.getParams().getKeyMarker();
this.maxKeys = callContext.getParams().getMaxKeys();
this.delimiter = getEncoded(callContext,callContext.getParams().getDelimiter());
this.isTruncated = isTruncated;
this.versions = versions;
this.nextKeyMarker = nextKeyMarker;
this.nextVersionIdMarker = nextVersionIdMarker;
this.commonPrefixes = commonPrefixes;
}

@XmlElement(name = "Name")
Expand Down Expand Up @@ -117,4 +125,13 @@ public List<AbstractVersionElement> getVersions() {
public void setVersions(List<AbstractVersionElement> versions) {
this.versions = versions;
}

@XmlElement(name = "CommonPrefixes")
public CommonPrefixes getCommonPrefixes() {
return commonPrefixes;
}

public void setCommonPrefixesList(CommonPrefixes commonPrefixes) {
this.commonPrefixes = commonPrefixes;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
import de.mc.ladon.s3server.entities.api.*;
import de.mc.ladon.s3server.jaxb.entities.*;

import java.net.URLEncoder;
import java.util.List;
import java.util.stream.Collectors;

import static de.mc.ladon.s3server.common.EncodingUtil.getEncoded;

/**
* @author Ralf Ulrich on 17.02.16.
*/
Expand All @@ -26,7 +27,7 @@ public static ListAllMyBucketsResult listAllMyBucketsResult(S3User user, List<S3
public static ListBucketResult listBucketResult(S3CallContext callContext, S3ListBucketResult list) {
return new ListBucketResult(callContext, list.getBucketName(),
list.getObjects().stream().map(o -> new Contents(new Owner(o.getOwner().getUserId(), o.getOwner().getUserName()),
URLEncoder.encode(o.getKey()), o.getLastModified(), o.getETag(), o.getSize(), o.getStorageClass()))
getEncoded(callContext, o.getKey()), o.getLastModified(), o.getETag(), o.getSize(), o.getStorageClass()))
.collect(Collectors.toList()),
list.getCommonPrefixes() != null ? new CommonPrefixes(list.getCommonPrefixes()) : null,
list.isTruncated());
Expand All @@ -41,14 +42,14 @@ public static ListVersionsResult listVersionsResult(S3CallContext callContext, S
list.getObjects().stream().map(o -> {
if (o.isDeleted()) {
return new DeleteMarker(new Owner(o.getOwner().getUserId(), o.getOwner().getUserName()),
URLEncoder.encode(o.getKey()), o.getVersionId(), o.isLatest(), o.getLastModified(), o.getETag(), o.getSize(), o.getStorageClass());
getEncoded(callContext, o.getKey()), o.getVersionId(), o.isLatest(), o.getLastModified(), o.getETag(), o.getSize(), o.getStorageClass());
} else {
return new Version(new Owner(o.getOwner().getUserId(), o.getOwner().getUserName()),
URLEncoder.encode(o.getKey()), o.getVersionId(), o.isLatest(), o.getLastModified(), o.getETag(), o.getSize(), o.getStorageClass());
getEncoded(callContext, o.getKey()), o.getVersionId(), o.isLatest(), o.getLastModified(), o.getETag(), o.getSize(), o.getStorageClass());
}
}).collect(Collectors.toList()), list.isTruncated(),
list.nextKeyMarker() == null ? null : URLEncoder.encode(list.nextKeyMarker()),
list.nextVersionIdMarker() == null ? null : URLEncoder.encode(list.nextVersionIdMarker()));
}).collect(Collectors.toList()), list.getCommonPrefixes() != null ? new CommonPrefixes(list.getCommonPrefixes()) : null, list.isTruncated(),
getEncoded(callContext, list.nextKeyMarker()),
getEncoded(callContext, list.nextVersionIdMarker()));
}


Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>de.mindconsulting</groupId>
<artifactId>s3-server</artifactId>
<version>1.2.0</version>
<version>2.0.0</version>
<packaging>pom</packaging>

<name>s3-server-boot</name>
Expand Down

0 comments on commit 9c309b1

Please sign in to comment.