From 3fb9cd0903e1241bed183f75a327a01ac7638dbb Mon Sep 17 00:00:00 2001 From: Alfred Maxwell Byers Date: Thu, 8 Feb 2007 23:01:41 +0000 Subject: [PATCH] A bunch of fixes to get the Content admin to upload and display the images under the "DataResource" tab. git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@505079 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/org/ofbiz/content/ContentManagementServices.java | 8 +++++--- .../content/src/org/ofbiz/content/data/DataServices.java | 6 +++--- applications/content/widget/content/DataResourceForms.xml | 8 ++++++-- .../content/widget/content/DataResourceScreens.xml | 1 + 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/applications/content/src/org/ofbiz/content/ContentManagementServices.java b/applications/content/src/org/ofbiz/content/ContentManagementServices.java index 8e4e2b3d7b..04c68457df 100644 --- a/applications/content/src/org/ofbiz/content/ContentManagementServices.java +++ b/applications/content/src/org/ofbiz/content/ContentManagementServices.java @@ -610,8 +610,10 @@ Debug.logInfo("updateSiteRoles, serviceContext(2):" + serviceContext, module); String mimeTypeId = (String) newDrContext.get("mimeTypeId"); if (byteWrapper != null && (mimeTypeId == null || (mimeTypeId.indexOf("image") >= 0) || (mimeTypeId.indexOf("application") >= 0))) { mimeTypeId = (String) context.get("_imageData_contentType"); - String fileName = (String) context.get("_imageData_fileName"); - newDrContext.put("objectInfo", fileName); + if (dataResourceTypeId.equals("IMAGE_OBJECT")) { + String fileName = (String) context.get("_imageData_fileName"); + newDrContext.put("objectInfo", fileName); + } newDrContext.put("mimeTypeId", mimeTypeId); } @@ -697,7 +699,7 @@ Debug.logInfo("updateSiteRoles, serviceContext(2):" + serviceContext, module); } if (hasData || "true".equalsIgnoreCase(forceElectronicText)) { fileContext.put("rootDir", context.get("rootDir")); - fileContext.put("dataResourcetype", dataResourceTypeId); + fileContext.put("dataResourceTypeId", dataResourceTypeId); fileContext.put("objectInfo", dataResource.get("objectInfo")); thisResult = dispatcher.runSync("updateFile", fileContext); errorMsg = ServiceUtil.getErrorMessage(thisResult); diff --git a/applications/content/src/org/ofbiz/content/data/DataServices.java b/applications/content/src/org/ofbiz/content/data/DataServices.java index de623e9932..00ffdc12aa 100644 --- a/applications/content/src/org/ofbiz/content/data/DataServices.java +++ b/applications/content/src/org/ofbiz/content/data/DataServices.java @@ -388,7 +388,7 @@ public class DataServices { String fileName = ""; String sep = ""; try { - if (UtilValidate.isEmpty(dataResourceTypeId) || dataResourceTypeId.equals("LOCAL_FILE")) { + if (UtilValidate.isEmpty(dataResourceTypeId) || dataResourceTypeId.startsWith("LOCAL_FILE")) { fileName = prefix + sep + objectInfo; file = new File(fileName); if (file == null) { @@ -397,13 +397,13 @@ public class DataServices { if (!file.isAbsolute()) { throw new GenericServiceException("File: " + fileName + " is not absolute."); } - } else if (dataResourceTypeId.equals("OFBIZ_FILE")) { + } else if (dataResourceTypeId.startsWith("OFBIZ_FILE")) { prefix = System.getProperty("ofbiz.home"); if (objectInfo.indexOf("/") != 0 && prefix.lastIndexOf("/") != (prefix.length() - 1)) { sep = "/"; } file = new File(prefix + sep + objectInfo); - } else if (dataResourceTypeId.equals("CONTEXT_FILE")) { + } else if (dataResourceTypeId.startsWith("CONTEXT_FILE")) { prefix = (String) context.get("rootDir"); if (objectInfo.indexOf("/") != 0 && prefix.lastIndexOf("/") != (prefix.length() - 1)) { sep = "/"; diff --git a/applications/content/widget/content/DataResourceForms.xml b/applications/content/widget/content/DataResourceForms.xml index 9d03c39e22..0a0e0ab0ea 100644 --- a/applications/content/widget/content/DataResourceForms.xml +++ b/applications/content/widget/content/DataResourceForms.xml @@ -155,6 +155,9 @@ under the License. + + + @@ -274,10 +277,11 @@ under the License. extends="AddDataResourceUrl"> -
- + +
diff --git a/applications/content/widget/content/DataResourceScreens.xml b/applications/content/widget/content/DataResourceScreens.xml index 638644851b..77272b89e1 100644 --- a/applications/content/widget/content/DataResourceScreens.xml +++ b/applications/content/widget/content/DataResourceScreens.xml @@ -107,6 +107,7 @@ under the License. +