You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ha...@apache.org on 2011/12/02 04:41:00 UTC
svn commit: r1209355 -
/ofbiz/trunk/applications/product/src/org/ofbiz/product/imagemanagement/ImageManagementHelper.java
Author: hansbak
Date: Fri Dec 2 03:40:59 2011
New Revision: 1209355
URL: http://svn.apache.org/viewvc?rev=1209355&view=rev
Log:
files missing on last commit 1209351
Added:
ofbiz/trunk/applications/product/src/org/ofbiz/product/imagemanagement/ImageManagementHelper.java (with props)
Added: ofbiz/trunk/applications/product/src/org/ofbiz/product/imagemanagement/ImageManagementHelper.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/imagemanagement/ImageManagementHelper.java?rev=1209355&view=auto
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/product/imagemanagement/ImageManagementHelper.java (added)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/product/imagemanagement/ImageManagementHelper.java Fri Dec 2 03:40:59 2011
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * 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.
+ *******************************************************************************/
+
+package org.ofbiz.product.imagemanagement;
+
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.ofbiz.base.util.Debug;
+import org.ofbiz.base.util.UtilMisc;
+import org.ofbiz.base.util.UtilValidate;
+import org.ofbiz.entity.Delegator;
+import org.ofbiz.entity.GenericEntityException;
+import org.ofbiz.entity.GenericValue;
+import org.ofbiz.entity.util.EntityUtil;
+
+public class ImageManagementHelper {
+
+ static String module = ImageManagementHelper.class.getName();
+
+ public static String getInternalImageUrl(HttpServletRequest request, String productId) {
+ String internalImageUrl = null;
+ try {
+ Delegator delegator = (Delegator) request.getAttribute("delegator");
+ List<GenericValue> defaultImageList = delegator.findByAnd("ProductContentAndInfo", UtilMisc.toMap("productId", productId, "productContentTypeId", "DEFAULT_IMAGE", "statusId", "IM_APPROVED", "drIsPublic", "N"), UtilMisc.toList("sequenceNum"));
+ if (UtilValidate.isNotEmpty(defaultImageList)) {
+ GenericValue productContent = EntityUtil.getFirst(defaultImageList);
+ if (UtilValidate.isNotEmpty(productContent.get("drObjectInfo"))) {
+ internalImageUrl = (String) productContent.get("drObjectInfo");
+ }
+ } else {
+ List<GenericValue> productContentList = delegator.findByAnd("ProductContentAndInfo", UtilMisc.toMap("productId", productId, "productContentTypeId", "IMAGE", "statusId", "IM_APPROVED", "drIsPublic", "N"), UtilMisc.toList("sequenceNum"));
+ if (UtilValidate.isNotEmpty(productContentList)) {
+ GenericValue productContent = EntityUtil.getFirst(productContentList);
+ if (UtilValidate.isNotEmpty(productContent.get("drObjectInfo"))) {
+ internalImageUrl = (String) productContent.get("drObjectInfo");
+ }
+ }
+ }
+ } catch (GenericEntityException e) {
+ Debug.logError(e, "Cannot get internal image url", module);
+ }
+ return internalImageUrl;
+ }
+}
\ No newline at end of file
Propchange: ofbiz/trunk/applications/product/src/org/ofbiz/product/imagemanagement/ImageManagementHelper.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ofbiz/trunk/applications/product/src/org/ofbiz/product/imagemanagement/ImageManagementHelper.java
------------------------------------------------------------------------------
svn:keywords = Date Rev Author URL Id
Propchange: ofbiz/trunk/applications/product/src/org/ofbiz/product/imagemanagement/ImageManagementHelper.java
------------------------------------------------------------------------------
svn:mime-type = text/plain