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/07/19 06:04:33 UTC
svn commit: r1148144 - in /ofbiz/trunk/applications/content:
script/org/ofbiz/content/content/ContentServices.xml
servicedef/services.xml src/org/ofbiz/content/content/ContentUrlFilter.java
Author: hansbak
Date: Tue Jul 19 04:04:32 2011
New Revision: 1148144
URL: http://svn.apache.org/viewvc?rev=1148144&view=rev
Log:
improved content friendly urls, fix some errors
Modified:
ofbiz/trunk/applications/content/script/org/ofbiz/content/content/ContentServices.xml
ofbiz/trunk/applications/content/servicedef/services.xml
ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentUrlFilter.java
Modified: ofbiz/trunk/applications/content/script/org/ofbiz/content/content/ContentServices.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/script/org/ofbiz/content/content/ContentServices.xml?rev=1148144&r1=1148143&r2=1148144&view=diff
==============================================================================
--- ofbiz/trunk/applications/content/script/org/ofbiz/content/content/ContentServices.xml (original)
+++ ofbiz/trunk/applications/content/script/org/ofbiz/content/content/ContentServices.xml Tue Jul 19 04:04:32 2011
@@ -1280,25 +1280,43 @@
<simple-method method-name="createContentAlternativeUrl" short-description="Create Content Alternative URLs.">
<set field="defaultLocaleString" from-field="parameters.locale" default-value="en"/>
<set field="contents" type="List"/>
- <if-empty field="parameters.contentId">
- <entity-condition list="contents" entity-name="Content">
- <condition-expr field-name="contentName" operator="not-equals" from-field="nullField"/>
- <select-field field-name="contentId"/>
- <select-field field-name="contentName"/>
- <select-field field-name="localeString"/>
- </entity-condition>
+ <if>
+ <condition>
+ <or>
+ <if-empty field="parameters.contentId"/>
+ <if-compare operator="equals" value="null" field="parameters.contentId"></if-compare>
+ </or>
+ </condition>
+ <then>
+ <entity-condition list="contents" entity-name="Content">
+ <condition-list combine="and">
+ <condition-expr field-name="contentName" operator="not-equals" from-field="nullField"/>
+ <condition-list combine="or">
+ <condition-expr field-name="contentTypeId" operator="equals" value="DOCUMENT"/>
+ <condition-expr field-name="contentTypeId" operator="equals" value="WEB_SITE_PUB_PT"/>
+ </condition-list>
+ </condition-list>
+ <select-field field-name="contentId"/>
+ <select-field field-name="contentName"/>
+ <select-field field-name="localeString"/>
+ </entity-condition>
+ </then>
<else>
<entity-condition list="contents" entity-name="Content">
<condition-list combine="and">
<condition-expr field-name="contentName" operator="not-equals" from-field="nullField"/>
<condition-expr field-name="contentId" operator="equals" from-field="parameters.contentId"/>
+ <condition-list combine="or">
+ <condition-expr field-name="contentTypeId" operator="equals" value="DOCUMENT"/>
+ <condition-expr field-name="contentTypeId" operator="equals" value="WEB_SITE_PUB_PT"/>
+ </condition-list>
</condition-list>
<select-field field-name="contentId"/>
<select-field field-name="contentName"/>
<select-field field-name="localeString"/>
</entity-condition>
</else>
- </if-empty>
+ </if>
<iterate entry="content" list="contents">
<set field="localeString" from-field="content.localeString" default-value="${defaultLocaleString}"/>
<entity-condition list="contentAssocDataResources" entity-name="ContentAssocDataResourceViewTo">
@@ -1315,39 +1333,21 @@
</entity-condition>
<filter-list-by-date list="contentAssocDataResources" from-field-name="caFromDate" thru-field-name="caThruDate"/>
<if-empty field="contentAssocDataResources">
- <set field="altUrl"/>
<if-not-empty field="content.contentName">
- <call-class-method method-name="invalidCharacter" class-name="org.ofbiz.common.UrlServletHelper" ret-field="altUrl">
- <field field="content.contentName"/>
- </call-class-method>
+ <set field="createSimpleTextContentContext.localeString" from-field="localeString"/>
+ <set field="createSimpleTextContentContext.text" from-field="content.contentName"/>
+ <call-service service-name="createSimpleTextContent" in-map-name="createSimpleTextContentContext" include-user-login="true" break-on-error="false">
+ <result-to-field result-name="contentId" field="contentIdTo"/>
+ </call-service>
+ <if-not-empty field="contentIdTo">
+ <set field="createContentAssocCtx.contentId" from-field="content.contentId"/>
+ <set field="createContentAssocCtx.contentIdTo" from-field="contentIdTo"/>
+ <set field="createContentAssocCtx.contentAssocTypeId" value="ALTERNATIVE_URL"/>
+ <call-service service-name="createContentAssoc" in-map-name="createContentAssocCtx" include-user-login="true" break-on-error="false"/>
+ </if-not-empty>
</if-not-empty>
- <set field="altUrl" value="/${altUrl}-${content.contentId}-content"/>
- <sequenced-id sequence-name="DataResource" field="createDataResourceCtx.dataResourceId"/>
- <set field="createDataResourceCtx.dataResourceTypeId" value="ELECTRONIC_TEXT"/>
- <set field="createDataResourceCtx.dataTemplateTypeId" value="FTL"/>
- <set field="createDataResourceCtx.localeString" from-field="localeString"/>
- <set field="createDataResourceCtx.objectInfo" from-field="altUrl"/>
- <set field="createDataResourceCtx.statusId" value="CTNT_IN_PROGRESS"/>
- <call-service service-name="createDataResource" in-map-name="createDataResourceCtx" include-user-login="true">
- <result-to-field result-name="dataResourceId" field="dataResourceId"/>
- </call-service>
- <set field="electronicTextCtx.dataResourceId" from-field="dataResourceId"/>
- <set field="electronicTextCtx.textData" from-field="content.contentName"/>
- <call-service service-name="createElectronicText" in-map-name="electronicTextCtx" include-user-login="true"></call-service>
-
- <sequenced-id sequence-name="Content" field="contentCtx.contentId"/>
- <set field="contentCtx.contentTypeId" value="DOCUMENT"/>
- <set field="contentCtx.dataResourceId" from-field="dataResourceId"/>
- <set field="contentCtx.localeString" from-field="localeString"/>
- <call-service service-name="createContent" in-map-name="contentCtx" include-user-login="true">
- <result-to-field result-name="contentId" field="contentIdTo"/>
- </call-service>
-
- <set field="createContentAssocCtx.contentId" from-field="content.contentId"/>
- <set field="createContentAssocCtx.contentIdTo" from-field="contentIdTo"/>
- <set field="createContentAssocCtx.contentAssocTypeId" value="ALTERNATIVE_URL"/>
- <call-service service-name="createContentAssoc" in-map-name="createContentAssocCtx" include-user-login="true"/>
</if-empty>
</iterate>
</simple-method>
</simple-methods>
+
Modified: ofbiz/trunk/applications/content/servicedef/services.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/servicedef/services.xml?rev=1148144&r1=1148143&r2=1148144&view=diff
==============================================================================
--- ofbiz/trunk/applications/content/servicedef/services.xml (original)
+++ ofbiz/trunk/applications/content/servicedef/services.xml Tue Jul 19 04:04:32 2011
@@ -1199,7 +1199,7 @@
</service>
<service name="createContentAlternativeUrl" engine="simple"
- location="component://content/script/org/ofbiz/content/content/ContentServices.xml" invoke="createContentAlternativeUrl" auth="true">
+ location="component://content/script/org/ofbiz/content/content/ContentServices.xml" invoke="createContentAlternativeUrl" auth="true" transaction-timeout="7200">
<description>Create Content Alternative URL</description>
<attribute name="contentId" mode="IN" type="String" optional="true"></attribute>
</service>
Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentUrlFilter.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentUrlFilter.java?rev=1148144&r1=1148143&r2=1148144&view=diff
==============================================================================
--- ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentUrlFilter.java (original)
+++ ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentUrlFilter.java Tue Jul 19 04:04:32 2011
@@ -20,6 +20,7 @@
package org.ofbiz.content.content;
import java.io.IOException;
+import java.util.Iterator;
import java.util.List;
import java.util.Set;
@@ -34,17 +35,17 @@ import javax.servlet.http.HttpServletRes
import javolution.util.FastList;
-import org.ofbiz.base.util.StringUtil;
import org.ofbiz.base.util.Debug;
+import org.ofbiz.base.util.UtilHttp;
import org.ofbiz.base.util.UtilMisc;
import org.ofbiz.base.util.UtilValidate;
+import org.ofbiz.common.UrlServletHelper;
import org.ofbiz.entity.Delegator;
import org.ofbiz.entity.GenericValue;
import org.ofbiz.entity.condition.EntityCondition;
import org.ofbiz.entity.condition.EntityOperator;
import org.ofbiz.entity.util.EntityUtil;
import org.ofbiz.webapp.control.ContextFilter;
-import org.ofbiz.common.UrlServletHelper;
public class ContentUrlFilter extends ContextFilter {
public final static String module = ContentUrlFilter.class.getName();
@@ -61,15 +62,13 @@ public class ContentUrlFilter extends Co
//Get ServletContext
ServletContext servletContext = config.getServletContext();
-
//Set request attribute and session
UrlServletHelper.setRequestAttributes(request, delegator, servletContext);
String urlContentId = null;
- String pathInfo = httpRequest.getServletPath();
+ StringBuffer pathInfoBuffer = UtilHttp.getFullRequestUrl(httpRequest);
+ String pathInfo = pathInfoBuffer.toString();
if (UtilValidate.isNotEmpty(pathInfo)) {
- List<String> paths = StringUtil.split(pathInfo, "/");
- String alternativeUrl = paths.get(0);
-
+ String alternativeUrl = pathInfo.substring(pathInfo.lastIndexOf("/") + 1);
if (alternativeUrl.endsWith("-content")) {
try {
List<EntityCondition> expr = FastList.newInstance();
@@ -77,7 +76,9 @@ public class ContentUrlFilter extends Co
expr.add(EntityCondition.makeCondition("caThruDate", EntityOperator.EQUALS, null));
Set<String> fieldsToSelect = UtilMisc.toSet("contentIdStart", "dataResourceId", "caFromDate", "caThruDate", "caCreatedDate");
List<GenericValue> contentAssocDataResources = delegator.findList("ContentAssocDataResourceViewTo", EntityCondition.makeCondition(expr), fieldsToSelect, UtilMisc.toList("-caCreatedDate"), null, true);
- for (GenericValue contentAssocDateResource : contentAssocDataResources) {
+ Iterator<GenericValue> contentAssocDateResourceIter = contentAssocDataResources.iterator();
+ while (contentAssocDateResourceIter.hasNext()) {
+ GenericValue contentAssocDateResource = contentAssocDateResourceIter.next();
GenericValue electronicText = delegator.findByPrimaryKey("ElectronicText", UtilMisc.toMap("dataResourceId", contentAssocDateResource.getString("dataResourceId")));
if (UtilValidate.isEmpty(electronicText) || UtilValidate.isEmpty(electronicText.get("textData"))) {
continue;
@@ -88,7 +89,7 @@ public class ContentUrlFilter extends Co
}
}
} catch (Exception e) {
-
+ Debug.logWarning(e.getMessage(), module);
}
}
if (UtilValidate.isNotEmpty(urlContentId)) {
@@ -116,7 +117,6 @@ public class ContentUrlFilter extends Co
return null;
}
Delegator delegator = (Delegator) request.getAttribute("delegator");
-
String url = null;
try {
List<EntityCondition> expr = FastList.newInstance();