[OFBiz] SVN: r7102 - in trunk/applications/content: . entitydef script/org/ofbiz/content/content servicedef src/org/ofbiz/content/email
byersa@svn.ofbiz.org
byersa at svn.ofbiz.org
Wed Mar 29 02:29:14 CST 2006
Author: byersa
Date: 2006-03-29 02:29:05 -0600 (Wed, 29 Mar 2006)
New Revision: 7102
Added:
trunk/applications/content/script/org/ofbiz/content/content/CommEventContentServices.xml
trunk/applications/content/servicedef/services_commevent.xml
Modified:
trunk/applications/content/entitydef/entitygroup.xml
trunk/applications/content/entitydef/entitymodel.xml
trunk/applications/content/ofbiz-component.xml
trunk/applications/content/script/org/ofbiz/content/content/ContentServices.xml
trunk/applications/content/servicedef/services_email.xml
trunk/applications/content/src/org/ofbiz/content/email/EmailServices.java
Log:
Changes in support of CommunicationEvent Content attachment functionality.
Added CommEventContentAssoc entity and CommEventContentDataResource entities.
Added several services: createCommContentDataResource, updateCommContentDataResource, createCommEventContentAssoc, updateCommEventContentAssoc.
Modified: trunk/applications/content/entitydef/entitygroup.xml
===================================================================
--- trunk/applications/content/entitydef/entitygroup.xml 2006-03-29 08:06:45 UTC (rev 7101)
+++ trunk/applications/content/entitydef/entitygroup.xml 2006-03-29 08:29:05 UTC (rev 7102)
@@ -28,7 +28,8 @@
<!-- org.ofbiz.content.commevent -->
<!-- ========================================================= -->
- <entity-group group="org.ofbiz" entity="CommEventContentAssoc" />
+ <entity-group group="org.ofbiz" entity="CommEventContentAssoc" />
+ <entity-group group="org.ofbiz" entity="CommEventContentDataResource" />
<!-- ========================================================= -->
<!-- org.ofbiz.content.content -->
Modified: trunk/applications/content/entitydef/entitymodel.xml
===================================================================
--- trunk/applications/content/entitydef/entitymodel.xml 2006-03-29 08:06:45 UTC (rev 7101)
+++ trunk/applications/content/entitydef/entitymodel.xml 2006-03-29 08:29:05 UTC (rev 7102)
@@ -410,6 +410,52 @@
<key-map field-name="contentId"/>
</relation>
</view-entity>
+ <view-entity entity-name="CommEventContentDataResource"
+ package-name="org.ofbiz.content.content"
+ title="CommEvent and Content and DataResource">
+ <member-entity entity-alias="CECA" entity-name="CommEventContentAssoc"/>
+ <member-entity entity-alias="CO" entity-name="Content"/>
+ <member-entity entity-alias="DR" entity-name="DataResource"/>
+ <alias-all entity-alias="CECA" />
+ <alias-all entity-alias="CO" />
+ <alias-all entity-alias="DR" prefix="dr"/>
+ <view-link entity-alias="CECA" rel-entity-alias="CO" rel-optional="false">
+ <key-map field-name="contentId"/>
+ </view-link>
+ <view-link entity-alias="CO" rel-entity-alias="DR" rel-optional="true">
+ <key-map field-name="dataResourceId"/>
+ </view-link>
+ <relation type="one-nofk" rel-entity-name="ElectronicText">
+ <key-map field-name="dataResourceId" />
+ </relation>
+ <relation type="one-nofk" rel-entity-name="CommunicationEvent">
+ <key-map field-name="communicationEventId" />
+ </relation>
+ <relation type="one-nofk" rel-entity-name="ImageDataResource">
+ <key-map field-name="dataResourceId" />
+ </relation>
+ <relation type="one-nofk" rel-entity-name="OtherDataResource">
+ <key-map field-name="dataResourceId" />
+ </relation>
+ <relation type="many" rel-entity-name="ContentAssocDataResourceViewFrom">
+ <key-map field-name="contentId" rel-field-name="contentIdStart" />
+ </relation>
+ <relation type="many" rel-entity-name="ContentAssocDataResourceViewTo">
+ <key-map field-name="contentId" rel-field-name="contentIdStart" />
+ </relation>
+ <relation type="many" title="From" rel-entity-name="ContentAssoc">
+ <key-map field-name="contentId"/>
+ </relation>
+ <relation type="many" title="To" rel-entity-name="ContentAssoc">
+ <key-map field-name="contentId" rel-field-name="contentIdTo"/>
+ </relation>
+ <relation type="many" rel-entity-name="ContentPurpose">
+ <key-map field-name="contentId"/>
+ </relation>
+ <relation type="many" rel-entity-name="ContentRole">
+ <key-map field-name="contentId"/>
+ </relation>
+ </view-entity>
<entity entity-name="ContentMetaData"
package-name="org.ofbiz.content.content"
title="Content Meta-Data Predicate Entity">
Modified: trunk/applications/content/ofbiz-component.xml
===================================================================
--- trunk/applications/content/ofbiz-component.xml 2006-03-29 08:06:45 UTC (rev 7101)
+++ trunk/applications/content/ofbiz-component.xml 2006-03-29 08:29:05 UTC (rev 7102)
@@ -48,6 +48,7 @@
<service-resource type="model" loader="main" location="servicedef/services_contenttypes.xml"/>
<service-resource type="model" loader="main" location="servicedef/services_email.xml"/>
<service-resource type="model" loader="main" location="servicedef/services_survey.xml"/>
+ <service-resource type="model" loader="main" location="servicedef/services_commevent.xml"/>
<service-resource type="eca" loader="main" location="servicedef/secas.xml"/>
<webapp name="content"
title="Content"
Added: trunk/applications/content/script/org/ofbiz/content/content/CommEventContentServices.xml
===================================================================
--- trunk/applications/content/script/org/ofbiz/content/content/CommEventContentServices.xml 2006-03-29 08:06:45 UTC (rev 7101)
+++ trunk/applications/content/script/org/ofbiz/content/content/CommEventContentServices.xml 2006-03-29 08:29:05 UTC (rev 7102)
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ * Copyright (c) 2001-2004 The Open For Business Project and repective authors.
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
+ * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * @author <a href="mailto:jonesde at ofbiz.org">David E. Jones</a>
+ * @version 1.0
+ * Created on April 2, 2002
+ -->
+
+<simple-methods xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:noNamespaceSchemaLocation="http://www.ofbiz.org/dtds/simple-methods.xsd">
+
+
+</simple-methods>
Modified: trunk/applications/content/script/org/ofbiz/content/content/ContentServices.xml
===================================================================
--- trunk/applications/content/script/org/ofbiz/content/content/ContentServices.xml 2006-03-29 08:06:45 UTC (rev 7101)
+++ trunk/applications/content/script/org/ofbiz/content/content/ContentServices.xml 2006-03-29 08:29:05 UTC (rev 7102)
@@ -733,5 +733,90 @@
<create-value value-name="content"/>
</simple-method>
+ <simple-method method-name="createCommContentDataResource" short-description="Create CommunicationEvent and Content">
+
+ <!--
+ <check-permission permission="CONTENTMGR" action="_DELETE"><fail-message message="Security Error: to run updateContent you must have the CONTENTMGR_DELETE or CONTENTMGR_ADMIN permission"/></check-permission>
+ <check-errors/>
+ -->
+ <set-service-fields to-map-name="persistIn" service-name="persistContentAndAssoc" map-name="parameters"/>
+ <call-service service-name="persistContentAndAssoc" in-map-name="persistIn">
+ <results-to-map map-name="persistOut"/>
+ </call-service>
+ <iterate-map key-name="key" value-name="val" map-name="persistOut">
+ <field-to-result field-name="val" result-name="${key}"/>
+ </iterate-map>
+
+ <set field="mapIn.contentId" from-field="persistOut.contentId"/>
+ <set field="mapIn.fromDate" from-field="parameters.fromDate"/>
+ <set field="mapIn.communicationEventId" from-field="parameters.communicationEventId"/>
+ <set field="mapIn.sequenceNum" from-field="parameters.sequenceNum"/>
+ <call-service service-name="createCommEventContentAssoc" in-map-name="mapIn">
+ <result-to-request result-name="fromDate"/>
+ </call-service>
+
+ </simple-method>
+
+ <simple-method method-name="updateCommContentDataResource" short-description="Update CommunicationEvent and Content">
+
+ <!--
+ <check-permission permission="CONTENTMGR" action="_DELETE"><fail-message message="Security Error: to run updateContent you must have the CONTENTMGR_DELETE or CONTENTMGR_ADMIN permission"/></check-permission>
+ <check-errors/>
+ -->
+ <set-service-fields to-map-name="persistIn" service-name="persistContentAndAssoc" map-name="parameters"/>
+ <call-service service-name="persistContentAndAssoc" in-map-name="persistIn">
+ <results-to-map map-name="persistOut"/>
+ </call-service>
+
+ <set field="mapIn.contentId" from-field="persistOut.contentId"/>
+ <set field="mapIn.fromDate" from-field="parameters.fromDate"/>
+ <set field="mapIn.communicationEventId" from-field="parameters.communicationEventId"/>
+ <set field="mapIn.sequenceNum" from-field="parameters.sequenceNum"/>
+ <call-service service-name="updateCommEventContentAssoc" in-map-name="mapIn">
+ </call-service>
+
+ <iterate-map key-name="key" value-name="val" map-name="persistOut">
+ <field-to-result field-name="val" result-name="${key}"/>
+ </iterate-map>
+
+ </simple-method>
+
+ <simple-method method-name="createCommEventContentAssoc" short-description="Create CommEventContentAssoc">
+ <make-value entity-name="CommEventContentAssoc" value-name="commEventContentAssoc" />
+ <set-pk-fields value-name="commEventContentAssoc" map-name="parameters"/>
+ <set-nonpk-fields value-name="commEventContentAssoc" map-name="parameters"/>
+ <if-empty field-name="commEventContentAssoc.fromDate">
+ <now-timestamp-to-env env-name="commEventContentAssoc.fromDate"/>
+ </if-empty>
+ <create-value value-name="commEventContentAssoc" />
+ <field-to-result field-name="commEventContentAssoc.fromDate" result-name="fromDate"/>
+ </simple-method>
+
+ <simple-method method-name="updateCommEventContentAssoc" short-description="Create CommEventContentAssoc">
+ <make-value entity-name="CommEventContentAssoc" value-name="pkCommEventContentAssoc" />
+ <set-pk-fields value-name="pkCommEventContentAssoc" map-name="parameters"/>
+ <find-by-primary-key value-name="commEventContentAssoc" map-name="pkCommEventContentAssoc" entity-name="CommEventContentAssoc"/>
+ <if-empty field-name="commEventContentAssoc">
+ <add-error>
+ <fail-message message="CommEventContentAssoc entity not found for update, communicationEventId: ${parameters.communicationEventId} and contentId: ${parameters.contentId}"/>
+ </add-error>
+ </if-empty>
+ <set-nonpk-fields value-name="commEventContentAssoc" map-name="parameters"/>
+ <store-value value-name="commEventContentAssoc" />
+ </simple-method>
+
+ <simple-method method-name="removeCommEventContentAssoc" short-description="Delete CommEventContentAssoc">
+ <make-value entity-name="CommEventContentAssoc" value-name="pkCommEventContentAssoc" />
+ <set-pk-fields value-name="pkCommEventContentAssoc" map-name="parameters"/>
+ <find-by-primary-key value-name="commEventContentAssoc" map-name="pkCommEventContentAssoc" entity-name="CommEventContentAssoc"/>
+ <if-empty field-name="commEventContentAssoc">
+ <add-error>
+ <fail-message message="CommEventContentAssoc entity not found for removal, communicationEventId: ${parameters.communicationEventId} and contentId: ${parameters.contentId}"/>
+ </add-error>
+ </if-empty>
+ <remove-value value-name="commEventContentAssoc" />
+ </simple-method>
+
+
</simple-methods>
Added: trunk/applications/content/servicedef/services_commevent.xml
===================================================================
--- trunk/applications/content/servicedef/services_commevent.xml 2006-03-29 08:06:45 UTC (rev 7101)
+++ trunk/applications/content/servicedef/services_commevent.xml 2006-03-29 08:29:05 UTC (rev 7102)
@@ -0,0 +1,87 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ * Copyright (c) 2001-2006 The Open For Business Project - www.ofbiz.org
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
+ * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+-->
+
+<services xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:noNamespaceSchemaLocation="http://www.ofbiz.org/dtds/services.xsd">
+ <description>Content Component Services</description>
+ <vendor>OFBiz</vendor>
+
+
+ <!--
+ This service must do two things:
+
+ First, call persistContentAndAssoc service to create the Content, DataResource and ImageDataResource/ElectronicText/??? entities.
+ Note that is will not create a ContentAssoc entity, which persistContentAndAssoc can do.
+ It should be able to auto populate the service parameters for persistContentAndAssoc from this service's input parameters
+ using ModelService.makeValid (or the simple method equivalent).
+ persistContentAndAssoc will return contentId.
+
+ Second, it must create a CommunicationEventContent record.
+ The fromData should be defaulted if not passed in.
+ -->
+ <service name="createCommContentDataResource" engine="simple"
+ location="org/ofbiz/content/content/ContentServices.xml" invoke="createCommContentDataResource" auth="true">
+ <description>Create CommunicationEvent and Content</description>
+ <implements service="persistContentAndAssoc"/>
+ <attribute name="communicationEventId" type="String" mode="IN" optional="false"/>
+ </service>
+
+ <service name="updateCommContentDataResource" engine="simple"
+ location="org/ofbiz/content/content/ContentServices.xml" invoke="updateCommContentDataResource" auth="true">
+ <description>Update CommunicationEvent and Content</description>
+ <implements service="persistContentAndAssoc"/>
+ <attribute name="communicationEventId" type="String" mode="IN" optional="false"/>
+ </service>
+
+ <service name="createCommEventContentAssoc" engine="simple"
+ location="org/ofbiz/content/content/ContentServices.xml" invoke="createCommEventContentAssoc" auth="true">
+ <description>Create CommEventContentAssoc</description>
+ <attribute name="communicationEventId" type="String" mode="IN" optional="false"/>
+ <attribute name="contentId" type="String" mode="IN" optional="false"/>
+ <attribute name="fromDate" type="Timestamp" mode="IN" optional="true"/>
+ <attribute name="thruDate" type="Timestamp" mode="IN" optional="true"/>
+ <attribute name="sequenceNum" type="Long" mode="IN" optional="true"/>
+ </service>
+
+ <service name="updateCommEventContentAssoc" engine="simple"
+ location="org/ofbiz/content/content/ContentServices.xml" invoke="updateCommEventContentAssoc" auth="true">
+ <description>Update CommEventContentAssoc</description>
+ <attribute name="communicationEventId" type="String" mode="IN" optional="false"/>
+ <attribute name="contentId" type="String" mode="IN" optional="false"/>
+ <attribute name="fromDate" type="Timestamp" mode="IN" optional="false"/>
+ <attribute name="thruDate" type="Timestamp" mode="IN" optional="true"/>
+ <attribute name="sequenceNum" type="Long" mode="IN" optional="true"/>
+ </service>
+
+ <service name="removeCommEventContentAssoc" engine="simple"
+ location="org.ofbiz.product.product.CommEventContentServices.xml" invoke="removeCommEventContent" auth="true">
+ <description>Remove CommEventContentAssoc</description>
+ <attribute name="communicationEventId" type="String" mode="IN" optional="false"/>
+ <attribute name="contentId" type="String" mode="IN" optional="false"/>
+ <attribute name="fromDate" type="Timestamp" mode="IN" optional="false"/>
+ </service>
+
+ <service name="storeIncomingEmail" engine="java"
+ location="org.ofbiz.content.email" invoke="storeIncomingEmail" auth="true">
+ </service>
+</services>
Modified: trunk/applications/content/servicedef/services_email.xml
===================================================================
--- trunk/applications/content/servicedef/services_email.xml 2006-03-29 08:06:45 UTC (rev 7101)
+++ trunk/applications/content/servicedef/services_email.xml 2006-03-29 08:29:05 UTC (rev 7102)
@@ -116,4 +116,14 @@
<attribute name="body" type="String" mode="IN" optional="false"/>
<attribute name="contentType" type="String" mode="IN" optional="true"/>
</service>
+ <service name="storeIncomingEmail" engine="java"
+ location="org.ofbiz.content.email.EmailServices" invoke="storeIncomingEmail" auth="true">
+ <description>Process incoming email. Try to determine partyIdFrom from email address.</description>
+ <implements service="mailProcessInterface"/>
+ </service>
+ <service name="storeForwardedEmail" engine="java"
+ location="org.ofbiz.content.email.EmailServices" invoke="storeForwardedEmail" auth="true">
+ <description>Process incoming email. Try to determine partyIdFrom from email address.</description>
+ <implements service="mailProcessInterface"/>
+ </service>
</services>
Modified: trunk/applications/content/src/org/ofbiz/content/email/EmailServices.java
===================================================================
--- trunk/applications/content/src/org/ofbiz/content/email/EmailServices.java 2006-03-29 08:06:45 UTC (rev 7101)
+++ trunk/applications/content/src/org/ofbiz/content/email/EmailServices.java 2006-03-29 08:29:05 UTC (rev 7102)
@@ -42,6 +42,7 @@
import javax.activation.DataHandler;
import javax.activation.DataSource;
import javax.mail.Message;
+import javax.mail.Address;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
@@ -49,6 +50,7 @@
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;
import javax.xml.parsers.ParserConfigurationException;
+import javax.mail.MessagingException;
import javolution.util.FastList;
import javolution.util.FastMap;
@@ -75,6 +77,7 @@
import org.ofbiz.service.GenericServiceException;
import org.ofbiz.service.LocalDispatcher;
import org.ofbiz.service.ServiceUtil;
+import org.ofbiz.service.mail.MimeMessageWrapper;
import org.ofbiz.widget.html.HtmlScreenRenderer;
import org.ofbiz.widget.screen.ScreenRenderer;
import org.w3c.dom.Document;
@@ -553,4 +556,36 @@
throw new IOException("Cannot write to this read-only resource");
}
}
+
+ public static Map storeIncomingEmail(DispatchContext dctx, Map context) {
+ MimeMessageWrapper wrapper = (MimeMessageWrapper) context.get("messageWrapper");
+ MimeMessage message = wrapper.getMessage();
+ InternetAddress fromAddress = null;
+ try {
+ Address [] addresses = message.getFrom();
+ if (addresses.length > 0) {
+ Address addr = addresses[0];
+ if (addr instanceof InternetAddress) {
+ fromAddress = (InternetAddress)addr;
+ }
+ }
+
+ if (UtilValidate.isEmpty(fromAddress) ) {
+ return ServiceUtil.returnError("No from address found.");
+ }
+ Debug.log("To: " + message.getAllRecipients(), module);
+ Debug.log("From: " + message.getFrom(), module);
+ Debug.log("Subject: " + message.getSubject(), module);
+ Debug.log("Sent: " + message.getSentDate().toString(), module);
+ Debug.log("Received: " + message.getReceivedDate().toString(), module);
+ } catch (MessagingException e) {
+ Debug.logError(e, module);
+ return ServiceUtil.returnError(e.getMessage());
+ } catch (Exception e) {
+ Debug.logError(e, module);
+ return ServiceUtil.returnError(e.getMessage());
+ }
+ return ServiceUtil.returnSuccess();
+ }
+
}
More information about the Svn
mailing list