aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Terry2013-05-14 12:19:15 (EDT)
committerDavid Terry2013-05-14 13:08:02 (EDT)
commit36566038e787005d78298005236adfc478f7a8cf (patch)
tree46da38b218e7f7991777b83a6594900c4285139a
parenta7da010c4ac4d63769815cc6c663c40d5b723609 (diff)
downloadorg.eclipse.lyo.core-36566038e787005d78298005236adfc478f7a8cf.zip
org.eclipse.lyo.core-36566038e787005d78298005236adfc478f7a8cf.tar.gz
org.eclipse.lyo.core-36566038e787005d78298005236adfc478f7a8cf.tar.bz2
Bug 408040 - Media type comparisons should be done using isCompatiblerefs/changes/85/12785/1
method Change-Id: I475beaa05d8b43dadae8e2417a1884b9bb50dec4 Signed-off-by: David Terry <dgterry@us.ibm.com>
-rw-r--r--org.eclipse.lyo.core.utils/src/main/java/org/eclipse/lyo/core/utils/marshallers/OSLC4JMarshaller.java24
-rw-r--r--org.eclipse.lyo.core.utils/src/main/java/org/eclipse/lyo/core/utils/marshallers/OSLC4JUnmarshaller.java10
2 files changed, 17 insertions, 17 deletions
diff --git a/org.eclipse.lyo.core.utils/src/main/java/org/eclipse/lyo/core/utils/marshallers/OSLC4JMarshaller.java b/org.eclipse.lyo.core.utils/src/main/java/org/eclipse/lyo/core/utils/marshallers/OSLC4JMarshaller.java
index 2934567..84db54f 100644
--- a/org.eclipse.lyo.core.utils/src/main/java/org/eclipse/lyo/core/utils/marshallers/OSLC4JMarshaller.java
+++ b/org.eclipse.lyo.core.utils/src/main/java/org/eclipse/lyo/core/utils/marshallers/OSLC4JMarshaller.java
@@ -40,34 +40,34 @@ public class OSLC4JMarshaller {
public void marshal(Object[] resources, OutputStream os) throws WebApplicationException{
try {
- if (mediaType == MT_RDF_XML
- || mediaType == MediaType.APPLICATION_XML_TYPE
- || mediaType == MT_N_TRIPLES
- || mediaType == MT_TURTLE
- || mediaType == MT_N3) {
+ if (mediaType.isCompatible(MT_RDF_XML)
+ || mediaType.isCompatible(MediaType.APPLICATION_XML_TYPE)
+ || mediaType.isCompatible(MT_N_TRIPLES)
+ || mediaType.isCompatible(MT_TURTLE)
+ || mediaType.isCompatible(MT_N3)) {
Model model = JenaModelHelper.createJenaModel(resources);
if (model != null) {
String format = FileUtils.langXML;
// XML is the abbrivitaed format
- if (mediaType == MediaType.APPLICATION_XML_TYPE) {
+ if (mediaType.isCompatible(MediaType.APPLICATION_XML_TYPE)) {
format = FileUtils.langXMLAbbrev;
- } else if (mediaType == MT_N_TRIPLES) {
+ } else if (mediaType.isCompatible(MT_N_TRIPLES)) {
format = FileUtils.langNTriple;
- } else if (mediaType == MT_TURTLE) {
+ } else if (mediaType.isCompatible(MT_TURTLE)) {
format = FileUtils.langTurtle;
- }else if (mediaType == MT_N3) {
+ }else if (mediaType.isCompatible(MT_N3)) {
format = FileUtils.langN3;
}
final RDFWriter writer = model.getWriter(format);
- if (mediaType == MT_RDF_XML
- || mediaType == MediaType.APPLICATION_XML_TYPE){
+ if (mediaType.isCompatible(MT_RDF_XML)
+ || mediaType.isCompatible(MediaType.APPLICATION_XML_TYPE)){
writer.setProperty("showXmlDeclaration", "true");
}
writer.write(model, os, null);
}
}
- else if(mediaType == MediaType.APPLICATION_JSON_TYPE){
+ else if(mediaType.isCompatible(MediaType.APPLICATION_JSON_TYPE)){
JSONObject jo = JsonHelper.createJSON(null, null, null, resources, null);
jo.write(os);
}
diff --git a/org.eclipse.lyo.core.utils/src/main/java/org/eclipse/lyo/core/utils/marshallers/OSLC4JUnmarshaller.java b/org.eclipse.lyo.core.utils/src/main/java/org/eclipse/lyo/core/utils/marshallers/OSLC4JUnmarshaller.java
index 610df0a..caddbb6 100644
--- a/org.eclipse.lyo.core.utils/src/main/java/org/eclipse/lyo/core/utils/marshallers/OSLC4JUnmarshaller.java
+++ b/org.eclipse.lyo.core.utils/src/main/java/org/eclipse/lyo/core/utils/marshallers/OSLC4JUnmarshaller.java
@@ -42,11 +42,11 @@ public class OSLC4JUnmarshaller {
@SuppressWarnings("unchecked")
public <T> T unmarshal(InputStream inputStream, Class<T> clazz) throws IllegalArgumentException, SecurityException, DatatypeConfigurationException, IllegalAccessException, InstantiationException, InvocationTargetException, OslcCoreApplicationException, URISyntaxException, NoSuchMethodException{
- if (mediaType == MT_RDF_XML
- || mediaType == MediaType.APPLICATION_XML_TYPE
- || mediaType == MT_N_TRIPLES
- || mediaType == MT_TURTLE
- || mediaType == MT_N3) {
+ if (mediaType.isCompatible(MT_RDF_XML)
+ || mediaType.isCompatible(MediaType.APPLICATION_XML_TYPE)
+ || mediaType.isCompatible(MT_N_TRIPLES)
+ || mediaType.isCompatible(MT_TURTLE)
+ || mediaType.isCompatible(MT_N3)) {
final Model model = ModelFactory.createDefaultModel();
final RDFReader reader = model.getReader(); // Default reader handles both xml and abbreviated xml