Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/data/DataResourceWorker.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/data/DataResourceWorker.java?view=diff&rev=513985&r1=513984&r2=513985 ============================================================================== --- ofbiz/trunk/applications/content/src/org/ofbiz/content/data/DataResourceWorker.java (original) +++ ofbiz/trunk/applications/content/src/org/ofbiz/content/data/DataResourceWorker.java Fri Mar 2 14:03:48 2007 @@ -18,17 +18,9 @@ *******************************************************************************/ package org.ofbiz.content.data; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.StringWriter; -import java.io.Writer; +import java.io.*; import java.net.URL; +import java.net.URLConnection; import java.util.ArrayList; import java.util.Comparator; import java.util.HashMap; @@ -58,6 +50,7 @@ import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.GenericValue; import org.ofbiz.entity.util.ByteWrapper; +import org.ofbiz.entity.util.EntityUtil; import org.ofbiz.service.GenericServiceException; import org.ofbiz.service.LocalDispatcher; import org.ofbiz.widget.html.HtmlScreenRenderer; @@ -71,8 +64,6 @@ import freemarker.template.TemplateException; import javolution.util.FastMap; -//import com.clarkware.profiler.Profiler; - /** * DataResourceWorker Class */ @@ -406,223 +397,252 @@ return imageType; } - public static String renderDataResourceAsText(GenericDelegator delegator, String dataResourceId, Map templateContext, GenericValue view, Locale locale, String mimeTypeId) throws GeneralException, IOException { - Writer outWriter = new StringWriter(); - renderDataResourceAsText(delegator, dataResourceId, outWriter, templateContext, view, locale, mimeTypeId); - return outWriter.toString(); - } - - public static void renderDataResourceAsText(GenericDelegator delegator, String dataResourceId, Writer out, Map templateContext, GenericValue view, Locale locale, String mimeTypeId) throws GeneralException, IOException { - if (templateContext == null) { - templateContext = new HashMap(); + public static String buildRequestPrefix(GenericDelegator delegator, Locale locale, String webSiteId, String https) { + Map prefixValues = FastMap.newInstance(); + String prefix; + + NotificationServices.setBaseUrl(delegator, webSiteId, prefixValues); + if (https != null && https.equalsIgnoreCase("true")) { + prefix = (String) prefixValues.get("baseSecureUrl"); + } else { + prefix = (String) prefixValues.get("baseUrl"); + } + if (UtilValidate.isEmpty(prefix)) { + if (https != null && https.equalsIgnoreCase("true")) { + prefix = UtilProperties.getMessage("content", "baseSecureUrl", locale); + } else { + prefix = UtilProperties.getMessage("content", "baseUrl", locale); + } } + return prefix; + } -// Map context = (Map) templateContext.get("context"); -// if (context == null) { -// context = new HashMap(); -// } + public static File getContentFile(String dataResourceTypeId, String objectInfo, String contextRoot) throws GeneralException, FileNotFoundException{ + File file = null; - if (UtilValidate.isEmpty(mimeTypeId)) { - mimeTypeId = "text/html"; - } + if (dataResourceTypeId.equals("LOCAL_FILE") || dataResourceTypeId.equals("LOCAL_FILE_BIN")) { + file = new File(objectInfo); + if (!file.exists()) { + throw new FileNotFoundException("No file found: " + (objectInfo)); + } + if (!file.isAbsolute()) { + throw new GeneralException("File (" + objectInfo + ") is not absolute"); + } + } else if (dataResourceTypeId.equals("OFBIZ_FILE") || dataResourceTypeId.equals("OFBIZ_FILE_BIN")) { + String prefix = System.getProperty("ofbiz.home"); - // if the target mimeTypeId is not a text type, throw an exception - if (!mimeTypeId.startsWith("text/")) { - throw new GeneralException("The desired mime-type is not a text type, cannot render as text: " + mimeTypeId); - } + String sep = ""; + if (objectInfo.indexOf("/") != 0 && prefix.lastIndexOf("/") != (prefix.length() - 1)) { + sep = "/"; + } + file = new File(prefix + sep + objectInfo); + if (!file.exists()) { + throw new FileNotFoundException("No file found: " + (prefix + sep + objectInfo)); + } + } else if (dataResourceTypeId.equals("CONTEXT_FILE") || dataResourceTypeId.equals("CONTEXT_FILE_BIN")) { + if (UtilValidate.isEmpty(contextRoot)) { + throw new GeneralException("Cannot find CONTEXT_FILE with an empty context root!"); + } - GenericValue dataResource = null; - if (view != null) { - String entityName = view.getEntityName(); - dataResource = delegator.makeValue("DataResource", null); - if ("DataResource".equals(entityName)) { - dataResource.setAllFields(view, true, null, null); - } else { - dataResource.setAllFields(view, true, "dr", null); + String sep = ""; + if (objectInfo.indexOf("/") != 0 && contextRoot.lastIndexOf("/") != (contextRoot.length() - 1)) { + sep = "/"; } - dataResourceId = dataResource.getString("dataResourceId"); - if (UtilValidate.isEmpty(dataResourceId)) { - throw new GeneralException("The dataResourceId [" + dataResourceId + "] is empty."); + file = new File(contextRoot + sep + objectInfo); + if (!file.exists()) { + throw new FileNotFoundException("No file found: " + (contextRoot + sep + objectInfo)); } } - if (dataResource == null || dataResource.isEmpty()) { - if (dataResourceId == null) { - throw new GeneralException("DataResourceId is null"); - } - dataResource = delegator.findByPrimaryKey("DataResource", UtilMisc.toMap("dataResourceId", dataResourceId)); + return file; + } + + + public static String getDataResourceMimeType(GenericDelegator delegator, String dataResourceId, GenericValue view) throws GenericEntityException { + + String mimeType = null; + if (view != null) + mimeType = view.getString("drMimeTypeId"); + //if (Debug.infoOn()) Debug.logInfo("getDataResourceMimeType, mimeType(2):" + mimeType, ""); + if (UtilValidate.isEmpty(mimeType) && UtilValidate.isNotEmpty(dataResourceId)) { + GenericValue dataResource = delegator.findByPrimaryKeyCache("DataResource", UtilMisc.toMap("dataResourceId", dataResourceId)); + //if (Debug.infoOn()) Debug.logInfo("getDataResourceMimeType, dataResource(2):" + dataResource, ""); + mimeType = dataResource.getString("mimeTypeId"); + } - if (dataResource == null || dataResource.isEmpty()) { - throw new GeneralException("DataResource not found with id=" + dataResourceId); + return mimeType; + } + + public static String getDataResourceContentUploadPath() { + String initialPath = UtilProperties.getPropertyValue("content.properties", "content.upload.path.prefix"); + double maxFiles = UtilProperties.getPropertyNumber("content.properties", "content.upload.max.files"); + if (maxFiles < 1) { + maxFiles = 250; } + String ofbizHome = System.getProperty("ofbiz.home"); - String drMimeTypeId = dataResource.getString("mimeTypeId"); - if (UtilValidate.isEmpty(drMimeTypeId)) { - drMimeTypeId = "text/plain"; + if (!initialPath.startsWith("/")) { + initialPath = "/" + initialPath; } - String dataTemplateTypeId = dataResource.getString("dataTemplateTypeId"); + // descending comparator + Comparator desc = new Comparator() { + public int compare(Object o1, Object o2) { + if (((Long) o1).longValue() > ((Long) o2).longValue()) { + return -1; + } else if (((Long) o1).longValue() < ((Long) o2).longValue()) { + return 1; + } + return 0; + } + }; - // if this is a template, we need to get the full template text and interpret it, otherwise we should just write a bit at a time to the writer to better support large text - if (UtilValidate.isEmpty(dataTemplateTypeId) || "NONE".equals(dataTemplateTypeId)) { - writeDataResourceText(dataResource, mimeTypeId, locale, templateContext, delegator, out); + // check for the latest subdirectory + String parentDir = ofbizHome + initialPath; + File parent = new File(parentDir); + TreeMap dirMap = new TreeMap(desc); + if (parent.exists()) { + File[] subs = parent.listFiles(); + for (int i = 0; i < subs.length; i++) { + if (subs[i].isDirectory()) { + dirMap.put(new Long(subs[0].lastModified()), subs[i]); + } + } } else { - String subContentId = (String)templateContext.get("subContentId"); - //String subContentId = (String)context.get("subContentId"); - // TODO: the reason why I did this (and I can't remember) may not be valid or it can be done better - if (UtilValidate.isNotEmpty(subContentId)) { - //context.put("contentId", subContentId); - //context.put("subContentId", null); - templateContext.put("contentId", subContentId); - templateContext.put("subContentId", null); + // if the parent doesn't exist; create it now + boolean created = parent.mkdir(); + if (!created) { + Debug.logWarning("Unable to create top level upload directory [" + parentDir + "].", module); } + } - - // get the full text of the DataResource - String templateText = getDataResourceText(dataResource, mimeTypeId, locale, templateContext, delegator); - - //String subContentId3 = (String)context.get("subContentId"); - -// context.put("mimeTypeId", null); - templateContext.put("mimeTypeId", null); -// templateContext.put("context", context); - - if ("FTL".equals(dataTemplateTypeId)) { - try { - FreeMarkerWorker.renderTemplate("DataResource:" + dataResourceId, templateText, templateContext, out); - } catch (TemplateException e) { - throw new GeneralException("Error rendering FTL template", e); + // first item in map is the most current directory + File latestDir = null; + if (dirMap != null && dirMap.size() > 0) { + latestDir = (File) dirMap.values().iterator().next(); + if (latestDir != null) { + File[] dirList = latestDir.listFiles(); + if (dirList.length >= maxFiles) { + latestDir = makeNewDirectory(parent); } - } else { - throw new GeneralException("The dataTemplateTypeId [" + dataTemplateTypeId + "] is not yet supported"); } + } else { + latestDir = makeNewDirectory(parent); } - } - public static String renderDataResourceAsTextCache(GenericDelegator delegator, String dataResourceId, Map templateContext, GenericValue view, Locale locale, String mimeTypeId) throws GeneralException, IOException { - Writer outWriter = new StringWriter(); - renderDataResourceAsTextCache(delegator, dataResourceId, outWriter, templateContext, view, locale, mimeTypeId); - return outWriter.toString(); + Debug.log("Directory Name : " + latestDir.getName(), module); + return latestDir.getAbsolutePath().replace('\\','/'); } + private static File makeNewDirectory(File parent) { + File latestDir = null; + boolean newDir = false; + while (!newDir) { + latestDir = new File(parent, "" + System.currentTimeMillis()); + if (!latestDir.exists()) { + latestDir.mkdir(); + newDir = true; + } + } + return latestDir; + } - public static void renderDataResourceAsTextCache(GenericDelegator delegator, String dataResourceId, Writer out, Map templateRoot, GenericValue view, Locale locale, String mimeTypeId) throws GeneralException, IOException { + // ------------------------------------- + // DataResource rendering methods + // ------------------------------------- + + public static String renderDataResourceAsText(GenericDelegator delegator, String dataResourceId, Map templateContext, + Locale locale, String targetMimeTypeId, boolean cache) throws GeneralException, IOException { + Writer writer = new StringWriter(); + renderDataResourceAsText(delegator, dataResourceId, writer, templateContext, locale, targetMimeTypeId, cache); + return writer.toString(); + } - if (templateRoot == null) { - templateRoot = new HashMap(); + public static void renderDataResourceAsText(GenericDelegator delegator, String dataResourceId, Writer out, + Map templateContext, Locale locale, String targetMimeTypeId, boolean cache) throws GeneralException, IOException { + if (dataResourceId == null) { + throw new GeneralException("Cannot lookup data resource with for a null dataResourceId"); + } + if (templateContext == null) { + templateContext = FastMap.newInstance(); + } + if (UtilValidate.isEmpty(targetMimeTypeId)) { + targetMimeTypeId = "text/html"; + } + if (locale == null) { + locale = Locale.getDefault(); } - //Map context = (Map) templateRoot.get("context"); - //if (context == null) { - //context = new HashMap(); - //} - - String disableCache = UtilProperties.getPropertyValue("content", "disable.ftl.template.cache"); - if (disableCache == null || !disableCache.equalsIgnoreCase("true")) { - Template cachedTemplate = FreeMarkerWorker.getTemplateCached(dataResourceId); - if (cachedTemplate != null) { - try { - String subContentId = (String)templateRoot.get("subContentId"); - if (UtilValidate.isNotEmpty(subContentId)) { - templateRoot.put("contentId", subContentId); - templateRoot.put("subContentId", null); - templateRoot.put("globalNodeTrail", null); // Force getCurrentContent to query for subContent + // check for a cahced template + if (cache) { + String disableCache = UtilProperties.getPropertyValue("content", "disable.ftl.template.cache"); + if (disableCache == null || !disableCache.equalsIgnoreCase("true")) { + Template cachedTemplate = FreeMarkerWorker.getTemplateCached(dataResourceId); + if (cachedTemplate != null) { + try { + String subContentId = (String) templateContext.get("subContentId"); + if (UtilValidate.isNotEmpty(subContentId)) { + templateContext.put("contentId", subContentId); + templateContext.put("subContentId", null); + templateContext.put("globalNodeTrail", null); // Force getCurrentContent to query for subContent + } + FreeMarkerWorker.renderTemplateCached(cachedTemplate, templateContext, out); + } catch (TemplateException e) { + Debug.logError("Error rendering FTL template. " + e.getMessage(), module); + throw new GeneralException("Error rendering FTL template", e); } - FreeMarkerWorker.renderTemplateCached(cachedTemplate, templateRoot, out); - } catch (TemplateException e) { - Debug.logError("Error rendering FTL template. " + e.getMessage(), module); - throw new GeneralException("Error rendering FTL template", e); + return; } - return; } } - if (UtilValidate.isEmpty(mimeTypeId)) { - mimeTypeId = "text/html"; - } - // if the target mimeTypeId is not a text type, throw an exception - if (!mimeTypeId.startsWith("text/")) { - throw new GeneralException("The desired mime-type is not a text type, cannot render as text: " + mimeTypeId); + if (!targetMimeTypeId.startsWith("text/")) { + throw new GeneralException("The desired mime-type is not a text type, cannot render as text: " + targetMimeTypeId); } + // get the data resource object GenericValue dataResource = null; - if (view != null) { - String entityName = view.getEntityName(); - dataResource = delegator.makeValue("DataResource", null); - if ("DataResource".equals(entityName)) { - dataResource.setAllFields(view, true, null, null); - } else { - dataResource.setAllFields(view, true, "dr", null); - } - String thisDataResourceId = null; - try { - thisDataResourceId = (String) view.get("drDataResourceId"); - } catch (Exception e) { - thisDataResourceId = (String) view.get("dataResourceId"); - } - if (UtilValidate.isEmpty(thisDataResourceId)) { - if (UtilValidate.isNotEmpty(dataResourceId)) - view = null; // causes lookup of DataResource - else - throw new GeneralException("The dataResourceId [" + dataResourceId + "] is empty."); - } - } - - if (dataResource == null || dataResource.isEmpty()) { - if (dataResourceId == null) { - throw new GeneralException("DataResourceId is null"); - } + if (cache) { dataResource = delegator.findByPrimaryKeyCache("DataResource", UtilMisc.toMap("dataResourceId", dataResourceId)); - } - if (dataResource == null || dataResource.isEmpty()) { - throw new GeneralException("DataResource not found with id=" + dataResourceId); + } else { + dataResource = delegator.findByPrimaryKey("DataResource", UtilMisc.toMap("dataResourceId", dataResourceId)); } - String drMimeTypeId = dataResource.getString("mimeTypeId"); - if (UtilValidate.isEmpty(drMimeTypeId)) { - drMimeTypeId = "text/plain"; + if (dataResource == null) { + throw new GeneralException("No data resource object found for dataResourceId: [" + dataResourceId + "]"); } + // a data template attached to the data resource String dataTemplateTypeId = dataResource.getString("dataTemplateTypeId"); - //if (Debug.infoOn()) Debug.logInfo("in renderDataResourceAsText, dataTemplateTypeId :" + dataTemplateTypeId ,""); - // if this is a template, we need to get the full template text and interpret it, otherwise we should just write a bit at a time to the writer to better support large text + // no template; or template is NONE; render the data if (UtilValidate.isEmpty(dataTemplateTypeId) || "NONE".equals(dataTemplateTypeId)) { - writeDataResourceTextCache(dataResource, mimeTypeId, locale, templateRoot, delegator, out); - } else { - String subContentId = (String)templateRoot.get("subContentId"); - if (UtilValidate.isNotEmpty(subContentId)) { - templateRoot.put("contentId", subContentId); - templateRoot.put("subContentId", null); - } + DataResourceWorker.writeDataResourceText(dataResource, targetMimeTypeId, locale, templateContext, delegator, out, true); - templateRoot.put("mimeTypeId", null); + // a template is defined; render the template first + } else { + templateContext.put("mimeTypeId", targetMimeTypeId); + // FTL template if ("FTL".equals(dataTemplateTypeId)) { try { - // This is something of a hack. FTL templates should need "contentId" value and - // not subContentId so that it will find subContent. - templateRoot.put("contentId", subContentId); - templateRoot.put("subContentId", null); - templateRoot.put("globalNodeTrail", null); // Force getCurrentContent to query for subContent - //if (Debug.infoOn()) Debug.logInfo("in renderDataResourceAsTextCache, templateRoot :" + templateRoot ,""); - //StringWriter sw = new StringWriter(); - // get the full text of the DataResource - String templateText = getDataResourceTextCache(dataResource, mimeTypeId, locale, templateRoot, delegator); - FreeMarkerWorker.renderTemplate("DataResource:" + dataResourceId, templateText, templateRoot, out); - //if (Debug.infoOn()) Debug.logInfo("in renderDataResourceAsText, sw:" + sw.toString(),""); - //out.write(sw.toString()); - //out.flush(); + // get the template data for rendering + String templateText = getDataResourceText(dataResource, targetMimeTypeId, locale, templateContext, delegator, cache); + + // render the FTL template + FreeMarkerWorker.renderTemplate("DataResource:" + dataResourceId, templateText, templateContext, out); } catch (TemplateException e) { throw new GeneralException("Error rendering FTL template", e); } + + // Screen Widget template } else if ("SCREEN_COMBINED".equals(dataTemplateTypeId)) { try { - MapStack context = MapStack.create(templateRoot); + MapStack context = MapStack.create(templateContext); context.put("locale", locale); - + // prepare the map for preRenderedContent Map prc = FastMap.newInstance(); String textData = (String) context.get("textData"); @@ -633,20 +653,22 @@ prc.put("body", textData); // used for default screen defs context.put("preRenderedContent", prc); + // get the screen renderer; or create a new one ScreenRenderer screens = (ScreenRenderer) context.get("screens"); if (screens == null) { screens = new ScreenRenderer(out, context, new HtmlScreenRenderer()); screens.getContext().put("screens", screens); } + // render the screen ScreenStringRenderer renderer = screens.getScreenStringRenderer(); String combinedName = (String) dataResource.get("objectInfo"); ModelScreen modelScreen = ScreenFactory.getScreenFromLocation(combinedName); modelScreen.renderScreenString(out, context, renderer); } catch (SAXException e) { throw new GeneralException("Error rendering Screen template", e); - } catch(ParserConfigurationException e3) { - throw new GeneralException("Error rendering Screen template", e3); + } catch (ParserConfigurationException e) { + throw new GeneralException("Error rendering Screen template", e); } } else { throw new GeneralException("The dataTemplateTypeId [" + dataTemplateTypeId + "] is not yet supported"); @@ -654,20 +676,54 @@ } } - public static String getDataResourceText(GenericValue dataResource, String mimeTypeId, Locale locale, Map context, GenericDelegator delegator) throws IOException, GeneralException { - Writer outWriter = new StringWriter(); - writeDataResourceText(dataResource, mimeTypeId, locale, context, delegator, outWriter); - return outWriter.toString(); + + /** @deprecated */ + public static String renderDataResourceAsText(GenericDelegator delegator, String dataResourceId, Map templateContext, + GenericValue view, Locale locale, String mimeTypeId) throws GeneralException, IOException { + return renderDataResourceAsText(delegator, dataResourceId, templateContext, locale, mimeTypeId, false); + } + + /** @deprecated */ + public static void renderDataResourceAsText(GenericDelegator delegator, String dataResourceId, Writer out, + Map templateContext, GenericValue view, Locale locale, String targetMimeTypeId) throws GeneralException, IOException { + renderDataResourceAsText(delegator, dataResourceId, out, templateContext, locale, targetMimeTypeId, false); } - public static void writeDataResourceText(GenericValue dataResource, String mimeTypeId, Locale locale, Map templateContext, GenericDelegator delegator, Writer outWriter) throws IOException, GeneralException { + /** @deprecated */ + public static String renderDataResourceAsTextCache(GenericDelegator delegator, String dataResourceId, Map templateContext, + GenericValue view, Locale locale, String mimeTypeId) throws GeneralException, IOException { + return renderDataResourceAsText(delegator, dataResourceId, templateContext, locale, mimeTypeId, true); + } - Map context = (Map)templateContext.get("context"); + /** @deprecated */ + public static void renderDataResourceAsTextCache(GenericDelegator delegator, String dataResourceId, Writer out, + Map templateContext, GenericValue view, Locale locale, String targetMimeTypeId) throws GeneralException, IOException { + renderDataResourceAsText(delegator, dataResourceId, out, templateContext, locale, targetMimeTypeId, true); + } + + // ---------------------------- + // Data Resource Data Gathering + // ---------------------------- + + public static String getDataResourceText(GenericValue dataResource, String mimeTypeId, Locale locale, Map context, + GenericDelegator delegator, boolean cache) throws IOException, GeneralException { + Writer out = new StringWriter(); + writeDataResourceText(dataResource, mimeTypeId, locale, context, delegator, out, cache); + return out.toString(); + } + + public static void writeDataResourceText(GenericValue dataResource, String mimeTypeId, Locale locale, Map templateContext, + GenericDelegator delegator, Writer out, boolean cache) throws IOException, GeneralException { + Map context = (Map) templateContext.get("context"); + if (context == null) { + context = FastMap.newInstance(); + } String webSiteId = (String) templateContext.get("webSiteId"); if (UtilValidate.isEmpty(webSiteId)) { if (context != null) webSiteId = (String) context.get("webSiteId"); } + String https = (String) templateContext.get("https"); if (UtilValidate.isEmpty(https)) { if (context != null) @@ -676,36 +732,32 @@ String dataResourceId = dataResource.getString("dataResourceId"); String dataResourceTypeId = dataResource.getString("dataResourceTypeId"); + + // default type if (UtilValidate.isEmpty(dataResourceTypeId)) { dataResourceTypeId = "SHORT_TEXT"; } - if (dataResourceTypeId.equals("SHORT_TEXT")) { + // text types + if ("SHORT_TEXT".equals(dataResourceTypeId) || "LINK".equals(dataResourceTypeId)) { String text = dataResource.getString("objectInfo"); - outWriter.write(text); - } else if (dataResourceTypeId.equals("ELECTRONIC_TEXT")) { - GenericValue electronicText = delegator.findByPrimaryKey("ElectronicText", UtilMisc.toMap("dataResourceId", dataResourceId)); - String text = electronicText.getString("textData"); - outWriter.write(text); - } else if (dataResourceTypeId.equals("IMAGE_OBJECT")) { - // TODO: Is this where the image (or any binary) object URL is created? looks like it is just returning - //the ID, maybe is okay, but maybe should create the whole image tag so that text and images can be - //interchanged without changing the wrapping template, and so the wrapping template doesn't have to know what the root is, etc - /* - // decide how to render based on the mime-types - // TODO: put this in a separate method to be re-used for file objects as well... - if ("text/html".equals(mimeTypeId)) { - } else if ("text/plain".equals(mimeTypeId)) { + writeText(dataResource, text, templateContext, mimeTypeId, locale, out); + } else if ("ELECTRONIC_TEXT".equals(dataResourceTypeId)) { + GenericValue electronicText; + if (cache) { + electronicText = delegator.findByPrimaryKeyCache("ElectronicText", UtilMisc.toMap("dataResourceId", dataResourceId)); } else { - throw new GeneralException("The renderDataResourceAsText operation does not yet support the desired mime-type: " + mimeTypeId); + electronicText = delegator.findByPrimaryKey("ElectronicText", UtilMisc.toMap("dataResourceId", dataResourceId)); } - */ + String text = electronicText.getString("textData"); + writeText(dataResource, text, templateContext, mimeTypeId, locale, out); + // object types + } else if (dataResourceTypeId.endsWith("_OBJECT")) { String text = (String) dataResource.get("dataResourceId"); - outWriter.write(text); - } else if (dataResourceTypeId.equals("LINK")) { - String text = dataResource.getString("objectInfo"); - outWriter.write(text); + writeText(dataResource, text, templateContext, mimeTypeId, locale, out); + + // resource type } else if (dataResourceTypeId.equals("URL_RESOURCE")) { String text = null; URL url = new URL(dataResource.getString("objectInfo")); @@ -719,152 +771,109 @@ sw.close(); text = sw.toString(); } else { - String prefix = buildRequestPrefix(delegator, locale, webSiteId, https); + String prefix = DataResourceWorker.buildRequestPrefix(delegator, locale, webSiteId, https); String sep = ""; - //String s = ""; if (url.toString().indexOf("/") != 0 && prefix.lastIndexOf("/") != (prefix.length() - 1)) { sep = "/"; } - String s2 = prefix + sep + url.toString(); - URL url2 = new URL(s2); - text = (String) url2.getContent(); - } - outWriter.write(text); - } else if (dataResourceTypeId.indexOf("_FILE") >= 0) { - String rootDir = (String) templateContext.get("rootDir"); - if (UtilValidate.isEmpty(rootDir)) { - if (context != null) - rootDir = (String) context.get("rootDir"); - } - if (mimeTypeId != null && mimeTypeId.startsWith("image")) { - writeDataResourceText(dataResource, mimeTypeId, locale, context, delegator, outWriter); + String fixedUrlStr = prefix + sep + url.toString(); + URL fixedUrl = new URL(fixedUrlStr); + text = (String) fixedUrl.getContent(); + } + out.write(text); + + // file types + } else if (dataResourceTypeId.endsWith("_FILE_BIN")) { + writeText(dataResource, dataResourceId, templateContext, mimeTypeId, locale, out); + } else if (dataResourceTypeId.endsWith("_FILE")) { + String dataResourceMimeTypeId = dataResource.getString("mimeTypeId"); + String objectInfo = dataResource.getString("objectInfo"); + String rootDir = (String) context.get("rootDir"); + + if (dataResourceMimeTypeId == null || dataResourceMimeTypeId.startsWith("text")) { + renderFile(dataResourceTypeId, objectInfo, rootDir, out); } else { - renderFile(dataResourceTypeId, dataResource.getString("objectInfo"), rootDir, outWriter); + writeText(dataResource, dataResourceId, templateContext, mimeTypeId, locale, out); } } else { throw new GeneralException("The dataResourceTypeId [" + dataResourceTypeId + "] is not supported in renderDataResourceAsText"); } } - public static String getDataResourceTextCache(GenericValue dataResource, String mimeTypeId, Locale locale, Map context, GenericDelegator delegator) throws IOException, GeneralException { - Writer outWriter = new StringWriter(); - writeDataResourceText(dataResource, mimeTypeId, locale, context, delegator, outWriter); - return outWriter.toString(); + /** @deprecated */ + public static String getDataResourceTextCache(GenericValue dataResource, String mimeTypeId, Locale locale, Map context, + GenericDelegator delegator) throws IOException, GeneralException { + return getDataResourceText(dataResource, mimeTypeId, locale, context, delegator, true); } - public static void writeDataResourceTextCache(GenericValue dataResource, String mimeTypeId, Locale locale, Map context, GenericDelegator delegator, Writer outWriter) throws IOException, GeneralException { + /** @deprecated */ + public static void writeDataResourceTextCache(GenericValue dataResource, String mimeTypeId, Locale locale, Map context, + GenericDelegator delegator, Writer outWriter) throws IOException, GeneralException { + writeDataResourceText(dataResource, mimeTypeId, locale, context, delegator, outWriter, true); + } - if (context == null) - context = new HashMap(); + /** @deprecated */ + public static String getDataResourceText(GenericValue dataResource, String mimeTypeId, Locale locale, Map context, + GenericDelegator delegator) throws IOException, GeneralException { + return getDataResourceText(dataResource, mimeTypeId, locale, context, delegator, false); + } - String text = null; - String webSiteId = (String) context.get("webSiteId"); - String https = (String) context.get("https"); + /** @deprecated */ + public static void writeDataResourceText(GenericValue dataResource, String mimeTypeId, Locale locale, Map context, + GenericDelegator delegator, Writer out) throws IOException, GeneralException { + writeDataResourceText(dataResource, mimeTypeId, locale, context, delegator, out, false); + } - String dataResourceId = dataResource.getString("dataResourceId"); - String dataResourceTypeId = dataResource.getString("dataResourceTypeId"); + public static void writeText(GenericValue dataResource, String textData, Map context, String targetMimeTypeId, Locale locale, Writer out) throws GeneralException, IOException { String dataResourceMimeTypeId = dataResource.getString("mimeTypeId"); - if (UtilValidate.isEmpty(dataResourceTypeId)) { - dataResourceTypeId = "SHORT_TEXT"; + GenericDelegator delegator = dataResource.getDelegator(); + + // assume HTML as data resource data + if (UtilValidate.isEmpty(dataResourceMimeTypeId)) { + dataResourceMimeTypeId = "text/html"; } - if (dataResourceTypeId.equals("SHORT_TEXT")) { - text = dataResource.getString("objectInfo"); - writeText(text, dataResourceMimeTypeId, mimeTypeId, outWriter); - } else if (dataResourceTypeId.equals("ELECTRONIC_TEXT")) { - GenericValue electronicText = delegator.findByPrimaryKeyCache("ElectronicText", UtilMisc.toMap("dataResourceId", dataResourceId)); - if (electronicText != null) { - text = electronicText.getString("textData"); - writeText(text, dataResourceMimeTypeId, mimeTypeId, outWriter); - } - } else if (dataResourceTypeId.equals("IMAGE_OBJECT")) { - // TODO: Is this where the image (or any binary) object URL is created? looks like it is just returning - //the ID, maybe is okay, but maybe should create the whole image tag so that text and images can be - //interchanged without changing the wrapping template, and so the wrapping template doesn't have to know what the root is, etc - /* - // decide how to render based on the mime-types - // TODO: put this in a separate method to be re-used for file objects as well... - if ("text/html".equals(mimeTypeId)) { - } else if ("text/plain".equals(mimeTypeId)) { - } else { - throw new GeneralException("The renderDataResourceAsText operation does not yet support the desired mime-type: " + mimeTypeId); - } - */ + // assume HTML for target + if (UtilValidate.isEmpty(targetMimeTypeId)) { + targetMimeTypeId = "text/html"; + } - text = (String) dataResource.get("dataResourceId"); - writeText(text, dataResourceMimeTypeId, mimeTypeId, outWriter); - } else if (dataResourceTypeId.equals("LINK")) { - text = dataResource.getString("objectInfo"); - writeText(text, dataResourceMimeTypeId, mimeTypeId, outWriter); - } else if (dataResourceTypeId.equals("URL_RESOURCE")) { - URL url = new URL(dataResource.getString("objectInfo")); - if (url.getHost() != null) { // is absolute - InputStream in = url.openStream(); - int c; - StringWriter sw = new StringWriter(); - while ((c = in.read()) != -1) { - sw.write(c); - } - sw.close(); - text = sw.toString(); - } else { - String prefix = buildRequestPrefix(delegator, locale, webSiteId, https); - String sep = ""; - //String s = ""; - if (url.toString().indexOf("/") != 0 && prefix.lastIndexOf("/") != (prefix.length() - 1)) { - sep = "/"; - } - String s2 = prefix + sep + url.toString(); - URL url2 = new URL(s2); - text = (String) url2.getContent(); - } - writeText(text, dataResourceMimeTypeId, mimeTypeId, outWriter); - } else if (dataResourceTypeId.indexOf("_FILE_BIN") >= 0) { - String rootDir = (String) context.get("rootDir"); - //renderFileBin(dataResourceTypeId, dataResource.getString("objectInfo"), rootDir, outWriter); - String objectInfo = dataResource.getString("objectInfo"); - dataResourceMimeTypeId = dataResource.getString("mimeTypeId"); - writeText( dataResourceId, dataResourceMimeTypeId, "text/html", outWriter); - } else if (dataResourceTypeId.indexOf("_FILE") >= 0) { - String rootDir = (String) context.get("rootDir"); - dataResourceMimeTypeId = dataResource.getString("mimeTypeId"); - if (dataResourceMimeTypeId == null || dataResourceMimeTypeId.startsWith("text")) { - renderFile(dataResourceTypeId, dataResource.getString("objectInfo"), rootDir, outWriter); - } else { - writeText( dataResourceId, dataResourceMimeTypeId, "text/html", outWriter); - } - } else { - throw new GeneralException("The dataResourceTypeId [" + dataResourceTypeId + "] is not supported in renderDataResourceAsText"); + // we can only render text + if (!targetMimeTypeId.startsWith("text")) { + throw new GeneralException("Method writeText() only supports rendering text content : " + targetMimeTypeId + " is not supported"); } - } - public static void writeText( String textData, String dataResourceMimeType, String targetMimeType, Writer out) throws IOException { - if (UtilValidate.isEmpty(targetMimeType)) - targetMimeType = "text/html"; - if (UtilValidate.isEmpty(dataResourceMimeType)) - dataResourceMimeType = "text/html"; + if ("text/html".equals(targetMimeTypeId)) { + // get the default mime type template + GenericValue mimeTypeTemplate = delegator.findByPrimaryKeyCache("MimeTypeHtmlTemplate", UtilMisc.toMap("mimeTypeId", dataResourceMimeTypeId)); - if (dataResourceMimeType.startsWith("text") ) { - out.write(textData); - } else { - if( targetMimeType.equals("text/html")) { - /* - if (request == null || response == null) { - throw new GeneralException("Request [" + request + "] or response [" + response + "] is null."); - } - ServletContext ctx = (ServletContext) request.getAttribute("servletContext"); - RequestHandler rh = (RequestHandler) ctx.getAttribute("_REQUEST_HANDLER_"); - boolean fullPath = false; - boolean secure = false; - boolean encode = false; - String url = rh.makeLink(request, response, buf.toString(), fullPath, secure, encode); - */ - String img = "<img src=\"/content/control/img?imgId=" + textData + "\"/>"; - out.write(img); - } else if( targetMimeType.equals("text/plain")) { + if (mimeTypeTemplate != null && mimeTypeTemplate.get("templateLocation") != null) { + // prepare the context + Map mimeContext = FastMap.newInstance(); + mimeContext.putAll(context); + mimeContext.put("dataResource", dataResource); + mimeContext.put("textData", textData); + + String mimeString = DataResourceWorker.renderMimeTypeTemplate(mimeTypeTemplate, context); + out.write(mimeString); + } else { out.write(textData); } + } else if ("text/plain".equals(targetMimeTypeId)) { + out.write(textData); + } + } + + public static String renderMimeTypeTemplate(GenericValue mimeTypeTemplate, Map context) throws GeneralException, IOException { + String location = mimeTypeTemplate.getString("templateLocation"); + StringWriter writer = new StringWriter(); + try { + FreeMarkerWorker.renderTemplateAtLocation(location, context, writer); + } catch (TemplateException e) { + throw new GeneralException(e.getMessage(), e); } + + return writer.toString(); } public static void renderFile(String dataResourceTypeId, String objectInfo, String rootDir, Writer out) throws GeneralException, IOException { @@ -918,143 +927,137 @@ } } + // ---------------------------- + // Data Resource Streaming + // ---------------------------- - public static String buildRequestPrefix(GenericDelegator delegator, Locale locale, String webSiteId, String https) { - String prefix = null; - Map prefixValues = new HashMap(); - NotificationServices.setBaseUrl(delegator, webSiteId, prefixValues); - if (https != null && https.equalsIgnoreCase("true")) { - prefix = (String) prefixValues.get("baseSecureUrl"); - } else { - prefix = (String) prefixValues.get("baseUrl"); - } - if (UtilValidate.isEmpty(prefix)) { - if (https != null && https.equalsIgnoreCase("true")) { - prefix = UtilProperties.getMessage("content", "baseSecureUrl", locale); - } else { - prefix = UtilProperties.getMessage("content", "baseUrl", locale); - } + /** + * getDataResourceStream - gets an InputStream and Content-Length of a DataResource + * + * @param dataResource + * @param https + * @param webSiteId + * @param locale + * @param contextRoot + * @return Map containing 'stream': the InputStream and 'length' a Long containing the content-length + * @throws IOException + * @throws GeneralException + */ + public static Map getDataResourceStream(GenericValue dataResource, String https, String webSiteId, Locale locale, String contextRoot, boolean cache) throws IOException, GeneralException { + if (dataResource == null) { + throw new GeneralException("Cannot stream null data resource!"); } - return prefix; - } - - public static File getContentFile(String dataResourceTypeId, String objectInfo, String rootDir) throws GeneralException, FileNotFoundException{ + String dataResourceTypeId = dataResource.getString("dataResourceTypeId"); + String dataResourceId = dataResource.getString("dataResourceId"); + GenericDelegator delegator = dataResource.getDelegator(); - File file = null; - if (dataResourceTypeId.equals("LOCAL_FILE") || dataResourceTypeId.equals("LOCAL_FILE_BIN")) { - file = new File(objectInfo); - if (!file.isAbsolute()) { - throw new GeneralException("File (" + objectInfo + ") is not absolute"); - } - } else if (dataResourceTypeId.equals("OFBIZ_FILE") || dataResourceTypeId.equals("OFBIZ_FILE_BIN")) { - String prefix = System.getProperty("ofbiz.home"); - String sep = ""; - if (objectInfo.indexOf("/") != 0 && prefix.lastIndexOf("/") != (prefix.length() - 1)) { - sep = "/"; - } - file = new File(prefix + sep + objectInfo); - } else if (dataResourceTypeId.equals("CONTEXT_FILE") || dataResourceTypeId.equals("CONTEXT_FILE_BIN")) { - String prefix = rootDir; - String sep = ""; - if (objectInfo.indexOf("/") != 0 && prefix.lastIndexOf("/") != (prefix.length() - 1)) { - sep = "/"; + // first text based data + if (dataResourceTypeId.endsWith("_TEXT") || "LINK".equals(dataResourceTypeId)) { + String text = ""; + + if ("SHORT_TEXT".equals(dataResourceTypeId) || "LINK".equals(dataResourceTypeId)) { + text = dataResource.getString("objectInfo"); + } else if ("ELECTRONIC_TEXT".equals(dataResourceTypeId)) { + GenericValue electronicText; + if (cache) { + electronicText = delegator.findByPrimaryKeyCache("ElectronicText", UtilMisc.toMap("dataResourceId", dataResourceId)); + } else { + electronicText = delegator.findByPrimaryKey("ElectronicText", UtilMisc.toMap("dataResourceId", dataResourceId)); + } + if (electronicText != null) { + text = electronicText.getString("textData"); + } + } else { + throw new GeneralException("Unsupported TEXT type; cannot stream"); } - file = new File(prefix + sep + objectInfo); - } - return file; - } + byte[] bytes = text.getBytes(); + return UtilMisc.toMap("stream", new ByteArrayInputStream(bytes), "length", new Integer(bytes.length)); - public static String getDataResourceMimeType(GenericDelegator delegator, String dataResourceId, GenericValue view) throws GenericEntityException { - - String mimeType = null; - if (view != null) - mimeType = view.getString("drMimeTypeId"); - //if (Debug.infoOn()) Debug.logInfo("getDataResourceMimeType, mimeType(2):" + mimeType, ""); - if (UtilValidate.isEmpty(mimeType) && UtilValidate.isNotEmpty(dataResourceId)) { - GenericValue dataResource = delegator.findByPrimaryKeyCache("DataResource", UtilMisc.toMap("dataResourceId", dataResourceId)); - //if (Debug.infoOn()) Debug.logInfo("getDataResourceMimeType, dataResource(2):" + dataResource, ""); - mimeType = dataResource.getString("mimeTypeId"); - - } - return mimeType; - } - - public static String getDataResourceContentUploadPath() { - String initialPath = UtilProperties.getPropertyValue("content.properties", "content.upload.path.prefix"); - double maxFiles = UtilProperties.getPropertyNumber("content.properties", "content.upload.max.files"); - if (maxFiles < 1) { - maxFiles = 250; - } - String ofbizHome = System.getProperty("ofbiz.home"); - - if (!initialPath.startsWith("/")) { - initialPath = "/" + initialPath; - } - - // descending comparator - Comparator desc = new Comparator() { - public int compare(Object o1, Object o2) { - if (((Long) o1).longValue() > ((Long) o2).longValue()) { - return -1; - } else if (((Long) o1).longValue() < ((Long) o2).longValue()) { - return 1; + // object (binary) data + } else if (dataResourceTypeId.endsWith("_OBJECT")) { + byte[] bytes = new byte[0]; + GenericValue valObj; + + if ("IMAGE_OBJECT".equals(dataResourceTypeId)) { + if (cache) { + valObj = delegator.findByPrimaryKeyCache("ImageDataResource", UtilMisc.toMap("dataResourceId", dataResourceId)); + } else { + valObj = delegator.findByPrimaryKey("ImageDataResource", UtilMisc.toMap("dataResourceId", dataResourceId)); } - return 0; - } - }; - - // check for the latest subdirectory - String parentDir = ofbizHome + initialPath; - File parent = new File(parentDir); - TreeMap dirMap = new TreeMap(desc); - if (parent.exists()) { - File[] subs = parent.listFiles(); - for (int i = 0; i < subs.length; i++) { - if (subs[i].isDirectory()) { - dirMap.put(new Long(subs[0].lastModified()), subs[i]); + if (valObj != null) { + bytes = valObj.getBytes("imageData"); } + } else if ("VIDEO_OBJECT".equals(dataResourceTypeId)) { + if (cache) { + valObj = delegator.findByPrimaryKeyCache("VideoDataResource", UtilMisc.toMap("dataResourceId", dataResourceId)); + } else { + valObj = delegator.findByPrimaryKey("VideoDataResource", UtilMisc.toMap("dataResourceId", dataResourceId)); + } + if (valObj != null) { + bytes = valObj.getBytes("videoData"); + } + } else if ("AUDIO_OBJECT".equals(dataResourceTypeId)) { + if (cache) { + valObj = delegator.findByPrimaryKeyCache("AudioDataResource", UtilMisc.toMap("dataResourceId", dataResourceId)); + } else { + valObj = delegator.findByPrimaryKey("AudioDataResource", UtilMisc.toMap("dataResourceId", dataResourceId)); + } + if (valObj != null) { + bytes = valObj.getBytes("audioData"); + } + } else if ("OTHER_OBJECT".equals(dataResourceTypeId)) { + if (cache) { + valObj = delegator.findByPrimaryKeyCache("OtherDataResource", UtilMisc.toMap("dataResourceId", dataResourceId)); + } else { + valObj = delegator.findByPrimaryKey("OtherDataResource", UtilMisc.toMap("dataResourceId", dataResourceId)); + } + if (valObj != null) { + bytes = valObj.getBytes("dataResourceContent"); + } + } else { + throw new GeneralException("Unsupported OBJECT type [" + dataResourceTypeId + "]; cannot stream"); } - } else { - // if the parent doesn't exist; create it now - boolean created = parent.mkdir(); - if (!created) { - Debug.logWarning("Unable to create top level upload directory [" + parentDir + "].", module); - } - } - // first item in map is the most current directory - File latestDir = null; - if (dirMap != null && dirMap.size() > 0) { - latestDir = (File) dirMap.values().iterator().next(); - if (latestDir != null) { - File[] dirList = latestDir.listFiles(); - if (dirList.length >= maxFiles) { - latestDir = makeNewDirectory(parent); - } + return UtilMisc.toMap("stream", new ByteArrayInputStream(bytes), "length", new Long(bytes.length)); + + // file data + } else if (dataResourceTypeId.endsWith("_FILE") || dataResourceTypeId.endsWith("_FILE_BIN")) { + String objectInfo = dataResource.getString("objectInfo"); + if (UtilValidate.isNotEmpty(objectInfo)) { + File file = DataResourceWorker.getContentFile(dataResourceTypeId, objectInfo, contextRoot); + return UtilMisc.toMap("stream", new FileInputStream(file), "length", new Long(file.length())); + } else { + throw new GeneralException("No objectInfo found for FILE type [" + dataResourceTypeId + "]; cannot stream"); } - } else { - latestDir = makeNewDirectory(parent); - } - Debug.log("Directory Name : " + latestDir.getName(), module); - return latestDir.getAbsolutePath().replace('\\','/'); - } + // URL resource data + } else if ("URL_RESOURCE".equals(dataResourceTypeId)) { + String objectInfo = dataResource.getString("objectInfo"); + if (UtilValidate.isNotEmpty(objectInfo)) { + URL url = new URL(objectInfo); + if (url.getHost() == null) { // is relative + String newUrl = DataResourceWorker.buildRequestPrefix(delegator, locale, webSiteId, https); + if (!newUrl.endsWith("/")) { + newUrl = newUrl + "/"; + } + newUrl = newUrl + url.toString(); + url = new URL(newUrl); + } - private static File makeNewDirectory(File parent) { - File latestDir = null; - boolean newDir = false; - while (!newDir) { - latestDir = new File(parent, "" + System.currentTimeMillis()); - if (!latestDir.exists()) { - latestDir.mkdir(); - newDir = true; + URLConnection con = url.openConnection(); + return UtilMisc.toMap("stream", con.getInputStream(), "length", new Long(con.getContentLength())); + } else { + throw new GeneralException("No objectInfo found for URL_RESOURCE type; cannot stream"); } } - return latestDir; + + // unsupported type + throw new GeneralException("The dataResourceTypeId [" + dataResourceTypeId + "] is not supported in getDataResourceStream"); } + // TODO: remove this method in favor of getDataResourceStream public static void streamDataResource(OutputStream os, GenericDelegator delegator, String dataResourceId, String https, String webSiteId, Locale locale, String rootDir) throws IOException, GeneralException { try { GenericValue dataResource = delegator.findByPrimaryKeyCache("DataResource", UtilMisc.toMap("dataResourceId", dataResourceId)); Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/data/DataServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/data/DataServices.java?view=diff&rev=513985&r1=513984&r2=513985 ============================================================================== --- ofbiz/trunk/applications/content/src/org/ofbiz/content/data/DataServices.java (original) +++ ofbiz/trunk/applications/content/src/org/ofbiz/content/data/DataServices.java Fri Mar 2 14:03:48 2007 @@ -471,7 +471,7 @@ GenericValue view = (GenericValue) context.get("subContentDataResourceView"); Writer outWriter = new StringWriter(); - DataResourceWorker.renderDataResourceAsTextCache(delegator, dataResourceId, outWriter, templateContext, view, locale, mimeTypeId); + DataResourceWorker.renderDataResourceAsText(delegator, dataResourceId, outWriter, templateContext, locale, mimeTypeId, true); try { out.write(outWriter.toString()); results.put("textData", outWriter.toString()); Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/search/ContentDocument.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/search/ContentDocument.java?view=diff&rev=513985&r1=513984&r2=513985 ============================================================================== --- ofbiz/trunk/applications/content/src/org/ofbiz/content/search/ContentDocument.java (original) +++ ofbiz/trunk/applications/content/src/org/ofbiz/content/search/ContentDocument.java Fri Mar 2 14:03:48 2007 @@ -52,7 +52,7 @@ public static Document Document(String id, GenericDelegator delegator) throws InterruptedException { Document doc = null; - GenericValue content = null; + GenericValue content; try { content = delegator.findByPrimaryKeyCache("Content", UtilMisc.toMap("contentId",id)); } catch(GenericEntityException e) { @@ -67,7 +67,7 @@ public static Document Document(GenericValue content, Map context) throws InterruptedException { - Document doc = null; + Document doc; // make a new, empty document doc = new Document(); String contentId = content.getString("contentId"); @@ -118,7 +118,7 @@ // module); String dataResourceId = content.getString("dataResourceId"); //Debug.logInfo("in ContentDocument, dataResourceId:" + dataResourceId, module); - GenericValue dataResource = null; + GenericValue dataResource; try { dataResource = delegator.findByPrimaryKeyCache("DataResource", UtilMisc.toMap("dataResourceId", dataResourceId)); } catch (GenericEntityException e) { @@ -143,9 +143,9 @@ if (UtilValidate.isNotEmpty(currentLocaleString)) { locale = UtilMisc.parseLocale(currentLocaleString); } - String text = null; + String text; try { - text = ContentWorker.renderContentAsTextCache(delegator, contentId, context, content, locale, mimeTypeId); + text = ContentWorker.renderContentAsText(delegator, contentId, context, locale, mimeTypeId, true); } catch (GeneralException e) { Debug.logError(e, module); List badIndexList = (List) context.get("badIndexList"); @@ -165,7 +165,7 @@ //Debug.logInfo("in ContentDocument, field:" + field.stringValue(), module); doc.add(field); } - List featureDataResourceList = null; + List featureDataResourceList; try { featureDataResourceList = content.getRelatedCache("ProductFeatureDataResource"); } catch (GenericEntityException e) { Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/search/DataResourceDocument.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/search/DataResourceDocument.java?view=diff&rev=513985&r1=513984&r2=513985 ============================================================================== --- ofbiz/trunk/applications/content/src/org/ofbiz/content/search/DataResourceDocument.java (original) +++ ofbiz/trunk/applications/content/src/org/ofbiz/content/search/DataResourceDocument.java Fri Mar 2 14:03:48 2007 @@ -72,7 +72,7 @@ StringWriter outWriter = new StringWriter(); try { - DataResourceWorker.writeDataResourceTextCache(dataResource, mimeTypeId, locale, context, delegator, outWriter); + DataResourceWorker.writeDataResourceText(dataResource, mimeTypeId, locale, context, delegator, outWriter, true); } catch(GeneralException e) { Debug.logError(e, module); } catch(IOException e) { Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/EditRenderSubContentCacheTransform.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/EditRenderSubContentCacheTransform.java?view=diff&rev=513985&r1=513984&r2=513985 ============================================================================== --- ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/EditRenderSubContentCacheTransform.java (original) +++ ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/EditRenderSubContentCacheTransform.java Fri Mar 2 14:03:48 2007 @@ -160,7 +160,7 @@ Locale locale = null; try { //if (Debug.infoOn()) Debug.logInfo("in Edit(0), before calling renderContentAsTextCache, wrapTemplateId: ." + wrapTemplateId , module); - ContentWorker.renderContentAsTextCache(delegator, wrapTemplateId, out, templateRoot, null, locale, mimeTypeId); + ContentWorker.renderContentAsText(delegator, wrapTemplateId, out, templateRoot, locale, mimeTypeId, true); //if (Debug.infoOn()) Debug.logInfo("in Edit(0), after calling renderContentAsTextCache, wrapTemplateId: ." + wrapTemplateId , module); } catch (IOException e) { Debug.logError(e, "Error rendering content" + e.getMessage(), module); Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/EditRenderSubContentTransform.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/EditRenderSubContentTransform.java?view=diff&rev=513985&r1=513984&r2=513985 ============================================================================== --- ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/EditRenderSubContentTransform.java (original) +++ ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/EditRenderSubContentTransform.java Fri Mar 2 14:03:48 2007 @@ -190,7 +190,7 @@ templateRoot.put("context", templateContext); try { - ContentWorker.renderContentAsText(delegator, wrapTemplateId, out, templateRoot, null, locale, mimeTypeId); + ContentWorker.renderContentAsText(delegator, wrapTemplateId, out, templateRoot, locale, mimeTypeId, false); } catch (IOException e) { Debug.logError(e, "Error rendering content" + e.getMessage(), module); throw new IOException("Error rendering content" + e.toString()); Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/LoopSubContentTransform.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/LoopSubContentTransform.java?view=diff&rev=513985&r1=513984&r2=513985 ============================================================================== --- ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/LoopSubContentTransform.java (original) +++ ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/LoopSubContentTransform.java Fri Mar 2 14:03:48 2007 @@ -276,7 +276,7 @@ locale = Locale.getDefault(); String mimeTypeId = (String) templateCtx.get("mimeTypeId"); try { - ContentWorker.renderContentAsText(delegator, wrapTemplateId, out, templateRoot, null, locale, mimeTypeId); + ContentWorker.renderContentAsText(delegator, wrapTemplateId, out, templateRoot, locale, mimeTypeId, true); } catch (GeneralException e) { Debug.logError(e, "Error rendering content", module); throw new IOException("Error rendering content" + e.toString()); Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/RenderContentAsText.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/RenderContentAsText.java?view=diff&rev=513985&r1=513984&r2=513985 ============================================================================== --- ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/RenderContentAsText.java (original) +++ ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/RenderContentAsText.java Fri Mar 2 14:03:48 2007 @@ -175,7 +175,7 @@ FreeMarkerWorker.saveContextValues(templateRoot, saveKeyNames, savedValues); //if (thisView != null) { try { - String txt = ContentWorker.renderContentAsTextCache(delegator, thisContentId, templateRoot, null, locale, mimeTypeId); + String txt = ContentWorker.renderContentAsText(delegator, thisContentId, templateRoot, locale, mimeTypeId, true); if ("true".equals(xmlEscape)) { txt = UtilFormatOut.encodeXmlValue(txt); } Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/RenderSubContentAsText.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/RenderSubContentAsText.java?view=diff&rev=513985&r1=513984&r2=513985 ============================================================================== --- ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/RenderSubContentAsText.java (original) +++ ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/RenderSubContentAsText.java Fri Mar 2 14:03:48 2007 @@ -160,7 +160,8 @@ FreeMarkerWorker.saveContextValues(templateRoot, saveKeyNames, savedValues); try { - String txt = ContentWorker.renderSubContentAsTextCache(delegator, thisContentId, thisMapKey, null, templateRoot, locale, mimeTypeId, null, fromDate); + String txt = ContentWorker.renderSubContentAsText(delegator, thisContentId, thisMapKey, templateRoot, locale, mimeTypeId, true); + //String txt = ContentWorker.renderSubContentAsTextCache(delegator, thisContentId, thisMapKey, null, templateRoot, locale, mimeTypeId, null, fromDate); if ("true".equals(xmlEscape)) { txt = UtilFormatOut.encodeXmlValue(txt); } Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/RenderSubContentCacheTransform.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/RenderSubContentCacheTransform.java?view=diff&rev=513985&r1=513984&r2=513985 ============================================================================== --- ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/RenderSubContentCacheTransform.java (original) +++ ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/RenderSubContentCacheTransform.java Fri Mar 2 14:03:48 2007 @@ -171,12 +171,15 @@ } if (thisView != null) { - try { - ContentWorker.renderContentAsTextCache(delegator, null, out, templateRoot, thisView, locale, mimeTypeId); - //if (Debug.infoOn()) Debug.logInfo("in RenderSubContent, after renderContentAsTextCache:", module); - } catch (GeneralException e) { - Debug.logError(e, "Error rendering content", module); - throw new IOException("Error rendering thisView:" + thisView + " msg:" + e.toString()); + String contentId = thisView.getString("contentId"); + if (contentId != null) { + try { + ContentWorker.renderContentAsText(delegator, contentId, out, templateRoot, locale, mimeTypeId, true); + //if (Debug.infoOn()) Debug.logInfo("in RenderSubContent, after renderContentAsTextCache:", module); + } catch (GeneralException e) { + Debug.logError(e, "Error rendering content", module); + throw new IOException("Error rendering thisView:" + thisView + " msg:" + e.toString()); + } } } if (UtilValidate.isNotEmpty(editRequestName)) { Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/RenderSubContentTransform.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/RenderSubContentTransform.java?view=diff&rev=513985&r1=513984&r2=513985 ============================================================================== --- ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/RenderSubContentTransform.java (original) +++ ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/RenderSubContentTransform.java Fri Mar 2 14:03:48 2007 @@ -133,13 +133,18 @@ if (subContentDataResourceView != null) { } try { - Map results = ContentWorker.renderSubContentAsText(delegator, contentId, out, mapKey, subContentId, subContentDataResourceView, templateRoot, locale, mimeTypeId, userLogin, fromDate); + if (subContentId != null) { + ContentWorker.renderContentAsText(delegator, subContentId, out, templateRoot, locale, mimeTypeId, false); + } else { + ContentWorker.renderSubContentAsText(delegator, contentId, out, mapKey, templateRoot, locale, mimeTypeId, false); + } + //Map results = ContentWorker.renderSubContentAsText(delegator, contentId, out, mapKey, subContentId, subContentDataResourceView, templateRoot, locale, mimeTypeId, userLogin, fromDate); } catch (GeneralException e) { Debug.logError(e, "Error rendering content", module); throw new IOException("Error rendering content" + e.toString()); } - Map resultCtx = (Map) FreeMarkerWorker.getWrappedObject("context", env); + //Map resultCtx = (Map) FreeMarkerWorker.getWrappedObject("context", env); templateContext.put("mapKey", null); templateContext.put("subContentId", null); templateContext.put("subDataResourceTypeId", null); Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/TraverseSubContentTransform.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/TraverseSubContentTransform.java?view=diff&rev=513985&r1=513984&r2=513985 ============================================================================== --- ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/TraverseSubContentTransform.java (original) +++ ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/TraverseSubContentTransform.java Fri Mar 2 14:03:48 2007 @@ -249,7 +249,7 @@ if (locale == null) locale = Locale.getDefault(); try { - ContentWorker.renderContentAsText(delegator, wrapTemplateId, out, templateRoot, null, locale, mimeTypeId); + ContentWorker.renderContentAsText(delegator, wrapTemplateId, out, templateRoot, locale, mimeTypeId, false); } catch (GeneralException e) { Debug.logError(e, "Error rendering content", module); throw new IOException("Error rendering content" + e.toString()); Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/WrapSubContentCacheTransform.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/WrapSubContentCacheTransform.java?view=diff&rev=513985&r1=513984&r2=513985 ============================================================================== --- ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/WrapSubContentCacheTransform.java (original) +++ ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/WrapSubContentCacheTransform.java Fri Mar 2 14:03:48 2007 @@ -169,7 +169,7 @@ Locale locale = null; try { //if (Debug.infoOn()) Debug.logInfo("in Edit(0), before calling renderContentAsText ." , module); - ContentWorker.renderContentAsTextCache(delegator, wrapTemplateId, out, templateRoot, null, locale, mimeTypeId); + ContentWorker.renderContentAsText(delegator, wrapTemplateId, out, templateRoot, locale, mimeTypeId, true); //if (Debug.infoOn()) Debug.logInfo("in Edit(0), after calling renderContentAsText ." , module); } catch (IOException e) { Debug.logError(e, "Error rendering content" + e.getMessage(), module); Added: ofbiz/trunk/applications/content/template/mime-type/flash-flv.ftl URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/template/mime-type/flash-flv.ftl?view=auto&rev=513985 ============================================================================== --- ofbiz/trunk/applications/content/template/mime-type/flash-flv.ftl (added) +++ ofbiz/trunk/applications/content/template/mime-type/flash-flv.ftl Fri Mar 2 14:03:48 2007 @@ -0,0 +1,31 @@ +<#-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + --> +<object type="application/x-shockwave-flash" data="/images/FlowPlayerLP.swf" width="320" height="263" id="FlowPlayer"> + <param name="movie" value="/images/FlowPlayerLP.swf" /> + <param name="quality" value="high" /> + + <param name="flashvars" value="config={ + autoPlay: true, + bufferLength: '100', + loop: false, + initialScale: 'fit', + videoFile: '/content/control/stream?contentId=${contentId}', + showPlayListButtons: true + }" /> +</object> \ No newline at end of file Propchange: ofbiz/trunk/applications/content/template/mime-type/flash-flv.ftl ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/applications/content/template/mime-type/flash-flv.ftl ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/trunk/applications/content/template/mime-type/flash-flv.ftl ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/trunk/applications/content/template/mime-type/flash-swf.ftl URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/template/mime-type/flash-swf.ftl?view=auto&rev=513985 ============================================================================== --- ofbiz/trunk/applications/content/template/mime-type/flash-swf.ftl (added) +++ ofbiz/trunk/applications/content/template/mime-type/flash-swf.ftl Fri Mar 2 14:03:48 2007 @@ -0,0 +1,22 @@ +<#-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + --> +<object width="550" height="400"> + <param name="movie" value="/content/control/stream?contentId=${contentId}"> + <embed src="/content/control/stream?contentId=${contentId}" width="550" height="400"></embed> +</object> Propchange: ofbiz/trunk/applications/content/template/mime-type/flash-swf.ftl ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/applications/content/template/mime-type/flash-swf.ftl ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/trunk/applications/content/template/mime-type/flash-swf.ftl ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/trunk/applications/content/template/mime-type/image.ftl URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/template/mime-type/image.ftl?view=auto&rev=513985 ============================================================================== --- ofbiz/trunk/applications/content/template/mime-type/image.ftl (added) +++ ofbiz/trunk/applications/content/template/mime-type/image.ftl Fri Mar 2 14:03:48 2007 @@ -0,0 +1,19 @@ +<#-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + --> +<img src="/content/control/stream?contentId=${contentId}"/> \ No newline at end of file Propchange: ofbiz/trunk/applications/content/template/mime-type/image.ftl ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/applications/content/template/mime-type/image.ftl ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/trunk/applications/content/template/mime-type/image.ftl ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/trunk/applications/content/template/mime-type/quicktime.ftl URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/template/mime-type/quicktime.ftl?view=auto&rev=513985 ============================================================================== --- ofbiz/trunk/applications/content/template/mime-type/quicktime.ftl (added) +++ ofbiz/trunk/applications/content/template/mime-type/quicktime.ftl Fri Mar 2 14:03:48 2007 @@ -0,0 +1,31 @@ +<#-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + --> +<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab"> + <param name="SRC" value="/content/control/stream?contentId=${contentId}" /> + <param name="WIDTH" value="320" /> + <param name="HEIGHT" value="263" /> + <param name="SCALE" value="tofit" /> + <param name="AUTOSTART" value="true" /> + <param name="AUTOPLAY" value="true" /> + <param name="KIOSKMODE" value="false" /> + <embed src="/content/control/stream?contentId=${contentId}" width="320" height="263" scale="tofit" + autostart="true" autoplay="true" kioskmode="false" target="quicktimeplayer" + pluginspage="http://www.apple.com/quicktime/download/"> + </embed> +</object> Propchange: ofbiz/trunk/applications/content/template/mime-type/quicktime.ftl ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/applications/content/template/mime-type/quicktime.ftl ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/trunk/applications/content/template/mime-type/quicktime.ftl ------------------------------------------------------------------------------ svn:mime-type = text/plain Modified: ofbiz/trunk/applications/content/webapp/content/WEB-INF/actions/website/WebSitePublishPoint.bsh URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/webapp/content/WEB-INF/actions/website/WebSitePublishPoint.bsh?view=diff&rev=513985&r1=513984&r2=513985 ============================================================================== --- ofbiz/trunk/applications/content/webapp/content/WEB-INF/actions/website/WebSitePublishPoint.bsh (original) +++ ofbiz/trunk/applications/content/webapp/content/WEB-INF/actions/website/WebSitePublishPoint.bsh Fri Mar 2 14:03:48 2007 @@ -38,7 +38,7 @@ context.put("publishPoint", publishPoint); Debug.log("CnRt: " + contentRoot + " -- PP: " + publishPoint); - // get all subsite content for the publish point - List subsites = delegator.findByAnd("ContentAssoc", UtilMisc.toMap("contentId", contentRoot, "contentAssocTypeId", "SUBSITE")); + // get all sub content for the publish point + List subsites = delegator.findByAnd("ContentAssoc", UtilMisc.toMap("contentId", contentRoot)); context.put("subsites", subsites); } Modified: ofbiz/trunk/applications/content/webapp/content/WEB-INF/controller.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/webapp/content/WEB-INF/controller.xml?view=diff&rev=513985&r1=513984&r2=513985 ============================================================================== --- ofbiz/trunk/applications/content/webapp/content/WEB-INF/controller.xml (original) +++ ofbiz/trunk/applications/content/webapp/content/WEB-INF/controller.xml Fri Mar 2 14:03:48 2007 @@ -749,6 +749,30 @@ <response name="error" type="view" value="EditMimeType"/> </request-map> + <!-- ================ MimeTypeHtmlTemplate Requests ================= --> + <request-map uri="EditMimeTypeHtmlTemplate"> + <security auth="true" https="true"/> + <response name="success" type="view" value="EditMimeTypeHtmlTemplate"/> + </request-map> + <request-map uri="createMimeTypeHtmlTemplate"> + <security auth="true" https="true"/> + <event invoke="createMimeTypeHtmlTemplate" path="" type="service"/> + <response name="success" type="view" value="EditMimeTypeHtmlTemplate"/> + <response name="error" type="view" value="EditMimeTypeHtmlTemplate"/> + </request-map> + <request-map uri="updateMimeTypeHtmlTemplate"> + <security auth="true" https="true"/> + <event invoke="updateMimeTypeHtmlTemplate" path="" type="service"/> + <response name="success" type="view" value="EditMimeTypeHtmlTemplate"/> + <response name="error" type="view" value="EditMimeTypeHtmlTemplate"/> + </request-map> + <request-map uri="removeMimeTypeHtmlTemplate"> + <security auth="true" https="true"/> + <event invoke="removeMimeTypeHtmlTemplate" path="" type="service"/> + <response name="success" type="view" value="EditMimeTypeHtmlTemplate"/> + <response name="error" type="view" value="EditMimeTypeHtmlTemplate"/> + </request-map> + <!-- ================ Redirect Content Requests ================= --> <request-map uri="findContent"> <security auth="true" https="true"/> @@ -864,6 +888,11 @@ <response name="success" type="none"/> <response name="error" type="view" value="main"/> </request-map> + <request-map uri="stream"> + <event type="java" path="org.ofbiz.content.data.DataEvents" invoke="serveObjectData"/> + <response name="success" type="none"/> + <response name="error" type="view" value="error"/> + </request-map> <!-- ================ ContentOperation Requests ================= --> <request-map uri="EditContentOperation"><security auth="true" https="true"/><response name="success" type="view" value="EditContentOperation"/></request-map> @@ -1709,6 +1738,7 @@ <view-map name="EditCharacterSet" page="component://content/widget/datasetup/DataResourceSetupScreens.xml#EditCharacterSet" type="screen"/> <view-map name="EditFileExtension" page="component://content/widget/datasetup/DataResourceSetupScreens.xml#EditFileExtension" type="screen"/> <view-map name="EditMimeType" page="component://content/widget/datasetup/DataResourceSetupScreens.xml#EditMimeType" type="screen"/> + <view-map name="EditMimeTypeHtmlTemplate" page="component://content/widget/datasetup/DataResourceSetupScreens.xml#EditMimeTypeHtmlTemplate" type="screen"/> <view-map name="ListLayout" page="component://content/widget/layout/LayoutScreens.xml#ListLayout" type="screen"/> <view-map name="FindLayout" page="component://content/widget/layout/LayoutScreens.xml#FindLayout" type="screen"/> Modified: ofbiz/trunk/applications/content/webapp/content/datasetup/DataResourceSetupMenus.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/webapp/content/datasetup/DataResourceSetupMenus.xml?view=diff&rev=513985&r1=513984&r2=513985 ============================================================================== --- ofbiz/trunk/applications/content/webapp/content/datasetup/DataResourceSetupMenus.xml (original) +++ ofbiz/trunk/applications/content/webapp/content/datasetup/DataResourceSetupMenus.xml Fri Mar 2 14:03:48 2007 @@ -51,5 +51,8 @@ <menu-item name="EditMimeType" title="${uiLabelMap.ContentMimeType}" > <link target="EditMimeType" target-window="_top" style="tabButton" /> </menu-item> + <menu-item name="EditMimeTypeHtmlTemplate" title="${uiLabelMap.ContentMimeTypeHtmlTemplate}" > + <link target="EditMimeTypeHtmlTemplate" target-window="_top" style="tabButton" /> + </menu-item> </menu> </menus> |
Free forum by Nabble | Edit this page |