[Yanel-commits] rev 60101 - public/yanel/trunk/src/impl/java/org/wyona/yanel/impl/resources
michi at wyona.com
michi at wyona.com
Thu Aug 18 11:31:05 CEST 2011
Author: michi
Date: 2011-08-18 11:31:05 +0200 (Thu, 18 Aug 2011)
New Revision: 60101
Modified:
public/yanel/trunk/src/impl/java/org/wyona/yanel/impl/resources/BasicXMLResource.java
Log:
mobile view added
Modified: public/yanel/trunk/src/impl/java/org/wyona/yanel/impl/resources/BasicXMLResource.java
===================================================================
--- public/yanel/trunk/src/impl/java/org/wyona/yanel/impl/resources/BasicXMLResource.java 2011-08-18 09:30:46 UTC (rev 60100)
+++ public/yanel/trunk/src/impl/java/org/wyona/yanel/impl/resources/BasicXMLResource.java 2011-08-18 09:31:05 UTC (rev 60101)
@@ -123,6 +123,12 @@
* @param viewId View id
*/
protected ViewDescriptor getViewDescriptor(String viewId) {
+ if (viewId == null) {
+ log.debug("View ID is null (" + getPath() + ")");
+ // TODO: Setting the view ID to default would actually make sense, but check for backwards compatibility first!
+ //viewId = DEFAULT_VIEW_ID;
+ return null;
+ }
ViewDescriptor[] viewDescriptors = getViewDescriptors();
if (viewDescriptors != null) {
for (int i = 0; i < viewDescriptors.length; i++) {
@@ -189,13 +195,20 @@
}
/**
- * Get mime type
+ * Get mime type for a specific view ID
*/
public String getMimeType(String viewId) throws Exception {
+ if (viewId == null) {
+ log.debug("View ID is null (" + getPath() + "), hence use default view ID: " + DEFAULT_VIEW_ID);
+ // TODO: Setting this to default would make sense, but check backwards compatibility first!
+ //viewId = DEFAULT_VIEW_ID;
+ }
String mimeType = null;
ViewDescriptor viewDescriptor = getViewDescriptor(viewId);
if (viewDescriptor != null) {
mimeType = viewDescriptor.getMimeType();
+ } else {
+ log.debug("No view descriptor for view ID '" + viewId + "' and path '" + getPath() + "'.");
}
if (mimeType == null) {
mimeType = this.getResourceConfigProperty("mime-type");
@@ -223,12 +236,24 @@
}
/**
- *
+ * Apply view ID specific transformers to source XML
+ * @param viewId View ID
+ * @param xmlInputStream Source XML
*/
public View getXMLView(String viewId, InputStream xmlInputStream) throws Exception {
View view = new View();
if (viewId == null) {
- viewId = DEFAULT_VIEW_ID;
+ if (isMobileView()) {
+ if (getViewDescriptor(MOBILE_VIEW_ID) != null) {
+ //viewId = DEFAULT_VIEW_ID;
+ viewId = MOBILE_VIEW_ID;
+ } else {
+ log.warn("Seems to be a mobile device, but no mobile view configured, hence use default view!");
+ viewId = DEFAULT_VIEW_ID;
+ }
+ } else {
+ viewId = DEFAULT_VIEW_ID;
+ }
}
ConfigurableViewDescriptor viewDescriptor = (ConfigurableViewDescriptor)getViewDescriptor(viewId);
String mimeType = getMimeType(viewId);
More information about the Yanel-commits
mailing list