Modified: ofbiz/branches/jackrabbit20100709/applications/product/script/org/ofbiz/product/product/ProductServices.xml
URL: http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/applications/product/script/org/ofbiz/product/product/ProductServices.xml?rev=1213245&r1=1213244&r2=1213245&view=diff ============================================================================== --- ofbiz/branches/jackrabbit20100709/applications/product/script/org/ofbiz/product/product/ProductServices.xml (original) +++ ofbiz/branches/jackrabbit20100709/applications/product/script/org/ofbiz/product/product/ProductServices.xml Mon Dec 12 13:53:03 2011 @@ -35,7 +35,12 @@ under the License. <sequenced-id sequence-name="Product" field="newEntity.productId"/> <else> <check-id field="newEntity.productId"/> - <check-errors/> + <check-errors /> + <entity-one value-field="dummyProduct" entity-name="Product"><field-map field-name="productId" from-field="parameters.productId"/></entity-one> + <if-not-empty field="dummyProduct"> + <add-error ><fail-property resource="CommonErrorUiLabels" property="CommonErrorDublicateKey" /></add-error> + </if-not-empty> + <check-errors /> </else> </if-empty> <field-to-result field="newEntity.productId" result-name="productId"/> @@ -1059,7 +1064,7 @@ under the License. <entity-one entity-name="ProductGroupOrder" value-field="productGroupOrder"/> <set-nonpk-fields value-field="productGroupOrder" map="parameters"/> <store-value value-field="productGroupOrder"/> - + <entity-one entity-name="JobSandbox" value-field="jobSandbox"> <field-map field-name="jobId" from-field="productGroupOrder.jobId"/> </entity-one> @@ -1067,15 +1072,15 @@ under the License. <set field="jobSandbox.runTime" from-field="parameters.thruDate"/> <store-value value-field="jobSandbox"/> </if-not-empty> - - <entity-one value-field="systemUserLogin" entity-name="UserLogin"> + + <entity-one entity-name="UserLogin" value-field="systemUserLogin"> <field-map field-name="userLoginId" value="system"/> </entity-one> <if-compare field="productGroupOrder.soldOrderQty" operator="equals" value="${productGroupOrder.reqOrderQty}"> <set field="checkProductGroupOrderExpiredMap.userLogin" from-field="systemUserLogin"/> <set field="checkProductGroupOrderExpiredMap.groupOrderId" from-field="productGroupOrder.groupOrderId"/> <call-service service-name="checkProductGroupOrderExpired" in-map-name="checkProductGroupOrderExpiredMap"/> - + <set field="cancelScheduledJobMap.userLogin" from-field="systemUserLogin"/> <set field="cancelScheduledJobMap.jobId" from-field="productGroupOrder.jobId"/> <call-service service-name="cancelScheduledJob" in-map-name="cancelScheduledJobMap"/> @@ -1084,50 +1089,74 @@ under the License. <simple-method method-name="deleteProductGroupOrder" short-description="Delete ProductGroupOrder"> <entity-one entity-name="ProductGroupOrder" value-field="productGroupOrder"/> + <entity-one entity-name="JobSandbox" value-field="jobSandbox"> + <field-map field-name="jobId" from-field="productGroupOrder.jobId"/> + </entity-one> + <entity-one entity-name="RuntimeData" value-field="runtimeData"> + <field-map field-name="runtimeDataId" from-field="jobSandbox.runtimeDataId"/> + </entity-one> + <remove-value value-field="productGroupOrder"/> + <remove-value value-field="jobSandbox"/> + <remove-value value-field="runtimeData"/> </simple-method> <simple-method method-name="createJobForProductGroupOrder" short-description="Create ProductGroupOrder"> - <!-- Create RuntimeData For ProductGroupOrder --> - <set field="runtimeDataMap.groupOrderId" from-field="parameters.groupOrderId"/> - <call-class-method class-name="org.ofbiz.entity.serialize.XmlSerializer" method-name="serialize" ret-field="runtimeInfo"> - <field field="runtimeDataMap" type="Object"/> - </call-class-method> - <make-value entity-name="RuntimeData" value-field="runtimeData"/> - <sequenced-id sequence-name="RuntimeData" field="runtimeData.runtimeDataId"/> - <set field="runtimeDataId" from-field="runtimeData.runtimeDataId"/> - <set field="runtimeData.runtimeInfo" from-field="runtimeInfo"/> - <create-value value-field="runtimeData"/> - - <!-- Create Job For ProductGroupOrder --> - <make-value entity-name="JobSandbox" value-field="jobSandbox"/> - <sequenced-id sequence-name="JobSandbox" field="jobSandbox.jobId"/> - <set field="jobId" from-field="jobSandbox.jobId"/> - <set field="jobSandbox.jobName" value="Check Product GroupOrder Expired"/> - <set field="jobSandbox.runTime" from-field="parameters.thruDate"/> - <set field="jobSandbox.poolId" value="pool"/> - <set field="jobSandbox.statusId" value="SERVICE_PENDING"/> - <set field="jobSandbox.serviceName" value="checkProductGroupOrderExpired"/> - <set field="jobSandbox.runAsUser" value="system"/> - <set field="jobSandbox.runtimeDataId" from-field="runtimeDataId"/> - <set field="jobSandbox.maxRecurrenceCount" value="1" type="Long"/> - <create-value value-field="jobSandbox"/> - <entity-one entity-name="ProductGroupOrder" value-field="productGroupOrder"/> - <set field="productGroupOrder.jobId" from-field="jobId"/> - <store-value value-field="productGroupOrder"/> + <if-empty field="productGroupOrder.jobId"> + <!-- Create RuntimeData For ProductGroupOrder --> + <set field="runtimeDataMap.groupOrderId" from-field="parameters.groupOrderId"/> + <call-class-method class-name="org.ofbiz.entity.serialize.XmlSerializer" method-name="serialize" ret-field="runtimeInfo"> + <field field="runtimeDataMap" type="Object"/> + </call-class-method> + <make-value entity-name="RuntimeData" value-field="runtimeData"/> + <sequenced-id sequence-name="RuntimeData" field="runtimeData.runtimeDataId"/> + <set field="runtimeDataId" from-field="runtimeData.runtimeDataId"/> + <set field="runtimeData.runtimeInfo" from-field="runtimeInfo"/> + <create-value value-field="runtimeData"/> + + <!-- Create Job For ProductGroupOrder --> + <make-value entity-name="JobSandbox" value-field="jobSandbox"/> + <sequenced-id sequence-name="JobSandbox" field="jobSandbox.jobId"/> + <set field="jobId" from-field="jobSandbox.jobId"/> + <set field="jobSandbox.jobName" value="Check Product GroupOrder Expired"/> + <set field="jobSandbox.runTime" from-field="parameters.thruDate"/> + <set field="jobSandbox.poolId" value="pool"/> + <set field="jobSandbox.statusId" value="SERVICE_PENDING"/> + <set field="jobSandbox.serviceName" value="checkProductGroupOrderExpired"/> + <set field="jobSandbox.runAsUser" value="system"/> + <set field="jobSandbox.runtimeDataId" from-field="runtimeDataId"/> + <set field="jobSandbox.maxRecurrenceCount" value="1" type="Long"/> + <create-value value-field="jobSandbox"/> + + <set field="productGroupOrder.jobId" from-field="jobId"/> + <store-value value-field="productGroupOrder"/> + </if-empty> </simple-method> - <simple-method method-name="checkOrderItemForProductGroupOrder" short-description="Check Order Item For ProductGroupOrder"> - <entity-one value-field="systemUserLogin" entity-name="UserLogin"> + <simple-method method-name="checkOrderItemForProductGroupOrder" short-description="Check OrderItem For ProductGroupOrder"> + <entity-one entity-name="UserLogin" value-field="systemUserLogin"> <field-map field-name="userLoginId" value="system"/> </entity-one> <entity-and entity-name="OrderItem" list="orderItems"> <field-map field-name="orderId" from-field="parameters.orderId"/> </entity-and> <iterate entry="orderItem" list="orderItems"> - <entity-and entity-name="ProductGroupOrder" list="productGroupOrders" filter-by-date="true"> + <set field="productId" from-field="orderItem.productId"/> + <entity-one entity-name="Product" value-field="product"> <field-map field-name="productId" from-field="orderItem.productId"/> + </entity-one> + <if-compare field="product.isVariant" operator="equals" value="Y"> + <entity-and entity-name="ProductAssoc" list="variantProductAssocs" filter-by-date="true"> + <field-map field-name="productIdTo" from-field="orderItem.productId"/> + <field-map field-name="productAssocTypeId" value="PRODUCT_VARIANT"/> + </entity-and> + <first-from-list entry="variantProductAssoc" list="variantProductAssocs"/> + <set field="productId" from-field="variantProductAssoc.productId"/> + </if-compare> + + <entity-and entity-name="ProductGroupOrder" list="productGroupOrders" filter-by-date="true"> + <field-map field-name="productId" from-field="productId"/> </entity-and> <iterate entry="productGroupOrder" list="productGroupOrders"> <if-compare field="productGroupOrder.soldOrderQty" operator="less" value="${productGroupOrder.reqOrderQty}"> @@ -1137,12 +1166,12 @@ under the License. </calcop> </calculate> <store-value value-field="productGroupOrder"/> - + <if-compare field="productGroupOrder.soldOrderQty" operator="equals" value="${productGroupOrder.reqOrderQty}"> <set field="checkProductGroupOrderExpiredMap.userLogin" from-field="systemUserLogin"/> <set field="checkProductGroupOrderExpiredMap.groupOrderId" from-field="productGroupOrder.groupOrderId"/> <call-service service-name="checkProductGroupOrderExpired" in-map-name="checkProductGroupOrderExpiredMap"/> - + <set field="cancelScheduledJobMap.userLogin" from-field="systemUserLogin"/> <set field="cancelScheduledJobMap.jobId" from-field="productGroupOrder.jobId"/> <call-service service-name="cancelScheduledJob" in-map-name="cancelScheduledJobMap"/> @@ -1160,9 +1189,36 @@ under the License. <set field="newItemStatusId" value="ITEM_CANCELLED"/> </else> </if-compare> + + <entity-one entity-name="Product" value-field="product"> + <field-map field-name="productId" from-field="productGroupOrder.productId"/> + </entity-one> + <if-compare field="product.isVirtual" operator="equals" value="Y"> + <entity-and entity-name="ProductAssoc" list="variantProductAssocs" filter-by-date="true"> + <field-map field-name="productId" from-field="productGroupOrder.productId"/> + <field-map field-name="productAssocTypeId" value="PRODUCT_VARIANT"/> + </entity-and> + <iterate entry="variantProductAssoc" list="variantProductAssocs"> + <set field="findOrderItemMap.productId" from-field="variantProductAssoc.productIdTo"/> + <set field="findOrderItemMap.newItemStatusId" from-field="newItemStatusId"/> + <set field="findOrderItemMap.fromDate" from-field="productGroupOrder.fromDate"/> + <set field="findOrderItemMap.thruDate" from-field="productGroupOrder.thruDate"/> + <call-service service-name="findOrderItemForProductGroupOrder" in-map-name="findOrderItemMap"/> + </iterate> + <else> + <set field="findOrderItemMap.productId" from-field="productGroupOrder.productId"/> + <set field="findOrderItemMap.newItemStatusId" from-field="newItemStatusId"/> + <set field="findOrderItemMap.fromDate" from-field="productGroupOrder.fromDate"/> + <set field="findOrderItemMap.thruDate" from-field="productGroupOrder.thruDate"/> + <call-service service-name="findOrderItemForProductGroupOrder" in-map-name="findOrderItemMap"/> + </else> + </if-compare> + </simple-method> + + <simple-method method-name="findOrderItemForProductGroupOrder" short-description="Find OrderItem For ProductGroupOrder"> <entity-condition entity-name="OrderItem" list="orderItems"> <condition-list combine="and"> - <condition-expr field-name="productId" operator="equals" from-field="productGroupOrder.productId"/> + <condition-expr field-name="productId" operator="equals" from-field="parameters.productId"/> <condition-list combine="or"> <condition-expr field-name="statusId" operator="equals" value="ITEM_CREATED"/> <condition-expr field-name="statusId" operator="equals" value="ITEM_APPROVED"/> @@ -1177,14 +1233,14 @@ under the License. <condition> <and> <if-compare field="orderHeader.orderTypeId" operator="equals" value="SALES_ORDER"/> - <if-compare field="orderHeader.orderDate" operator="greater-equals" value="${productGroupOrder.fromDate}"/> - <if-compare field="orderHeader.orderDate" operator="less" value="${productGroupOrder.thruDate}"/> + <if-compare field="orderHeader.orderDate" operator="greater-equals" value="${parameters.fromDate}"/> + <if-compare field="orderHeader.orderDate" operator="less" value="${parameters.thruDate}"/> </and> </condition> <then> <set field="changeOrderItemStatusMap.orderId" from-field="orderItem.orderId"/> <set field="changeOrderItemStatusMap.orderItemSeqId" from-field="orderItem.orderItemSeqId"/> - <set field="changeOrderItemStatusMap.statusId" from-field="newItemStatusId"/> + <set field="changeOrderItemStatusMap.statusId" from-field="parameters.newItemStatusId"/> <call-service service-name="changeOrderItemStatus" in-map-name="changeOrderItemStatusMap"/> </then> </if> Modified: ofbiz/branches/jackrabbit20100709/applications/product/servicedef/services.xml URL: http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/applications/product/servicedef/services.xml?rev=1213245&r1=1213244&r2=1213245&view=diff ============================================================================== --- ofbiz/branches/jackrabbit20100709/applications/product/servicedef/services.xml (original) +++ ofbiz/branches/jackrabbit20100709/applications/product/servicedef/services.xml Mon Dec 12 13:53:03 2011 @@ -1698,7 +1698,7 @@ under the License. <service name="checkOrderItemForProductGroupOrder" engine="simple" location="component://product/script/org/ofbiz/product/product/ProductServices.xml" invoke="checkOrderItemForProductGroupOrder" auth="true"> - <description>Check Order Item For ProductGroupOrder</description> + <description>Check OrderItem For ProductGroupOrder</description> <attribute name="orderId" mode="IN" type="String" optional="false"/> </service> @@ -1708,4 +1708,13 @@ under the License. <attribute name="groupOrderId" mode="IN" type="String" optional="false"/> </service> + <service name="findOrderItemForProductGroupOrder" engine="simple" + location="component://product/script/org/ofbiz/product/product/ProductServices.xml" invoke="findOrderItemForProductGroupOrder" auth="true"> + <description>Find OrderItem For ProductGroupOrder</description> + <attribute name="productId" mode="IN" type="String" optional="false"/> + <attribute name="newItemStatusId" mode="IN" type="String" optional="false"/> + <attribute name="fromDate" mode="IN" type="Timestamp" optional="false"/> + <attribute name="thruDate" mode="IN" type="Timestamp" optional="false"/> + </service> + </services> Modified: ofbiz/branches/jackrabbit20100709/applications/product/webapp/catalog/WEB-INF/actions/imagemanagement/ImageGallery.groovy URL: http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/applications/product/webapp/catalog/WEB-INF/actions/imagemanagement/ImageGallery.groovy?rev=1213245&r1=1213244&r2=1213245&view=diff ============================================================================== --- ofbiz/branches/jackrabbit20100709/applications/product/webapp/catalog/WEB-INF/actions/imagemanagement/ImageGallery.groovy (original) +++ ofbiz/branches/jackrabbit20100709/applications/product/webapp/catalog/WEB-INF/actions/imagemanagement/ImageGallery.groovy Mon Dec 12 13:53:03 2011 @@ -1,50 +1,50 @@ -/* - * 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. - */ - -/* - * This script is also referenced by the ecommerce's screens and - * should not contain order component's specific code. - */ - -import org.ofbiz.base.util.*; -import org.ofbiz.entity.*; -import org.ofbiz.entity.condition.*; -import org.ofbiz.entity.util.*; - -productImageList = []; -productContentAndInfoImageManamentList = delegator.findByAnd("ProductContentAndInfo", ["productId": productId, productContentTypeId : "IMAGE", "statusId" : "IM_APPROVED", "drIsPublic" : "Y"], ["sequenceNum"]); -if(productContentAndInfoImageManamentList) { - productContentAndInfoImageManamentList.each { productContentAndInfoImageManament -> - contentAssocThumbList = delegator.findByAnd("ContentAssoc", [contentId : productContentAndInfoImageManament.contentId, contentAssocTypeId : "IMAGE_THUMBNAIL"]); - contentAssocThumb = EntityUtil.getFirst(contentAssocThumbList); - if(contentAssocThumb) { - imageContentThumb = delegator.findByPrimaryKey("Content", [contentId : contentAssocThumb.contentIdTo]); - if(imageContentThumb) { - productImageThumb = delegator.findByPrimaryKey("ContentDataResourceView", [contentId : imageContentThumb.contentId, drDataResourceId : imageContentThumb.dataResourceId]); - productImageMap = [:]; - productImageMap.contentId = productContentAndInfoImageManament.contentId; - productImageMap.dataResourceId = productContentAndInfoImageManament.dataResourceId; - productImageMap.productImageThumb = productImageThumb.drObjectInfo; - productImageMap.productImage = productContentAndInfoImageManament.drObjectInfo; - productImageList.add(productImageMap); - } - } - } - context.productImageList = productImageList; -} +/* + * 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. + */ + +/* + * This script is also referenced by the ecommerce's screens and + * should not contain order component's specific code. + */ + +import org.ofbiz.base.util.*; +import org.ofbiz.entity.*; +import org.ofbiz.entity.condition.*; +import org.ofbiz.entity.util.*; + +productImageList = []; +productContentAndInfoImageManamentList = delegator.findByAnd("ProductContentAndInfo", ["productId": productId, productContentTypeId : "IMAGE", "statusId" : "IM_APPROVED"], ["sequenceNum"]); +if(productContentAndInfoImageManamentList) { + productContentAndInfoImageManamentList.each { productContentAndInfoImageManament -> + contentAssocThumbList = delegator.findByAnd("ContentAssoc", [contentId : productContentAndInfoImageManament.contentId, contentAssocTypeId : "IMAGE_THUMBNAIL"]); + contentAssocThumb = EntityUtil.getFirst(contentAssocThumbList); + if(contentAssocThumb) { + imageContentThumb = delegator.findByPrimaryKey("Content", [contentId : contentAssocThumb.contentIdTo]); + if(imageContentThumb) { + productImageThumb = delegator.findByPrimaryKey("ContentDataResourceView", [contentId : imageContentThumb.contentId, drDataResourceId : imageContentThumb.dataResourceId]); + productImageMap = [:]; + productImageMap.contentId = productContentAndInfoImageManament.contentId; + productImageMap.dataResourceId = productContentAndInfoImageManament.dataResourceId; + productImageMap.productImageThumb = productImageThumb.drObjectInfo; + productImageMap.productImage = productContentAndInfoImageManament.drObjectInfo; + productImageList.add(productImageMap); + } + } + } + context.productImageList = productImageList; +} Modified: ofbiz/branches/jackrabbit20100709/applications/product/webapp/catalog/WEB-INF/actions/imagemanagement/SetDefaultImage.groovy URL: http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/applications/product/webapp/catalog/WEB-INF/actions/imagemanagement/SetDefaultImage.groovy?rev=1213245&r1=1213244&r2=1213245&view=diff ============================================================================== --- ofbiz/branches/jackrabbit20100709/applications/product/webapp/catalog/WEB-INF/actions/imagemanagement/SetDefaultImage.groovy (original) +++ ofbiz/branches/jackrabbit20100709/applications/product/webapp/catalog/WEB-INF/actions/imagemanagement/SetDefaultImage.groovy Mon Dec 12 13:53:03 2011 @@ -1,175 +1,180 @@ -/* - * 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. - */ - -import java.awt.image.BufferedImage; -import java.awt.image.RenderedImage; -import java.io.File; -import java.util.List; - -import javax.imageio.ImageIO; - -import org.ofbiz.entity.*; -import org.ofbiz.entity.util.EntityUtil; -import org.ofbiz.base.util.*; -import org.ofbiz.base.util.string.*; -import org.ofbiz.product.image.ScaleImage; - -context.nowTimestampString = UtilDateTime.nowTimestamp().toString(); - -imageManagementPath = FlexibleStringExpander.expandString(UtilProperties.getPropertyValue("catalog", "image.management.path"), context); - -String fileType = "original"; -String productId = request.getParameter("productId"); - -productContentList = delegator.findByAnd("ProductContentAndInfo", UtilMisc.toMap("productId", productId, "productContentTypeId", "DEFAULT_IMAGE")); -if (productContentList) { - dataResourceName = productContentList.get(0).drDataResourceName -} - -// make the image file formats -imageFilenameFormat = UtilProperties.getPropertyValue('catalog', 'image.filename.format'); -imageServerPath = FlexibleStringExpander.expandString(UtilProperties.getPropertyValue("catalog", "image.server.path"), context); -imageUrlPrefix = UtilProperties.getPropertyValue('catalog', 'image.url.prefix'); -context.imageFilenameFormat = imageFilenameFormat; -context.imageServerPath = imageServerPath; -context.imageUrlPrefix = imageUrlPrefix; - -filenameExpander = FlexibleStringExpander.getInstance(imageFilenameFormat); -context.imageNameSmall = imageUrlPrefix + "/" + filenameExpander.expandString([location : 'products', id : productId, type : 'small']); -context.imageNameMedium = imageUrlPrefix + "/" + filenameExpander.expandString([location : 'products', id : productId, type : 'medium']); -context.imageNameLarge = imageUrlPrefix + "/" + filenameExpander.expandString([location : 'products', id : productId, type : 'large']); -context.imageNameDetail = imageUrlPrefix + "/" + filenameExpander.expandString([location : 'products', id : productId, type : 'detail']); -context.imageNameOriginal = imageUrlPrefix + "/" + filenameExpander.expandString([location : 'products', id : productId, type : 'original']); - -// Start ProductContent stuff -if (productId) { - product = delegator.findByPrimaryKey("Product",["productId" : productId]); - context.productId = productId; -} - -productContent = null; -if (product) { - productContent = product.getRelated('ProductContent', null, ['productContentTypeId']); -} -context.productContent = productContent; -// End ProductContent stuff - -tryEntity = true; -if (request.getAttribute("_ERROR_MESSAGE_")) { - tryEntity = false; -} -if (!product) { - tryEntity = false; -} - -if ("true".equalsIgnoreCase((String) request.getParameter("tryEntity"))) { - tryEntity = true; -} -context.tryEntity = tryEntity; - -//UPLOADING STUFF -forLock = new Object(); -contentType = null; -if (fileType) { - - context.fileType = fileType; - - fileLocation = filenameExpander.expandString([location : 'products', id : productId, type : fileType]); - filePathPrefix = ""; - filenameToUse = fileLocation; - if (fileLocation.lastIndexOf("/") != -1) { - filePathPrefix = fileLocation.substring(0, fileLocation.lastIndexOf("/") + 1); // adding 1 to include the trailing slash - filenameToUse = fileLocation.substring(fileLocation.lastIndexOf("/") + 1); - } - - int i1; - if (contentType && (i1 = contentType.indexOf("boundary=")) != -1) { - contentType = contentType.substring(i1 + 9); - contentType = "--" + contentType; - } - - defaultFileName = "temp_" + dataResourceName; - BufferedImage bufImg = ImageIO.read(new File(imageManagementPath + "/" + productId + "/" + dataResourceName)); - ImageIO.write((RenderedImage) bufImg, "jpg", new File(imageManagementPath + "/" + productId + "/" + defaultFileName)); - - clientFileName = dataResourceName; - if (clientFileName) { - context.clientFileName = clientFileName; - } - - if (clientFileName && clientFileName.length() > 0) { - if (clientFileName.lastIndexOf(".") > 0 && clientFileName.lastIndexOf(".") < clientFileName.length()) { - filenameToUse += clientFileName.substring(clientFileName.lastIndexOf(".")); - } else { - filenameToUse += ".jpg"; - } - - context.clientFileName = clientFileName; - context.filenameToUse = filenameToUse; - - characterEncoding = request.getCharacterEncoding(); - imageUrl = imageUrlPrefix + "/" + filePathPrefix + java.net.URLEncoder.encode(filenameToUse, characterEncoding); - - try { - file = new File(imageManagementPath + "/" + productId + "/" + defaultFileName); - file1 = new File(imageServerPath + "/" + filePathPrefix, filenameToUse); - try { - // Delete existing image files - File targetDir = new File(imageServerPath + "/" + filePathPrefix); - // Images are ordered by productId (${location}/${id}/${viewtype}/${sizetype}) - if (!filenameToUse.startsWith(productId + ".")) { - File[] files = targetDir.listFiles(); - for(File file : files) { - if (file.isFile() && !file.getName().equals(defaultFileName)) file.delete(); - } - // Images aren't ordered by productId (${location}/${viewtype}/${sizetype}/${id}) !!! BE CAREFUL !!! - } else { - File[] files = targetDir.listFiles(); - for(File file : files) { - if (file.isFile() && !file.getName().equals(defaultFileName) && file.getName().startsWith(productId + ".")) file.delete(); - } - } - } catch (Exception e) { - System.out.println("error deleting existing file (not neccessarily a problem)"); - } - file.renameTo(file1); - } catch (Exception e) { - e.printStackTrace(); - } - - if (imageUrl && imageUrl.length() > 0) { - context.imageUrl = imageUrl; - product.set(fileType + "ImageUrl", imageUrl); - - // call scaleImageInAllSize - if (fileType.equals("original")) { - result = ScaleImage.scaleImageInAllSize(context, filenameToUse, "main", "0"); - - if (result.containsKey("responseMessage") && result.get("responseMessage").equals("success")) { - imgMap = result.get("imageUrlMap"); - imgMap.each() { key, value -> - product.set(key + "ImageUrl", value); - } - } - } - - product.store(); - } - } -} +/* + * 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. + */ + +import java.awt.image.BufferedImage; +import java.awt.image.RenderedImage; +import java.io.File; +import java.util.List; + +import javax.imageio.ImageIO; + +import org.ofbiz.entity.*; +import org.ofbiz.entity.util.EntityUtil; +import org.ofbiz.base.util.*; +import org.ofbiz.base.util.string.*; +import org.ofbiz.product.image.ScaleImage; + +context.nowTimestampString = UtilDateTime.nowTimestamp().toString(); + +imageManagementPath = FlexibleStringExpander.expandString(UtilProperties.getPropertyValue("catalog", "image.management.path"), context); + +String fileType = "original"; +String productId = request.getParameter("productId"); + +productContentList = delegator.findByAnd("ProductContentAndInfo", UtilMisc.toMap("productId", productId, "productContentTypeId", "DEFAULT_IMAGE")); +if (productContentList) { + dataResourceName = productContentList.get(0).drDataResourceName +} + +// make the image file formats +imageFilenameFormat = UtilProperties.getPropertyValue('catalog', 'image.filename.format'); +imageServerPath = FlexibleStringExpander.expandString(UtilProperties.getPropertyValue("catalog", "image.server.path"), context); +imageUrlPrefix = UtilProperties.getPropertyValue('catalog', 'image.url.prefix'); +context.imageFilenameFormat = imageFilenameFormat; +context.imageServerPath = imageServerPath; +context.imageUrlPrefix = imageUrlPrefix; + +filenameExpander = FlexibleStringExpander.getInstance(imageFilenameFormat); +context.imageNameSmall = imageUrlPrefix + "/" + filenameExpander.expandString([location : 'products', id : productId, type : 'small']); +context.imageNameMedium = imageUrlPrefix + "/" + filenameExpander.expandString([location : 'products', id : productId, type : 'medium']); +context.imageNameLarge = imageUrlPrefix + "/" + filenameExpander.expandString([location : 'products', id : productId, type : 'large']); +context.imageNameDetail = imageUrlPrefix + "/" + filenameExpander.expandString([location : 'products', id : productId, type : 'detail']); +context.imageNameOriginal = imageUrlPrefix + "/" + filenameExpander.expandString([location : 'products', id : productId, type : 'original']); + +// Start ProductContent stuff +if (productId) { + product = delegator.findByPrimaryKey("Product",["productId" : productId]); + context.productId = productId; +} + +productContent = null; +if (product) { + productContent = product.getRelated('ProductContent', null, ['productContentTypeId']); +} +context.productContent = productContent; +// End ProductContent stuff + +tryEntity = true; +if (request.getAttribute("_ERROR_MESSAGE_")) { + tryEntity = false; +} +if (!product) { + tryEntity = false; +} + +if ("true".equalsIgnoreCase((String) request.getParameter("tryEntity"))) { + tryEntity = true; +} +context.tryEntity = tryEntity; + +//UPLOADING STUFF +forLock = new Object(); +contentType = null; +if (fileType) { + + context.fileType = fileType; + + fileLocation = filenameExpander.expandString([location : 'products', id : productId, type : fileType]); + filePathPrefix = ""; + filenameToUse = fileLocation; + if (fileLocation.lastIndexOf("/") != -1) { + filePathPrefix = fileLocation.substring(0, fileLocation.lastIndexOf("/") + 1); // adding 1 to include the trailing slash + filenameToUse = fileLocation.substring(fileLocation.lastIndexOf("/") + 1); + } + + int i1; + if (contentType && (i1 = contentType.indexOf("boundary=")) != -1) { + contentType = contentType.substring(i1 + 9); + contentType = "--" + contentType; + } + + defaultFileName = "temp_" + dataResourceName; + checkPathFile = imageManagementPath + "/" + productId + "/" + dataResourceName; + if (checkPathFile.equals(productContentList.get(0).drObjectInfo)) { + BufferedImage bufImg = ImageIO.read(new File(imageManagementPath + "/" + productId + "/" + dataResourceName)); + } else { + BufferedImage bufImg = ImageIO.read(new File(productContentList.get(0).drObjectInfo))); + } + ImageIO.write((RenderedImage) bufImg, "jpg", new File(imageManagementPath + "/" + productId + "/" + defaultFileName)); + + clientFileName = dataResourceName; + if (clientFileName) { + context.clientFileName = clientFileName; + } + + if (clientFileName && clientFileName.length() > 0) { + if (clientFileName.lastIndexOf(".") > 0 && clientFileName.lastIndexOf(".") < clientFileName.length()) { + filenameToUse += clientFileName.substring(clientFileName.lastIndexOf(".")); + } else { + filenameToUse += ".jpg"; + } + + context.clientFileName = clientFileName; + context.filenameToUse = filenameToUse; + + characterEncoding = request.getCharacterEncoding(); + imageUrl = imageUrlPrefix + "/" + filePathPrefix + java.net.URLEncoder.encode(filenameToUse, characterEncoding); + + try { + file = new File(imageManagementPath + "/" + productId + "/" + defaultFileName); + file1 = new File(imageServerPath + "/" + filePathPrefix, filenameToUse); + try { + // Delete existing image files + File targetDir = new File(imageServerPath + "/" + filePathPrefix); + // Images are ordered by productId (${location}/${id}/${viewtype}/${sizetype}) + if (!filenameToUse.startsWith(productId + ".")) { + File[] files = targetDir.listFiles(); + for(File file : files) { + if (file.isFile() && !file.getName().equals(defaultFileName)) file.delete(); + } + // Images aren't ordered by productId (${location}/${viewtype}/${sizetype}/${id}) !!! BE CAREFUL !!! + } else { + File[] files = targetDir.listFiles(); + for(File file : files) { + if (file.isFile() && !file.getName().equals(defaultFileName) && file.getName().startsWith(productId + ".")) file.delete(); + } + } + } catch (Exception e) { + System.out.println("error deleting existing file (not neccessarily a problem)"); + } + file.renameTo(file1); + } catch (Exception e) { + e.printStackTrace(); + } + + if (imageUrl && imageUrl.length() > 0) { + context.imageUrl = imageUrl; + product.set(fileType + "ImageUrl", imageUrl); + + // call scaleImageInAllSize + if (fileType.equals("original")) { + result = ScaleImage.scaleImageInAllSize(context, filenameToUse, "main", "0"); + + if (result.containsKey("responseMessage") && result.get("responseMessage").equals("success")) { + imgMap = result.get("imageUrlMap"); + imgMap.each() { key, value -> + product.set(key + "ImageUrl", value); + } + } + } + + product.store(); + } + } +} Modified: ofbiz/branches/jackrabbit20100709/applications/product/webapp/facility/WEB-INF/controller.xml URL: http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/applications/product/webapp/facility/WEB-INF/controller.xml?rev=1213245&r1=1213244&r2=1213245&view=diff ============================================================================== --- ofbiz/branches/jackrabbit20100709/applications/product/webapp/facility/WEB-INF/controller.xml (original) +++ ofbiz/branches/jackrabbit20100709/applications/product/webapp/facility/WEB-INF/controller.xml Mon Dec 12 13:53:03 2011 @@ -1352,10 +1352,7 @@ under the License. <response name="success" type="request" value="json"/> <response name="error" type="request" value="json"/> </request-map> - <request-map uri="Tracking"> - <security https="true" auth="true" /> - <response name="success" type="view" value="Tracking" /> - </request-map> + <!-- ================ Lookup Requests ================= --> <request-map uri="LookupOrderHeaderAndShipInfo"><security https="true" auth="true"/><response name="success" type="view" value="LookupOrderHeaderAndShipInfo"/></request-map> <request-map uri="LookupPurchaseOrderHeaderAndShipInfo"><security https="true" auth="true"/><response name="success" type="view" value="LookupPurchaseOrderHeaderAndShipInfo"/></request-map> @@ -1471,8 +1468,6 @@ under the License. <view-map name="LookupPartyName" type="screen" page="component://party/widget/partymgr/LookupScreens.xml#LookupPartyName"/> <view-map name="LookupInventoryItem" type="screen" page="component://product/widget/facility/LookupScreens.xml#LookupInventoryItem"/> <view-map name="LookupContent" type="screen" page="component://content/widget/content/ContentScreens.xml#LookupContent"/> - - <view-map name="Tracking" page="component://product//widget/facility/TrackingScreens.xml#LookingForTracking" type="screen" /> <!-- Shipment Gateway Config --> <view-map name="FindShipmentGatewayConfig" page="component://product//widget/facility/ShipmentGatewayConfigScreens.xml#FindShipmentGatewayConfig" type="screen"/> Modified: ofbiz/branches/jackrabbit20100709/applications/product/webapp/facility/facility/PicklistManage.ftl URL: http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/applications/product/webapp/facility/facility/PicklistManage.ftl?rev=1213245&r1=1213244&r2=1213245&view=diff ============================================================================== --- ofbiz/branches/jackrabbit20100709/applications/product/webapp/facility/facility/PicklistManage.ftl (original) +++ ofbiz/branches/jackrabbit20100709/applications/product/webapp/facility/facility/PicklistManage.ftl Mon Dec 12 13:53:03 2011 @@ -123,7 +123,7 @@ under the License. <#if picklistBinInfo.picklistItemInfoList?has_content> <div style="margin-left: 30px;"> <table class="basic-table" cellspacing="0"> - <tr class="header-row" + <tr class="header-row"> <td>${uiLabelMap.ProductOrderId}</td> <td>${uiLabelMap.ProductOrderShipGroupId}</td> <td>${uiLabelMap.ProductOrderItem}</td> Modified: ofbiz/branches/jackrabbit20100709/applications/product/widget/catalog/ImageManagementForms.xml URL: http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/applications/product/widget/catalog/ImageManagementForms.xml?rev=1213245&r1=1213244&r2=1213245&view=diff ============================================================================== --- ofbiz/branches/jackrabbit20100709/applications/product/widget/catalog/ImageManagementForms.xml (original) +++ ofbiz/branches/jackrabbit20100709/applications/product/widget/catalog/ImageManagementForms.xml Mon Dec 12 13:53:03 2011 @@ -318,7 +318,7 @@ under the License. </field> <field name="description" use-when="${groovy: return context.statusId == 'IM_APPROVED';}" title="${uiLabelMap.ImageManagementCaption}"><text/></field> <field name="sequenceNum" use-when="${groovy: return context.statusId == 'IM_APPROVED';}" title="${uiLabelMap.ImageManagementSortOrder}"><text maxlength="2" size="5"/></field> - <field name="drIsPublic" use-when="${groovy: return context.statusId == 'IM_APPROVED';}" title="${uiLabelMap.CommonEnable}"><check/></field> + <field name="drIsPublic" use-when="${groovy: return context.statusId == 'IM_APPROVED';}" title="${uiLabelMap.ImageManagementPublic}"><check/></field> <field name="defaultImage" use-when="${groovy: return context.statusId == 'IM_APPROVED';}" title="${uiLabelMap.ImageManagementDefaultImage}" widget-style="buttontext"> <hyperlink target="setDefaultImage" description="${uiLabelMap.ImageManagementSetDefault}"> <parameter param-name="productId"/> Modified: ofbiz/branches/jackrabbit20100709/applications/product/widget/catalog/ProductForms.xml URL: http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/applications/product/widget/catalog/ProductForms.xml?rev=1213245&r1=1213244&r2=1213245&view=diff ============================================================================== --- ofbiz/branches/jackrabbit20100709/applications/product/widget/catalog/ProductForms.xml (original) +++ ofbiz/branches/jackrabbit20100709/applications/product/widget/catalog/ProductForms.xml Mon Dec 12 13:53:03 2011 @@ -590,6 +590,7 @@ under the License. <field name="useTime"><display/></field> <field name="useTimeUomId"><display/></field> <field name="useRoleTypeId"><display/></field> + <field name="sequenceNum"><display/></field> <field name="editContent" title="${uiLabelMap.ProductEditContent}" widget-style="buttontext"> <hyperlink target="/content/control/EditContent" target-type="inter-app" description="${contentId}" also-hidden="false"> <parameter param-name="contentId"/> Modified: ofbiz/branches/jackrabbit20100709/applications/product/widget/facility/FacilityMenus.xml URL: http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/applications/product/widget/facility/FacilityMenus.xml?rev=1213245&r1=1213244&r2=1213245&view=diff ============================================================================== --- ofbiz/branches/jackrabbit20100709/applications/product/widget/facility/FacilityMenus.xml (original) +++ ofbiz/branches/jackrabbit20100709/applications/product/widget/facility/FacilityMenus.xml Mon Dec 12 13:53:03 2011 @@ -40,7 +40,6 @@ under the License. <parameter param-name="facilityId"/> </link> </menu-item> - <menu-item name="tracking" title="${uiLabelMap.Tracking}"><link target="Tracking"/></menu-item> </menu> <menu name="FacilityTabBar" extends="CommonTabBarMenu" extends-resource="component://common/widget/CommonMenus.xml" Modified: ofbiz/branches/jackrabbit20100709/applications/workeffort/config/WorkEffortUiLabels.xml URL: http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/applications/workeffort/config/WorkEffortUiLabels.xml?rev=1213245&r1=1213244&r2=1213245&view=diff ============================================================================== --- ofbiz/branches/jackrabbit20100709/applications/workeffort/config/WorkEffortUiLabels.xml (original) +++ ofbiz/branches/jackrabbit20100709/applications/workeffort/config/WorkEffortUiLabels.xml Mon Dec 12 13:53:03 2011 @@ -91,7 +91,7 @@ <property key="FormFieldTitle_approvedByUserLoginId"> <value xml:lang="de">Genehmigt von Benutzer ID</value> <value xml:lang="en">Approved By User Login Id</value> - <value xml:lang="fr">Approuvé par la réf. d'utilisateur de connexion</value> + <value xml:lang="fr">Approuvé par</value> <value xml:lang="it">Approvato dall'utente</value> <value xml:lang="zh">批准者用户登录标识</value> <value xml:lang="zh_TW">核准使用者登入ID</value> @@ -1325,7 +1325,7 @@ <property key="PageTitleListWorkEffortTimeEntries"> <value xml:lang="en">Work Effort Time Entries</value> <value xml:lang="es">Entradas de tiempo</value> - <value xml:lang="fr">Planifications horaires de la tâche</value> + <value xml:lang="fr">Détails des temps passés sur la tâche</value> <value xml:lang="it">Pianificazione oraria dell'impegno di lavoro</value> <value xml:lang="nl">Activiteit Time Entries</value> <value xml:lang="ro">Introducere Sarcina de Lucru Timp</value> Modified: ofbiz/branches/jackrabbit20100709/framework/base/config/ofbiz-containers.xml URL: http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/framework/base/config/ofbiz-containers.xml?rev=1213245&r1=1213244&r2=1213245&view=diff ============================================================================== --- ofbiz/branches/jackrabbit20100709/framework/base/config/ofbiz-containers.xml (original) +++ ofbiz/branches/jackrabbit20100709/framework/base/config/ofbiz-containers.xml Mon Dec 12 13:53:03 2011 @@ -270,7 +270,7 @@ under the License. </container> <!-- load BeanShell remote telnet server --> - <!-- Uncommented by default for security reasons --> + <!-- Commented out by default for security reasons --> <!-- the port below and port-1 will be opened by Beanshell --> <!--container name="beanshell-container" class="org.ofbiz.base.container.BeanShellContainer"> <property name="telnet-port" value="9990"/> @@ -278,7 +278,7 @@ under the License. </container--> <!-- load Groovy remote telnet server --> - <!-- Uncommented by default for security reasons --> + <!-- Commented out by default for security reasons --> <!-- the port below will be opened by Groovy --> <!--container name="groovyshell-container" class="org.ofbiz.base.container.GroovyShellContainer"> <property name="telnet-port" value="9991"/> Modified: ofbiz/branches/jackrabbit20100709/framework/base/src/org/ofbiz/base/util/StringUtil.java URL: http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/framework/base/src/org/ofbiz/base/util/StringUtil.java?rev=1213245&r1=1213244&r2=1213245&view=diff ============================================================================== --- ofbiz/branches/jackrabbit20100709/framework/base/src/org/ofbiz/base/util/StringUtil.java (original) +++ ofbiz/branches/jackrabbit20100709/framework/base/src/org/ofbiz/base/util/StringUtil.java Mon Dec 12 13:53:03 2011 @@ -223,13 +223,14 @@ public class StringUtil { /** * Creates a Map from an encoded name/value pair string * @param str The string to decode and format + * @param delim the delimiter character(s) to join on (null will split on whitespace) * @param trim Trim whitespace off fields * @return a Map of name/value pairs */ - public static Map<String, String> strToMap(String str, boolean trim) { + public static Map<String, String> strToMap(String str, String delim, boolean trim) { if (str == null) return null; Map<String, String> decodedMap = FastMap.newInstance(); - List<String> elements = split(str, "|"); + List<String> elements = split(str, delim); for (String s: elements) { List<String> e = split(s, "="); @@ -260,12 +261,33 @@ public class StringUtil { /** * Creates a Map from an encoded name/value pair string * @param str The string to decode and format + * @param trim Trim whitespace off fields + * @return a Map of name/value pairs + */ + public static Map<String, String> strToMap(String str, boolean trim) { + return strToMap(str, "|", trim); + } + + /** + * Creates a Map from an encoded name/value pair string + * @param str The string to decode and format + * @param delim the delimiter character(s) to join on (null will split on whitespace) + * @return a Map of name/value pairs + */ + public static Map<String, String> strToMap(String str, String delim) { + return strToMap(str, delim, false); + } + + /** + * Creates a Map from an encoded name/value pair string + * @param str The string to decode and format * @return a Map of name/value pairs */ public static Map<String, String> strToMap(String str) { - return strToMap(str, false); + return strToMap(str, "|", false); } + /** * Creates an encoded String from a Map of name/value pairs (MUST BE STRINGS!) * @param map The Map of name/value pairs Modified: ofbiz/branches/jackrabbit20100709/framework/common/config/CommonErrorUiLabels.xml URL: http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/framework/common/config/CommonErrorUiLabels.xml?rev=1213245&r1=1213244&r2=1213245&view=diff ============================================================================== --- ofbiz/branches/jackrabbit20100709/framework/common/config/CommonErrorUiLabels.xml (original) +++ ofbiz/branches/jackrabbit20100709/framework/common/config/CommonErrorUiLabels.xml Mon Dec 12 13:53:03 2011 @@ -19,6 +19,10 @@ under the License. --> <resource xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <property key="CommonErrorDublicateKey"> + <value xml:lang="de">Doppelter Primärschlüssel. Der Primärschlüssel existiert bereits.</value> + <value xml:lang="en">Dublicate Key. The Key already exist.</value> + </property> <property key="ImageTransform.error_occurs_during_reading"> <value xml:lang="da">Der opstår en fejl under læsning</value> <value xml:lang="en">An error occurs during reading</value> Modified: ofbiz/branches/jackrabbit20100709/framework/common/widget/CommonScreens.xml URL: http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/framework/common/widget/CommonScreens.xml?rev=1213245&r1=1213244&r2=1213245&view=diff ============================================================================== --- ofbiz/branches/jackrabbit20100709/framework/common/widget/CommonScreens.xml (original) +++ ofbiz/branches/jackrabbit20100709/framework/common/widget/CommonScreens.xml Mon Dec 12 13:53:03 2011 @@ -104,102 +104,145 @@ under the License. </section> </screen> - <!-- Global decorator for General Screens/Pages --> - <screen name="GlobalDecorator"> + <!-- Global screen rendering context initialization, intended to be included in screen decorators. Devs - please keep this simple and generic. --> + <screen name="GlobalActions"> <section> <actions> <!-- The default (global) java scripts --> - <!-- jQuery part --> + <!-- jQuery part --> <!-- Load available JS Language Files --> - <set field="initialLocaleComplete" type="String" value="${groovy:parameters?.userLogin?.lastLocale}" default-value="${groovy:locale.toString()}"/> - <set field="layoutSettings.javaScripts[+0]" value="${groovy: org.ofbiz.common.JsLanguageFilesMapping.datejs.getFilePath(initialLocaleComplete)}" global="true"/> - <set field="layoutSettings.javaScripts[+0]" value="${groovy: org.ofbiz.common.JsLanguageFilesMapping.jquery.getFilePath(initialLocaleComplete)}" global="true"/> - <set field="layoutSettings.javaScripts[+0]" value="${groovy: org.ofbiz.common.JsLanguageFilesMapping.validation.getFilePath(initialLocaleComplete)}" global="true"/> - <set field="layoutSettings.javaScripts[+0]" value="${groovy: org.ofbiz.common.JsLanguageFilesMapping.dateTime.getFilePath(initialLocaleComplete)}" global="true"/> - - <set field="layoutSettings.javaScripts[+0]" value="/images/jquery/plugins/asmselect/jquery.asmselect-1.0.4a-beta.js" global="true"/> - <set field="layoutSettings.javaScripts[+0]" value="/images/jquery/plugins/datetimepicker/jquery-ui-timepicker-addon-0.9.7.js" global="true"/> - <set field="layoutSettings.javaScripts[+0]" value="/images/jquery/plugins/jquery.maskedinput-1.2.2.min.js" global="true"/> - <set field="layoutSettings.javaScripts[+0]" value="/images/jquery/ui/js/jquery-ui-1.8.16.custom.min.js" global="true"/> - <set field="layoutSettings.javaScripts[+0]" value="/images/jquery/plugins/jeditable/jquery.jeditable.js" global="true"/> - <set field="layoutSettings.javaScripts[+0]" value="/images/jquery/plugins/validate/jquery.validate.min.js" global="true"/> - <set field="layoutSettings.javaScripts[+0]" value="/images/jquery/plugins/fjTimer/jquerytimer-min.js" global="true"/> - <set field="layoutSettings.javaScripts[+0]" value="/images/jquery/ui/development-bundle/ui/jquery.ui.datepicker.js" global="true"/> - - - <set field="layoutSettings.javaScripts[+0]" value="/images/jquery/jquery-1.7.min.js" global="true"/> - <!-- jQuery CSSs --> - <set field="layoutSettings.styleSheets[+0]" value="/images/jquery/plugins/asmselect/jquery.asmselect-1.0.4a-beta.css" global="true"/> - <set field="layoutSettings.styleSheets[+0]" value="/images/jquery/plugins/datetimepicker/jquery-ui-timepicker-addon-0.9.6.css" global="true"/> - - <set field="layoutSettings.javaScripts[]" value="/images/selectall.js" global="true"/> - <set field="layoutSettings.javaScripts[]" value="/images/fieldlookup.js" global="true"/> - <set field="layoutSettings.javaScripts[]" value="/images/GooglemapMarkers.js" global="true"/> - <set field="layoutSettings.javaScripts[]" value="/images/getDependentDropdownValues.js" global="true"/> - <set field="layoutSettings.javaScripts[]" value="/images/selectMultipleRelatedValues.js" global="true"/> - - <set field="layoutSettings.commonHeaderImageLinkUrl" from-field="layoutSettings.commonHeaderImageLinkUrl" default-value="main" global="true"/> - <set field="visualThemeId" from-field="userPreferences.VISUAL_THEME" global="true"/> + <set field="initialLocaleComplete" type="String" value="${groovy:parameters?.userLogin?.lastLocale}" default-value="${groovy:locale.toString()}" /> + <set field="layoutSettings.javaScripts[+0]" value="${groovy: org.ofbiz.common.JsLanguageFilesMapping.datejs.getFilePath(initialLocaleComplete)}" global="true" /> + <set field="layoutSettings.javaScripts[+0]" value="${groovy: org.ofbiz.common.JsLanguageFilesMapping.jquery.getFilePath(initialLocaleComplete)}" global="true" /> + <set field="layoutSettings.javaScripts[+0]" value="${groovy: org.ofbiz.common.JsLanguageFilesMapping.validation.getFilePath(initialLocaleComplete)}" global="true" /> + <set field="layoutSettings.javaScripts[+0]" value="${groovy: org.ofbiz.common.JsLanguageFilesMapping.dateTime.getFilePath(initialLocaleComplete)}" global="true" /> + <set field="layoutSettings.javaScripts[+0]" value="/images/jquery/plugins/asmselect/jquery.asmselect-1.0.4a-beta.js" global="true" /> + <set field="layoutSettings.javaScripts[+0]" value="/images/jquery/plugins/datetimepicker/jquery-ui-timepicker-addon-0.9.7.js" global="true" /> + <set field="layoutSettings.javaScripts[+0]" value="/images/jquery/plugins/jquery.maskedinput-1.2.2.min.js" global="true" /> + <set field="layoutSettings.javaScripts[+0]" value="/images/jquery/ui/js/jquery-ui-1.8.16.custom.min.js" global="true" /> + <set field="layoutSettings.javaScripts[+0]" value="/images/jquery/plugins/jeditable/jquery.jeditable.js" global="true" /> + <set field="layoutSettings.javaScripts[+0]" value="/images/jquery/plugins/validate/jquery.validate.min.js" global="true" /> + <set field="layoutSettings.javaScripts[+0]" value="/images/jquery/plugins/fjTimer/jquerytimer-min.js" global="true" /> + <set field="layoutSettings.javaScripts[+0]" value="/images/jquery/ui/development-bundle/ui/jquery.ui.datepicker.js" global="true" /> + <set field="layoutSettings.javaScripts[+0]" value="/images/jquery/jquery-1.7.min.js" global="true" /> + <!-- jQuery CSSs --> + <set field="layoutSettings.styleSheets[+0]" value="/images/jquery/plugins/asmselect/jquery.asmselect-1.0.4a-beta.css" global="true" /> + <set field="layoutSettings.styleSheets[+0]" value="/images/jquery/plugins/datetimepicker/jquery-ui-timepicker-addon-0.9.6.css" global="true" /> + <set field="layoutSettings.javaScripts[]" value="/images/selectall.js" global="true" /> + <set field="layoutSettings.javaScripts[]" value="/images/fieldlookup.js" global="true" /> + <set field="layoutSettings.javaScripts[]" value="/images/GooglemapMarkers.js" global="true" /> + <set field="layoutSettings.javaScripts[]" value="/images/getDependentDropdownValues.js" global="true" /> + <set field="layoutSettings.javaScripts[]" value="/images/selectMultipleRelatedValues.js" global="true" /> + <set field="visualThemeId" from-field="userPreferences.VISUAL_THEME" global="true" /> <service service-name="getVisualThemeResources"> - <field-map field-name="visualThemeId"/> - <field-map field-name="themeResources" from-field="layoutSettings"/> + <field-map field-name="visualThemeId" /> + <field-map field-name="themeResources" from-field="layoutSettings" /> </service> - <set field="layoutSettings" from-field="themeResources" default-value="${layoutSettings}" global="true"/> - <set field="iconsLocation" from-field="layoutSettings.VT_ICONS_LOC[0]" default-value="/images/icons/famfamfam" global="true"/> - <set field="headerTemplateLocation" from-field="layoutSettings.VT_HDR_TMPLT_LOC[0]"/> - <set field="footerTemplateLocation" from-field="layoutSettings.VT_FTR_TMPLT_LOC[0]"/> - <set field="appbarTemplateLocation" from-field="layoutSettings.VT_NAV_TMPLT_LOC[0]"/> - <set field="appbarOpenTemplateLocation" from-field="layoutSettings.VT_NAV_OPEN_TMPLT[0]"/> - <set field="appbarCloseTemplateLocation" from-field="layoutSettings.VT_NAV_CLOSE_TMPLT[0]"/> - <set field="messagesTemplateLocation" from-field="layoutSettings.VT_MSG_TMPLT_LOC[0]"/> + <set field="layoutSettings" from-field="themeResources" default-value="${layoutSettings}" global="true" /> </actions> + <widgets /> + </section> + </screen> + + <!-- Global decorator for General Screens/Pages --> + <screen name="GlobalDecorator"> + <section> <widgets> + <include-screen name="GlobalActions" /> + <section> + <actions> + <set field="layoutSettings.commonHeaderImageLinkUrl" from-field="layoutSettings.commonHeaderImageLinkUrl" default-value="main" global="true" /> + <set field="iconsLocation" from-field="layoutSettings.VT_ICONS_LOC[0]" default-value="/images/icons/famfamfam" global="true" /> + <set field="headerTemplateLocation" from-field="layoutSettings.VT_HDR_TMPLT_LOC[0]" /> + <set field="footerTemplateLocation" from-field="layoutSettings.VT_FTR_TMPLT_LOC[0]" /> + <set field="appbarTemplateLocation" from-field="layoutSettings.VT_NAV_TMPLT_LOC[0]" /> + <set field="appbarOpenTemplateLocation" from-field="layoutSettings.VT_NAV_OPEN_TMPLT[0]" /> + <set field="appbarCloseTemplateLocation" from-field="layoutSettings.VT_NAV_CLOSE_TMPLT[0]" /> + <set field="messagesTemplateLocation" from-field="layoutSettings.VT_MSG_TMPLT_LOC[0]" /> + </actions> + <widgets /> + </section> <section> <condition> - <if-empty field="parameters.ajaxUpdateEvent"/> + <if-empty field="parameters.ajaxUpdateEvent" /> </condition> <widgets> <!-- render header --> - <platform-specific><html><html-template location="${headerTemplateLocation}"/></html></platform-specific> + <platform-specific> + <html> + <html-template location="${headerTemplateLocation}" /> + </html> + </platform-specific> <!-- render appbar or its opening part --> <section name="Render-Main-Nav"> <condition> - <not><if-empty field="appbarOpenTemplateLocation"/></not> + <not> + <if-empty field="appbarOpenTemplateLocation" /> + </not> </condition> <widgets> - <platform-specific><html><html-template location="${appbarOpenTemplateLocation}"/></html></platform-specific> + <platform-specific> + <html> + <html-template location="${appbarOpenTemplateLocation}" /> + </html> + </platform-specific> </widgets> <fail-widgets> - <platform-specific><html><html-template location="${appbarTemplateLocation}"/></html></platform-specific> + <platform-specific> + <html> + <html-template location="${appbarTemplateLocation}" /> + </html> + </platform-specific> </fail-widgets> </section> </widgets> </section> - <section> <condition> - <if-empty field="parameters.ajaxUpdateEvent"/> + <if-empty field="parameters.ajaxUpdateEvent" /> </condition> <widgets> <!-- render appheader: both menu widget style and ftl template style menus are supported--> <section name="Render-App-Nav"> <condition> - <not><if-empty field="userLogin"/></not> + <not> + <if-empty field="userLogin" /> + </not> </condition> <widgets> <section> - <condition><not><if-empty field="appheaderTemplate"/></not></condition> + <condition> + <not> + <if-empty field="appheaderTemplate" /> + </not> + </condition> <widgets> - <platform-specific><html><html-template location="${appheaderTemplate}"/></html></platform-specific> + <platform-specific> + <html> + <html-template location="${appheaderTemplate}" /> + </html> + </platform-specific> </widgets> <fail-widgets> <section> - <condition><not><if-empty field="parameters.applicationTitle"/></not></condition> - <widgets><label style="apptitle">${parameters.applicationTitle}</label></widgets> + <condition> + <not> + <if-empty field="parameters.applicationTitle" /> + </not> + </condition> + <widgets> + <label style="apptitle">${parameters.applicationTitle}</label> + </widgets> </section> <section> - <condition><not><if-empty field="applicationMenuLocation"/></not></condition> - <widgets><include-menu name="${applicationMenuName}" location="${applicationMenuLocation}"/></widgets> + <condition> + <not> + <if-empty field="applicationMenuLocation" /> + </not> + </condition> + <widgets> + <include-menu name="${applicationMenuName}" location="${applicationMenuLocation}" /> + </widgets> </section> </fail-widgets> </section> @@ -210,43 +253,50 @@ under the License. </section> </widgets> </section> - <!-- render the appbar closing part --> <section> <condition> <and> - <if-empty field="parameters.ajaxUpdateEvent"/> - <not><if-empty field="appbarCloseTemplateLocation"/></not> + <if-empty field="parameters.ajaxUpdateEvent" /> + <not> + <if-empty field="appbarCloseTemplateLocation" /> + </not> </and> </condition> <widgets> - <platform-specific><html><html-template location="${appbarCloseTemplateLocation}"/></html></platform-specific> + <platform-specific> + <html> + <html-template location="${appbarCloseTemplateLocation}" /> + </html> + </platform-specific> </widgets> </section> - <!-- render messages --> - <platform-specific><html><html-template location="${messagesTemplateLocation}"/></html></platform-specific> - + <platform-specific> + <html> + <html-template location="${messagesTemplateLocation}" /> + </html> + </platform-specific> <!-- render content area --> <container style="contentarea"> - <decorator-section-include name="pre-body"/> + <decorator-section-include name="pre-body" /> <container id="column-container"> <section> <condition> - <if-empty-section section-name="left-column"/> + <if-empty-section section-name="left-column" /> </condition> <widgets> <container id="content-main-section"> - <decorator-section-include name="body"/> + <decorator-section-include name="body" /> </container> </widgets> <fail-widgets> <container style="left"> - <decorator-section-include name="left-column"/> + <decorator-section-include name="left-column" /> </container> <container id="content-main-section" style="leftonly"> <container style="no-clear" id="centerdiv"> - <decorator-section-include name="body"/> + <decorator-section-include name="body" /> </container> </container> </fail-widgets> @@ -254,22 +304,29 @@ under the License. <container style="clear"></container> </container> </container> - <section> <condition> - <if-empty field="parameters.ajaxUpdateEvent"/> + <if-empty field="parameters.ajaxUpdateEvent" /> </condition> <widgets> <!-- render footer --> <section name="Render-Footer"> <condition> - <if-empty field="applicationFooterTemplate"/> + <if-empty field="applicationFooterTemplate" /> </condition> <widgets> - <platform-specific><html><html-template location="${footerTemplateLocation}"/></html></platform-specific> + <platform-specific> + <html> + <html-template location="${footerTemplateLocation}" /> + </html> + </platform-specific> </widgets> <fail-widgets> - <platform-specific><html><html-template location="${applicationFooterTemplate}"/></html></platform-specific> + <platform-specific> + <html> + <html-template location="${applicationFooterTemplate}" /> + </html> + </platform-specific> </fail-widgets> </section> </widgets> Modified: ofbiz/branches/jackrabbit20100709/framework/images/webapp/images/fieldlookup.js URL: http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/framework/images/webapp/images/fieldlookup.js?rev=1213245&r1=1213244&r2=1213245&view=diff ============================================================================== --- ofbiz/branches/jackrabbit20100709/framework/images/webapp/images/fieldlookup.js (original) +++ ofbiz/branches/jackrabbit20100709/framework/images/webapp/images/fieldlookup.js Mon Dec 12 13:53:03 2011 @@ -255,7 +255,7 @@ function ConstructLookup(requestUrl, inp var requestUrlAndArgs = requestUrl; if (typeof args == "object" && jQuery.isArray(args)) { for (var i = 0; i < args.length; i++) { - requestUrlAndArgs += "&parm" + (i+1) + "=" + jQuery(args[i]).val(); + requestUrlAndArgs += "&parm" + i + "=" + jQuery(args[i]).val(); } } jQuery("#" + lookupId).load(requestUrlAndArgs, function(data){ @@ -286,6 +286,8 @@ function ConstructLookup(requestUrl, inp } if (prevLookup) { identifyLookup(prevLookup); + } else { + ACTIVATED_LOOKUP = null; } } Modified: ofbiz/branches/jackrabbit20100709/framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java URL: http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java?rev=1213245&r1=1213244&r2=1213245&view=diff ============================================================================== --- ofbiz/branches/jackrabbit20100709/framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java (original) +++ ofbiz/branches/jackrabbit20100709/framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java Mon Dec 12 13:53:03 2011 @@ -249,7 +249,7 @@ public class ContextFilter implements Fi // check to make sure the requested url is allowed if (!allowList.contains(requestPath) && !allowList.contains(requestInfo) && !allowList.contains(httpRequest.getServletPath())) { String filterMessage = "[Filtered request]: " + contextUri; - + if (redirectPath == null) { int error = 404; if (UtilValidate.isNotEmpty(errorCode)) { @@ -261,6 +261,7 @@ public class ContextFilter implements Fi } filterMessage = filterMessage + " (" + error + ")"; httpResponse.sendError(error, contextUri); + request.setAttribute("filterRequestUriError", contextUri); } else { filterMessage = filterMessage + " (" + redirectPath + ")"; if (!redirectPath.toLowerCase().startsWith("http")) { Modified: ofbiz/branches/jackrabbit20100709/framework/webapp/src/org/ofbiz/webapp/ftl/OfbizUrlTransform.java URL: http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/framework/webapp/src/org/ofbiz/webapp/ftl/OfbizUrlTransform.java?rev=1213245&r1=1213244&r2=1213245&view=diff ============================================================================== --- ofbiz/branches/jackrabbit20100709/framework/webapp/src/org/ofbiz/webapp/ftl/OfbizUrlTransform.java (original) +++ ofbiz/branches/jackrabbit20100709/framework/webapp/src/org/ofbiz/webapp/ftl/OfbizUrlTransform.java Mon Dec 12 13:53:03 2011 @@ -18,15 +18,34 @@ *******************************************************************************/ package org.ofbiz.webapp.ftl; +import java.io.File; +import java.io.FileInputStream; import java.io.IOException; +import java.io.InputStream; import java.io.Writer; import java.util.Map; import javax.servlet.ServletContext; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import javax.xml.parsers.ParserConfigurationException; +import org.ofbiz.base.component.ComponentConfig; +import org.ofbiz.base.component.ComponentConfig.WebappInfo; +import org.ofbiz.base.util.Debug; +import org.ofbiz.base.util.UtilMisc; +import org.ofbiz.base.util.UtilProperties; +import org.ofbiz.base.util.UtilValidate; +import org.ofbiz.base.util.UtilXml; +import org.ofbiz.entity.Delegator; +import org.ofbiz.entity.GenericEntityException; +import org.ofbiz.entity.GenericValue; import org.ofbiz.webapp.control.RequestHandler; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.xml.sax.SAXException; import freemarker.core.Environment; import freemarker.ext.beans.BeanModel; @@ -62,6 +81,7 @@ public class OfbizUrlTransform implement final boolean fullPath = checkArg(args, "fullPath", false); final boolean secure = checkArg(args, "secure", false); final boolean encode = checkArg(args, "encode", true); + final String webSiteId = getArg(args, "webSiteId"); return new Writer(out) { @Override @@ -81,7 +101,109 @@ public class OfbizUrlTransform implement BeanModel req = (BeanModel) env.getVariable("request"); BeanModel res = (BeanModel) env.getVariable("response"); Object prefix = env.getVariable("urlPrefix"); - if (req != null) { + if (UtilValidate.isNotEmpty(webSiteId)) { + HttpServletRequest request = (HttpServletRequest) req.getWrappedObject(); + Delegator delegator = (Delegator) request.getAttribute("delegator"); + String httpsPort = null; + String httpsServer = null; + String httpPort = null; + String httpServer = null; + Boolean enableHttps = null; + StringBuilder newURL = new StringBuilder(); + // make prefix url + try { + GenericValue webSite = delegator.findByPrimaryKeyCache("WebSite", UtilMisc.toMap("webSiteId", webSiteId)); + if (webSite != null) { + httpsPort = webSite.getString("httpsPort"); + httpsServer = webSite.getString("httpsHost"); + httpPort = webSite.getString("httpPort"); + httpServer = webSite.getString("httpHost"); + enableHttps = webSite.getBoolean("enableHttps"); + } + } catch (GenericEntityException e) { + Debug.logWarning(e, "Problems with WebSite entity; using global defaults", module); + } + // fill in any missing properties with fields from the global file + if (UtilValidate.isEmpty(httpsPort)) { + httpsPort = UtilProperties.getPropertyValue("url.properties", "port.https", "443"); + } + if (UtilValidate.isEmpty(httpsServer)) { + httpsServer = UtilProperties.getPropertyValue("url.properties", "force.https.host"); + } + if (UtilValidate.isEmpty(httpPort)) { + httpPort = UtilProperties.getPropertyValue("url.properties", "port.http", "80"); + } + if (UtilValidate.isEmpty(httpServer)) { + httpServer = UtilProperties.getPropertyValue("url.properties", "force.http.host"); + } + if (enableHttps == null) { + enableHttps = UtilProperties.propertyValueEqualsIgnoreCase("url.properties", "port.https.enabled", "Y"); + } + if (secure && enableHttps) { + String server = httpsServer; + if (UtilValidate.isEmpty(server)) { + server = request.getServerName(); + } + newURL.append("https://"); + newURL.append(httpsServer); + newURL.append(":").append(httpsPort); + } else { + newURL.append("http://"); + newURL.append(httpServer); + if (!"80".equals(httpPort)) { + newURL.append(":").append(httpPort); + } + } + // make mount point + String mountPoint = null; + for (WebappInfo webAppInfo : ComponentConfig.getAllWebappResourceInfos()) { + File file = new File(webAppInfo.getLocation() + "/WEB-INF/web.xml"); + if (!file.exists()) { + continue; + } + InputStream is = new FileInputStream(file); + try { + Document doc = UtilXml.readXmlDocument(is, true, null); + NodeList nList = doc.getElementsByTagName("context-param"); + for (int temp = 0; temp < nList.getLength(); temp++) { + Node nNode = nList.item(temp); + if (nNode.getNodeType() == Node.ELEMENT_NODE) { + Element eElement = (Element) nNode; + String paramName = getTagValue("param-name",eElement); + String paramValue = getTagValue("param-value",eElement); + if ("webSiteId".equals(paramName) && webSiteId.equals(paramValue)) { + mountPoint = webAppInfo.getContextRoot(); + break; + } + } + } + } catch (SAXException e) { + Debug.logWarning(e, e.getMessage(), module); + } catch (ParserConfigurationException e) { + Debug.logWarning(e, e.getMessage(), module); + } + if (UtilValidate.isNotEmpty(mountPoint)) { + if (mountPoint.length() > 1) newURL.append(mountPoint); + break; + } + } + // make the path the the control servlet + String controlPath = (String) request.getAttribute("_CONTROL_PATH_"); + String[] patch = controlPath.split("/"); + String patchStr = null; + if (patch.length > 0) { + patchStr = patch[patch.length-1]; + } + if (UtilValidate.isNotEmpty(patchStr)) { + newURL.append("/"); + newURL.append(patchStr); + } + newURL.append("/"); + // make requestUrl + String requestUrl = buf.toString(); + newURL.append(requestUrl); + out.write(newURL.toString()); + } else if (req != null) { HttpServletRequest request = (HttpServletRequest) req.getWrappedObject(); ServletContext ctx = (ServletContext) request.getAttribute("servletContext"); HttpServletResponse response = null; @@ -117,4 +239,32 @@ public class OfbizUrlTransform implement } }; } + private static String getArg(Map args, String key) { + String result = ""; + Object o = args.get(key); + if (o != null) { + if (Debug.verboseOn()) Debug.logVerbose("Arg Object : " + o.getClass().getName(), module); + if (o instanceof TemplateScalarModel) { + TemplateScalarModel s = (TemplateScalarModel) o; + try { + result = s.getAsString(); + } catch (TemplateModelException e) { + Debug.logError(e, "Template Exception", module); + } + } else { + result = o.toString(); + } + } + return result; + } + private static String getTagValue(String sTag, Element eElement){ + String value = ""; + try{ + NodeList nlList= eElement.getElementsByTagName(sTag).item(0).getChildNodes(); + Node nValue = (Node) nlList.item(0); + return value = nValue.getNodeValue(); + } catch (Exception e) { + return value; + } + } } |
Free forum by Nabble | Edit this page |