You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ja...@apache.org on 2007/01/31 04:41:38 UTC
svn commit: r501711 -
/ofbiz/trunk/applications/content/src/org/ofbiz/content/email/EmailWorker.java
Author: jacopoc
Date: Tue Jan 30 19:41:37 2007
New Revision: 501711
URL: http://svn.apache.org/viewvc?view=rev&rev=501711
Log:
Fixed bad formatting (mostly tabs in place of 4-spaces).
Modified:
ofbiz/trunk/applications/content/src/org/ofbiz/content/email/EmailWorker.java
Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/email/EmailWorker.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/email/EmailWorker.java?view=diff&rev=501711&r1=501710&r2=501711
==============================================================================
--- ofbiz/trunk/applications/content/src/org/ofbiz/content/email/EmailWorker.java (original)
+++ ofbiz/trunk/applications/content/src/org/ofbiz/content/email/EmailWorker.java Tue Jan 30 19:41:37 2007
@@ -41,95 +41,91 @@
public final static String module = EmailWorker.class.getName();
public String getForwardedField(MimeMessage message) {
-
- String fieldValue = null;
-
- return fieldValue;
+ String fieldValue = null;
+ return fieldValue;
}
public static int addAttachmentsToCommEvent(MimeMessage message, String communicationEventId, LocalDispatcher dispatcher, GenericValue userLogin)
- throws MessagingException, IOException, GenericServiceException {
- Map commEventMap = new HashMap();
- commEventMap.put("communicationEventId", communicationEventId);
- commEventMap.put("contentTypeId", "DOCUMENT");
- commEventMap.put("mimeTypeId", "text/html");
- commEventMap.put("userLogin", userLogin);
- String subject = message.getSubject();
- if (subject != null && subject.length() > 80) {
- subject = subject.substring(0,80); // make sure not too big for database field. (20 characters for filename)
- }
- currentIndex = "";
- attachmentCount = 0;
- return addMultipartAttachementToComm((Multipart)message.getContent(), commEventMap, subject, dispatcher, userLogin);
+ throws MessagingException, IOException, GenericServiceException {
+ Map commEventMap = new HashMap();
+ commEventMap.put("communicationEventId", communicationEventId);
+ commEventMap.put("contentTypeId", "DOCUMENT");
+ commEventMap.put("mimeTypeId", "text/html");
+ commEventMap.put("userLogin", userLogin);
+ String subject = message.getSubject();
+ if (subject != null && subject.length() > 80) {
+ subject = subject.substring(0,80); // make sure not too big for database field. (20 characters for filename)
+ }
+ currentIndex = "";
+ attachmentCount = 0;
+ return addMultipartAttachementToComm((Multipart)message.getContent(), commEventMap, subject, dispatcher, userLogin);
}
private static String currentIndex = "";
private static int attachmentCount = 0;
private static int addMultipartAttachementToComm(Multipart multipart, Map commEventMap, String subject, LocalDispatcher dispatcher, GenericValue userLogin)
throws MessagingException, IOException, GenericServiceException {
- try {
- int multipartCount = multipart.getCount();
- for (int i=0; i < multipartCount; i++) {
- Part part = multipart.getBodyPart(i);
- String thisContentTypeRaw = part.getContentType();
- int idx2 = thisContentTypeRaw.indexOf(";");
- if (idx2 == -1) idx2 = thisContentTypeRaw.length();
- String thisContentType = thisContentTypeRaw.substring(0, idx2);
- String disposition = part.getDisposition();
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ try {
+ int multipartCount = multipart.getCount();
+ for (int i=0; i < multipartCount; i++) {
+ Part part = multipart.getBodyPart(i);
+ String thisContentTypeRaw = part.getContentType();
+ int idx2 = thisContentTypeRaw.indexOf(";");
+ if (idx2 == -1) idx2 = thisContentTypeRaw.length();
+ String thisContentType = thisContentTypeRaw.substring(0, idx2);
+ String disposition = part.getDisposition();
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
- if (thisContentType.startsWith("multipart") || thisContentType.startsWith("Multipart")) {
- currentIndex = currentIndex.concat("." + i);
- return addMultipartAttachementToComm((Multipart) part.getContent(), commEventMap, subject, dispatcher, userLogin);
- }
-
- if(currentIndex.concat("." + i).equals(EmailServices.contentIndex)) continue;
+ if (thisContentType.startsWith("multipart") || thisContentType.startsWith("Multipart")) {
+ currentIndex = currentIndex.concat("." + i);
+ return addMultipartAttachementToComm((Multipart) part.getContent(), commEventMap, subject, dispatcher, userLogin);
+ }
+
+ if(currentIndex.concat("." + i).equals(EmailServices.contentIndex)) continue;
- // The first test should not pass, because if it exists, it should be the bodyContentIndex part
- if (((disposition == null) && (i == 0) && thisContentType.startsWith("text"))
- || ((disposition != null)
- && (disposition.equals(Part.ATTACHMENT) || disposition.equals(Part.INLINE))
- ) )
- {
- String attFileName = part.getFileName();
- if (!UtilValidate.isEmpty(attFileName)) {
- commEventMap.put("contentName", attFileName);
- commEventMap.put("description", subject + "-" + attachmentCount);
- } else {
- commEventMap.put("contentName", subject + "-" + attachmentCount);
- }
- commEventMap.put("drMimeTypeId", thisContentType);
- if (thisContentType.startsWith("text")) {
- String content = (String)part.getContent();
- commEventMap.put("drDataResourceTypeId", "ELECTRONIC_TEXT");
- commEventMap.put("textData", content);
- } else {
-
- InputStream is = part.getInputStream();
- int c;
- while ((c = is.read()) > -1) {
- baos.write(c);
- }
-
- ByteWrapper imageData = new ByteWrapper(baos.toByteArray());
- int len = imageData.getLength();
- if (Debug.infoOn()) Debug.logInfo("imageData length: " + len, module);
- commEventMap.put("drDataResourceName", part.getFileName());
- commEventMap.put("imageData", imageData);
- commEventMap.put("drDataResourceTypeId", "IMAGE_OBJECT");
- commEventMap.put("_imageData_contentType", thisContentType);
- }
- dispatcher.runSync("createCommContentDataResource", commEventMap);
- attachmentCount++;
- }
- }
- } catch (MessagingException e) {
- Debug.logError(e, module);
- } catch (IOException e) {
- Debug.logError(e, module);
- } catch (GenericServiceException e) {
- Debug.logError(e, module);
- }
- return attachmentCount;
+ // The first test should not pass, because if it exists, it should be the bodyContentIndex part
+ if (((disposition == null) && (i == 0) && thisContentType.startsWith("text"))
+ || ((disposition != null)
+ && (disposition.equals(Part.ATTACHMENT) || disposition.equals(Part.INLINE))
+ ) )
+ {
+ String attFileName = part.getFileName();
+ if (!UtilValidate.isEmpty(attFileName)) {
+ commEventMap.put("contentName", attFileName);
+ commEventMap.put("description", subject + "-" + attachmentCount);
+ } else {
+ commEventMap.put("contentName", subject + "-" + attachmentCount);
+ }
+ commEventMap.put("drMimeTypeId", thisContentType);
+ if (thisContentType.startsWith("text")) {
+ String content = (String)part.getContent();
+ commEventMap.put("drDataResourceTypeId", "ELECTRONIC_TEXT");
+ commEventMap.put("textData", content);
+ } else {
+ InputStream is = part.getInputStream();
+ int c;
+ while ((c = is.read()) > -1) {
+ baos.write(c);
+ }
+ ByteWrapper imageData = new ByteWrapper(baos.toByteArray());
+ int len = imageData.getLength();
+ if (Debug.infoOn()) Debug.logInfo("imageData length: " + len, module);
+ commEventMap.put("drDataResourceName", part.getFileName());
+ commEventMap.put("imageData", imageData);
+ commEventMap.put("drDataResourceTypeId", "IMAGE_OBJECT");
+ commEventMap.put("_imageData_contentType", thisContentType);
+ }
+ dispatcher.runSync("createCommContentDataResource", commEventMap);
+ attachmentCount++;
+ }
+ }
+ } catch (MessagingException e) {
+ Debug.logError(e, module);
+ } catch (IOException e) {
+ Debug.logError(e, module);
+ } catch (GenericServiceException e) {
+ Debug.logError(e, module);
+ }
+ return attachmentCount;
}
}