Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoberto E. Escobar2014-08-08 00:50:44 +0000
committerRoberto E. Escobar2014-09-29 22:55:13 +0000
commit947d8a5a9b3da405cf2a3d538ad1b4091aaee8d1 (patch)
tree4dbd505790298527af2ffd5e0d79748dd99b2f95
parentb3bcfdd1e1107e28b14f11c0f2fa95cded2a8a24 (diff)
downloadorg.eclipse.osee-947d8a5a9b3da405cf2a3d538ad1b4091aaee8d1.tar.gz
org.eclipse.osee-947d8a5a9b3da405cf2a3d538ad1b4091aaee8d1.tar.xz
org.eclipse.osee-947d8a5a9b3da405cf2a3d538ad1b4091aaee8d1.zip
feature[ats_ATS96758]: Use media type during template engine view resolution
-rw-r--r--plugins/org.eclipse.osee.jaxrs.server/src/org/eclipse/osee/jaxrs/server/internal/mvc/ViewModelWriter.java14
-rw-r--r--plugins/org.eclipse.osee.template.engine/src/org/eclipse/osee/template/engine/internal/PageFactoryViewResolver.java6
2 files changed, 17 insertions, 3 deletions
diff --git a/plugins/org.eclipse.osee.jaxrs.server/src/org/eclipse/osee/jaxrs/server/internal/mvc/ViewModelWriter.java b/plugins/org.eclipse.osee.jaxrs.server/src/org/eclipse/osee/jaxrs/server/internal/mvc/ViewModelWriter.java
index 72b4dc43dfc..b5511876761 100644
--- a/plugins/org.eclipse.osee.jaxrs.server/src/org/eclipse/osee/jaxrs/server/internal/mvc/ViewModelWriter.java
+++ b/plugins/org.eclipse.osee.jaxrs.server/src/org/eclipse/osee/jaxrs/server/internal/mvc/ViewModelWriter.java
@@ -136,16 +136,26 @@ public class ViewModelWriter implements MessageBodyWriter<ViewModel> {
}
private static List<MediaType> getMediaTypesProduced(ResourceInfo resourceInfo) {
- List<MediaType> produces = new ArrayList<MediaType>();
+ ArrayList<MediaType> produces = new ArrayList<MediaType>();
+ boolean hasText = false;
Method method = resourceInfo.getResourceMethod();
List<Produces> annotations = getAnnotations(method, Produces.class);
for (Produces annotation : annotations) {
String[] mediaTypes = annotation.value();
for (String mediaType : mediaTypes) {
- produces.add(MediaType.valueOf(mediaType));
+ MediaType toAdd = MediaType.valueOf(mediaType);
+ if (MediaType.TEXT_HTML_TYPE.equals(toAdd)) {
+ hasText = true;
+ } else {
+ produces.add(toAdd);
+ }
}
}
+
+ if (hasText) {
+ produces.add(0, MediaType.TEXT_HTML_TYPE);
+ }
if (produces.isEmpty()) {
produces.add(MediaType.WILDCARD_TYPE);
}
diff --git a/plugins/org.eclipse.osee.template.engine/src/org/eclipse/osee/template/engine/internal/PageFactoryViewResolver.java b/plugins/org.eclipse.osee.template.engine/src/org/eclipse/osee/template/engine/internal/PageFactoryViewResolver.java
index 70c01cf2d31..012732bd997 100644
--- a/plugins/org.eclipse.osee.template.engine/src/org/eclipse/osee/template/engine/internal/PageFactoryViewResolver.java
+++ b/plugins/org.eclipse.osee.template.engine/src/org/eclipse/osee/template/engine/internal/PageFactoryViewResolver.java
@@ -37,7 +37,11 @@ public class PageFactoryViewResolver extends AbstractViewResolver<ResourceToken>
@Override
public ResourceToken resolve(String viewId, MediaType mediaType) {
- return registry.resolveTemplate(viewId, mediaType);
+ ResourceToken toReturn = null;
+ if (MediaType.TEXT_HTML_TYPE.equals(mediaType) || MediaType.WILDCARD_TYPE.equals(mediaType)) {
+ toReturn = registry.resolveTemplate(viewId, mediaType);
+ }
+ return toReturn;
}
@Override

Back to the top