Skip to content

Commit

Permalink
Merge pull request #6 from dbmdz/ci-openjdk11
Browse files Browse the repository at this point in the history
Release 0.3.4
  • Loading branch information
stefan-it authored Nov 27, 2018
2 parents 2ee683c + 45b8acb commit 3b0ea3a
Show file tree
Hide file tree
Showing 13 changed files with 201 additions and 112 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ language: java
jdk:
- openjdk8
- oraclejdk8
- openjdk11
addons:
apt:
packages:
Expand Down
26 changes: 15 additions & 11 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>de.digitalcollections.iiif</groupId>
<artifactId>iiif-apis</artifactId>
<version>0.3.4-SNAPSHOT</version>
<version>0.3.4</version>
<packaging>jar</packaging>

<name>DigitalCollections: IIIF API Library</name>
Expand All @@ -23,6 +23,19 @@
<email>[email protected]</email>
<id>jbaiter</id>
</developer>
<developer>
<name>Ralf Eichinger</name>
<email>[email protected]</email>
<id>datazuul</id>
</developer>
<developer>
<name>Matthias Lindinger</name>
<id>morpheus-87</id>
</developer>
<developer>
<name>Stefan Schweter</name>
<id>stefan-it</id>
</developer>
</developers>
<ciManagement>
<url>https://travis-ci.org/dbmdz/iiif-apis</url>
Expand All @@ -49,7 +62,7 @@
<version.geojson>1.8</version.geojson>
<version.guava>23.0</version.guava>
<version.jackson>2.9.7</version.jackson>
<version.jacoco-maven-plugin>0.7.9</version.jacoco-maven-plugin>
<version.jacoco-maven-plugin>0.8.2</version.jacoco-maven-plugin>
<version.jsonassert>1.5.0</version.jsonassert>
<version.junit>4.12</version.junit>
<version.maven-compiler-plugin>3.7.0</version.maven-compiler-plugin>
Expand Down Expand Up @@ -164,15 +177,6 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>${version.maven-javadoc-plugin}</version>
<configuration>
<doclet>ch.raffael.mddoclet.MarkdownDoclet</doclet>
<docletArtifact>
<groupId>ch.raffael.markdown-doclet</groupId>
<artifactId>markdown-doclet</artifactId>
<version>1.4</version>
</docletArtifact>
<useStandardDocletOptions>true</useStandardDocletOptions>
</configuration>
<executions>
<execution>
<id>attach-javadocs</id>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
@JsonPropertyOrder({"@context", "@id", "profile", "label", "header", "description", "confirmLabel",
"failureHeader", "failureDescription", "service"})
public class AccessCookieService extends Service {

public static final String CONTEXT = "http://iiif.io/api/auth/1/context.json";

@JsonProperty("profile")
Expand All @@ -50,6 +51,8 @@ public AccessCookieService(@JsonProperty("@id") String identifier, @JsonProperty
/**
* Create a new access cookie service from an (optional) identifier and an authentication pattern.
*
* @param identifier (optional) identifier
* @param pattern authentication pattern
* @throws IllegalArgumentException If the auth pattern is not "external" and no identifier is provided.
*/
public AccessCookieService(URI identifier, AuthPattern pattern) throws IllegalArgumentException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,12 +252,15 @@ public static ImageApiProfile fromUrl(String url) {
return LEVEL_TWO;
} else if (V1_PROFILES.contains(url)) {
String lvl = url.split("#level")[1];
if (lvl.equals("0")) {
return new ImageApiProfile(url, LEVEL_ZERO);
} else if (lvl.equals("1")) {
return new ImageApiProfile(url, LEVEL_ONE);
} else if (lvl.equals("2")) {
return new ImageApiProfile(url, LEVEL_TWO);
switch (lvl) {
case "0":
return new ImageApiProfile(url, LEVEL_ZERO);
case "1":
return new ImageApiProfile(url, LEVEL_ONE);
case "2":
return new ImageApiProfile(url, LEVEL_TWO);
default:
break;
}
}
return new ImageApiProfile(url);
Expand Down Expand Up @@ -353,8 +356,12 @@ public void setMaxWidth(Integer maxWidth) {
this.maxWidth = maxWidth;
}

/** Merge multiple profiles into one.
Useful for image servers that want to consolidate the limits given in a info.json. */
/**
* Merge multiple profiles into one. Useful for image servers that want to consolidate the limits given in a info.json.
*
* @param profiles profiles to be merged
* @return merged profile
*/
public static ImageApiProfile merge(List<Profile> profiles) {
return profiles.stream()
.filter(ImageApiProfile.class::isInstance)
Expand All @@ -370,7 +377,11 @@ private <T> Stream<T> streamNotNull(Collection<T> src) {
}
}

/** Merge two profiles. */
/**
* Merge two profiles.
* @param other profile to be merged
* @return merged profile
*/
public ImageApiProfile merge(ImageApiProfile other) {
ImageApiProfile merged = new ImageApiProfile();
streamNotNull(this.features).forEach(merged::addFeature);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,16 @@
*/
@JsonTypeName(ImageApiSelector.TYPE)
public class ImageApiSelector implements Selector {

public static String CONTEXT = "http://iiif.io/api/annex/openannotation/context.json";
public static final String TYPE = "iiif:ImageApiSelector";

private static final Pattern REQUEST_PAT = Pattern.compile(
"/?(?<identifier>[^/]+)" +
"/(?<region>[^/]+)" +
"/(?<size>[^/]+)" +
"/(?<rotation>[^/]+)" +
"/(?<quality>[^/]+?)\\.(?<format>[^/]+?)$");
"/?(?<identifier>[^/]+)"
+ "/(?<region>[^/]+)"
+ "/(?<size>[^/]+)"
+ "/(?<rotation>[^/]+)"
+ "/(?<quality>[^/]+?)\\.(?<format>[^/]+?)$");

private String identifier;
private RegionRequest region;
Expand Down Expand Up @@ -88,13 +89,13 @@ public URI asImageApiUri(URI baseUri) {
@Override
public String toString() {
return String.format(
"%s%s/%s/%s/%s.%s",
identifier != null ? urlEncode(identifier) + "/" : "",
Objects.toString(region, "full"),
Objects.toString(size, "full"),
Objects.toString(rotation, "0"),
Objects.toString(quality, "default"),
Objects.toString(format, "jpg"));
"%s%s/%s/%s/%s.%s",
identifier != null ? urlEncode(identifier) + "/" : "",
Objects.toString(region, "full"),
Objects.toString(size, "full"),
Objects.toString(rotation, "0"),
Objects.toString(quality, "default"),
Objects.toString(format, "jpg"));
}

/** The spec says we have to urlencode values, but only characters outside of the US ASCII range and gen-delims
Expand All @@ -103,21 +104,22 @@ public String toString() {
* Great and pragmatic choice for readability, more code for us :-) */
private static String urlEncode(String str) {
Set<String> excluded = ImmutableSet.of(
":","!", "$", "&", "'", "(", ")", "*", "+", ",", ";", "=");
":", "!", "$", "&", "'", "(", ")", "*", "+", ",", ";", "=");
String encoded = new Encoded(str).toString();
for (String ex : excluded) {
encoded = encoded.replaceAll(new Encoded(ex).toString(), ex);
}
return encoded;
}

/** Create the canonical of the Image API request.
/**
* Create the canonical of the Image API request.See http://iiif.io/api/image/2.1/#canonical-uri-syntax
*
* See http://iiif.io/api/image/2.1/#canonical-uri-syntax
* @param nativeSize Native size of the image the selector is applied to
* @param profile Image API profile used
* @param defaultQuality The native/default quality of the image the selector is applied to
* @return The canonical form of the Image API request
* @throws de.digitalcollections.iiif.model.image.ResolvingException if RegionRequest can not be instantiated from canonical form of region
*/
public String getCanonicalForm(Dimension nativeSize, ImageApiProfile profile, Quality defaultQuality) throws ResolvingException {
Dimension scaleReference = nativeSize;
Expand All @@ -126,13 +128,13 @@ public String getCanonicalForm(Dimension nativeSize, ImageApiProfile profile, Qu
scaleReference = new Dimension((int) canonicalRegion.getWidth(), (int) canonicalRegion.getHeight());
}
return String.format(
"%s%s/%s/%s/%s.%s",
identifier != null ? urlEncode(identifier) + "/" : "",
region.getCanonicalForm(nativeSize),
size.getCanonicalForm(scaleReference, profile),
rotation.toString(),
quality.equals(defaultQuality) ? "default" : quality.toString(),
format.toString());
"%s%s/%s/%s/%s.%s",
identifier != null ? urlEncode(identifier) + "/" : "",
region.getCanonicalForm(nativeSize),
size.getCanonicalForm(scaleReference, profile),
rotation.toString(),
quality.equals(defaultQuality) ? "default" : quality.toString(),
format.toString());
}

public String getIdentifier() {
Expand Down
Loading

0 comments on commit 3b0ea3a

Please sign in to comment.