Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Use Java 7's StandardCharsets (http://docs.oracle.com/javase/7/docs/a…
  • Loading branch information
Edwin Shin committed May 24, 2013
1 parent 045b1c5 commit 05639b6
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 16 deletions.
Expand Up @@ -5,7 +5,7 @@

import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;

import javax.jcr.Node;
import javax.jcr.Property;
Expand Down Expand Up @@ -52,10 +52,8 @@ public InputStream getStream(final Node node) {

str.append("</oai_dc:dc>");

return new ByteArrayInputStream(str.toString().getBytes("UTF-8"));
} catch (final UnsupportedEncodingException e) {
logger.warn("Exception rendering properties: {}", e);
return null;
return new ByteArrayInputStream(str.toString().getBytes(
StandardCharsets.UTF_8));
} catch (final RepositoryException e) {
logger.error("Repository exception: {}", e);
return null;
Expand Down
Expand Up @@ -5,7 +5,7 @@

import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;

import javax.jcr.Node;

Expand All @@ -20,11 +20,6 @@ public InputStream getStream(final Node node) {
final String str =
"<oai_dc:dc xmlns:oai_dc=\"http://www.openarchives.org/OAI/2.0/oai_dc/\" ></oai_dc:dc>";

try {
return new ByteArrayInputStream(str.getBytes("UTF-8"));
} catch (final UnsupportedEncodingException e) {
logger.warn("logged exception", e);
return null;
}
return new ByteArrayInputStream(str.getBytes(StandardCharsets.UTF_8));
}
}
Expand Up @@ -17,7 +17,6 @@
import org.fcrepo.FedoraResource;
import org.fcrepo.generator.dublincore.DCGenerator;
import org.fcrepo.services.NodeService;
import org.fcrepo.services.ObjectService;
import org.fcrepo.test.util.TestHelpers;
import org.junit.Before;
import org.junit.Test;
Expand Down
Expand Up @@ -9,6 +9,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
Expand All @@ -34,7 +35,6 @@
import javax.ws.rs.core.Request;
import javax.ws.rs.core.Response;

import com.sun.jersey.core.header.ContentDisposition;
import org.fcrepo.AbstractResource;
import org.fcrepo.Datastream;
import org.fcrepo.exception.InvalidChecksumException;
Expand All @@ -43,6 +43,7 @@
import org.springframework.stereotype.Component;

import com.codahale.metrics.annotation.Timed;
import com.sun.jersey.core.header.ContentDisposition;
import com.sun.jersey.multipart.BodyPart;
import com.sun.jersey.multipart.BodyPartEntity;
import com.sun.jersey.multipart.MultiPart;
Expand Down Expand Up @@ -189,7 +190,8 @@ public Response getDatastreamsContents(@PathParam("path")
continue;
}

digest.update(ds.getContentDigest().toString().getBytes());
digest.update(ds.getContentDigest().toString().getBytes(
StandardCharsets.UTF_8));

if (ds.getLastModifiedDate().after(date)) {
date = ds.getLastModifiedDate();
Expand Down
Expand Up @@ -7,6 +7,7 @@
import static org.fcrepo.utils.EventType.getEventType;

import java.io.ByteArrayInputStream;
import java.nio.charset.StandardCharsets;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;

Expand Down Expand Up @@ -62,7 +63,7 @@ public StreamSource getFeed() throws FeedException {
feed.setEntries(transform(copyOf(feedQueue).reverse(), event2entry));
// TODO ought to make this stream, not go through a string
return new StreamSource(new ByteArrayInputStream(new SyndFeedOutput()
.outputString(feed).getBytes()));
.outputString(feed).getBytes(StandardCharsets.UTF_8)));
}

private final Function<Event, SyndEntry> event2entry =
Expand Down

0 comments on commit 05639b6

Please sign in to comment.