Guest User

mm_83_1_POP3XMLReceiver.patch

a guest
Oct 20th, 2017
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 12.84 KB | None | 0 0
  1. diff --git a/src/main/java/net/sf/xbus/technical/mail/Clazz1572373.java b/src/main/java/net/sf/xbus/technical/mail/Clazz1572373.java
  2. new file mode 100644
  3. index 0000000..dbe7c28
  4. --- /dev/null
  5. +++ b/src/main/java/net/sf/xbus/technical/mail/Clazz1572373.java
  6. @@ -0,0 +1,44 @@
  7. +package net.sf.xbus.technical.mail;
  8. +
  9. +public class Clazz1572373 {
  10. +  
  11. +   private String mHost = null;
  12. +   private String mUser = null;
  13. +   private String mPassword = null;
  14. +
  15. +   public Clazz1572373(String mHost2, String mUser2, String mPassword2) {
  16. +       this.mHost = mHost2;
  17. +       this.mUser = mUser2;
  18. +       this.mPassword = mPassword2;
  19. +   }
  20. +
  21. +   public String getmHost() {
  22. +       return mHost;
  23. +   }
  24. +
  25. +   public void setmHost(String mHost) {
  26. +       this.mHost = mHost;
  27. +   }
  28. +
  29. +   public String getmUser() {
  30. +       return mUser;
  31. +   }
  32. +
  33. +   public void setmUser(String mUser) {
  34. +       this.mUser = mUser;
  35. +   }
  36. +
  37. +   public String getmPassword() {
  38. +       return mPassword;
  39. +   }
  40. +
  41. +   public void setmPassword(String mPassword) {
  42. +       this.mPassword = mPassword;
  43. +   }
  44. +
  45. +   public String getAddress() {
  46. +       return new StringBuffer(mUser).append("@").append(mHost).toString();
  47. +   }
  48. +  
  49. +
  50. +}
  51. diff --git a/src/main/java/net/sf/xbus/technical/mail/Clazz8549921.java b/src/main/java/net/sf/xbus/technical/mail/Clazz8549921.java
  52. new file mode 100644
  53. index 0000000..03acf2c
  54. --- /dev/null
  55. +++ b/src/main/java/net/sf/xbus/technical/mail/Clazz8549921.java
  56. @@ -0,0 +1,95 @@
  57. +package net.sf.xbus.technical.mail;
  58. +
  59. +import java.util.List;
  60. +import java.util.Vector;
  61. +
  62. +import net.sf.xbus.base.core.Constants;
  63. +import net.sf.xbus.base.core.XException;
  64. +import net.sf.xbus.base.core.config.Configuration;
  65. +
  66. +public class Clazz8549921 {
  67. +  
  68. +  
  69. +
  70. +   private Clazz8549921 () {}
  71. +  
  72. +   public static Clazz8549921 getInstance() {
  73. +       return new Clazz8549921();
  74. +   }
  75. +
  76. +   public Clazz1572373 getMailAccount(String system) throws XException {
  77. +       Configuration config = Configuration.getInstance();
  78. +      
  79. +       String mHost = config.getValue(Constants.CHAPTER_SYSTEM, system, "Host");
  80. +       String mUser = config.getValue(Constants.CHAPTER_SYSTEM, system, "User");
  81. +       String mPassword = config.getValue(Constants.CHAPTER_SYSTEM, system,
  82. +               "Password");
  83. +       return new Clazz1572373(mHost, mUser, mPassword);
  84. +      
  85. +   }
  86. +  
  87. +   /**
  88. +    * Reads final resolution (resolved action with the email after that it was
  89. +    * read) for the for the given system name from the standard configuration
  90. +    * and checks its conformity with the allowed ones:
  91. +    * <p>
  92. +    * <dl>
  93. +    * <dd><code>Preserve</code> &nbsp;-email is remained without
  94. +    * modifications
  95. +    * <dd><code>Delete</code> &nbsp;&nbsp;&nbsp;- email is deleted
  96. +    * </dl>
  97. +    *
  98. +    * @param system Sytem name which resoltion must be read.
  99. +    * @return exist resolution (Preserve, Rename or Delete) as String
  100. +    * @exception XException if resolution is falsh or any errors occurs
  101. +    */
  102. +  
  103. +   public String getResolution(String system) throws XException
  104. +   {
  105. +       Configuration config = Configuration.getInstance();
  106. +       String resolution = config.getValue(Constants.CHAPTER_SYSTEM, system,
  107. +               Constants.KEY_RECEIVE_RESOL);
  108. +       if (!resolution.equals(Constants.READ_PRESERVE)
  109. +               && !resolution.equals(Constants.READ_DELETE))
  110. +       {
  111. +           List params = new Vector();
  112. +           params.add(resolution);
  113. +           throw new XException(Constants.LOCATION_INTERN,
  114. +                   Constants.LAYER_TECHNICAL,
  115. +                   Constants.PACKAGE_TECHNICAL_MAIL, "1", params);
  116. +       }
  117. +       return resolution;
  118. +   }
  119. +  
  120. +   /**
  121. +    * Reads the action which should happen with the email after an error for
  122. +    * the for the given system name from the standard configuration and checks
  123. +    * its conformity with the allowed ones:
  124. +    * <p>
  125. +    * <dl>
  126. +    * <dd><code>Preserve</code> &nbsp;-email is remained without
  127. +    * modifications
  128. +    * <dd><code>Delete</code> &nbsp;&nbsp;&nbsp;- email is deleted
  129. +    * </dl>
  130. +    *
  131. +    * @param system Sytem name which resoltion must be read.
  132. +    * @return exist resolution (Preserve, Rename or Delete) as String
  133. +    * @exception XException if resolution is falsh or any errors occurs
  134. +    */
  135. +   public String getOnError(String system) throws XException
  136. +   {
  137. +       Configuration config = Configuration.getInstance();
  138. +       String onError = config.getValue(Constants.CHAPTER_SYSTEM, system,
  139. +               "OnError");
  140. +       if (!onError.equals(Constants.READ_PRESERVE)
  141. +               && !onError.equals(Constants.READ_DELETE))
  142. +       {
  143. +           List params = new Vector();
  144. +           params.add(onError);
  145. +           throw new XException(Constants.LOCATION_INTERN,
  146. +                   Constants.LAYER_TECHNICAL,
  147. +                   Constants.PACKAGE_TECHNICAL_MAIL, "2", params);
  148. +       }
  149. +       return onError;
  150. +   }
  151. +}
  152. diff --git a/src/main/java/net/sf/xbus/technical/mail/Clazz1950677.java b/src/main/java/net/sf/xbus/technical/mail/Clazz1950677.java
  153. new file mode 100644
  154. index 0000000..6bb04e5
  155. --- /dev/null
  156. +++ b/src/main/java/net/sf/xbus/technical/mail/Clazz1950677.java
  157. @@ -0,0 +1,82 @@
  158. +package net.sf.xbus.technical.mail;
  159. +
  160. +import java.util.Properties;
  161. +
  162. +import javax.mail.Folder;
  163. +import javax.mail.MessagingException;
  164. +import javax.mail.NoSuchProviderException;
  165. +import javax.mail.Session;
  166. +
  167. +import net.sf.xbus.base.core.Constants;
  168. +import net.sf.xbus.base.core.XException;
  169. +
  170. +public class Clazz1950677 {
  171. +
  172. +   /**
  173. +    * This method will open the connection with the POP3 server
  174. +    */
  175. +   public static void open(POP3XMLReceiver p) throws XException
  176. +   {
  177. +       try
  178. +       {
  179. +           if (p.getmSession() == null)
  180. +           {
  181. +               p.setmSession(Session.getInstance(new Properties()));
  182. +           }
  183. +
  184. +           if (p.getmStore() == null)
  185. +           {
  186. +               p.setmStore(p.getmSession().getStore("pop3"));
  187. +               p.getmStore().connect(p.getMailAccount().getmHost(),
  188. +                       p.getMailAccount().getmUser(),
  189. +                       p.getMailAccount().getmPassword());
  190. +           }
  191. +
  192. +           if (p.getmFolder() == null)
  193. +           {
  194. +               p.setmFolder(p.getmStore().getFolder("INBOX"));
  195. +               p.getmFolder().open(Folder.READ_WRITE);
  196. +           }
  197. +       }
  198. +       catch (NoSuchProviderException e)
  199. +       {
  200. +           p.setmSession(null);
  201. +           p.setmStore(null);
  202. +           p.setmFolder(null);
  203. +           throw new XException(Constants.LOCATION_EXTERN,
  204. +                   Constants.LAYER_TECHNICAL,
  205. +                   Constants.PACKAGE_TECHNICAL_MAIL, "0", e);
  206. +       }
  207. +       catch (MessagingException e)
  208. +       {
  209. +           p.setmSession(null);
  210. +           p.setmStore(null);
  211. +           p.setmFolder(null);
  212. +           throw new XException(Constants.LOCATION_EXTERN,
  213. +                   Constants.LAYER_TECHNICAL,
  214. +                   Constants.PACKAGE_TECHNICAL_MAIL, "0", e);
  215. +       }
  216. +   }
  217. +
  218. +
  219. +   public static void close (POP3XMLReceiver p) throws XException {
  220. +       p.closeFolder();
  221. +
  222. +       try
  223. +       {
  224. +           if (p.getmStore() != null)
  225. +           {
  226. +               p.getmStore().close();
  227. +               p.setmStore(null);
  228. +               p.setmSession(null);
  229. +           }
  230. +       }
  231. +       catch (MessagingException e)
  232. +       {
  233. +           throw new XException(Constants.LOCATION_EXTERN,
  234. +                   Constants.LAYER_TECHNICAL,
  235. +                   Constants.PACKAGE_TECHNICAL_MAIL, "0", e);
  236. +       }
  237. +      
  238. +   }
  239. +}
  240. diff --git a/src/main/java/net/sf/xbus/technical/mail/POP3XMLReceiver.java b/src/main/java/net/sf/xbus/technical/mail/POP3XMLReceiver.java
  241. index a6b1fbf..b61e285 100644
  242. --- a/src/main/java/net/sf/xbus/technical/mail/POP3XMLReceiver.java
  243. +++ b/src/main/java/net/sf/xbus/technical/mail/POP3XMLReceiver.java
  244. @@ -50,9 +50,7 @@ public class POP3XMLReceiver
  245.             ReceiverSingleInterface
  246.  {
  247.  
  248. -   private String mHost = null;
  249. -   private String mUser = null;
  250. -   private String mPassword = null;
  251. +   private Clazz1572373 clazz1572373 = null;
  252.  
  253.     private Store mStore = null;
  254.     protected Folder mFolder = null;
  255. @@ -391,43 +389,7 @@ public class POP3XMLReceiver
  256.      */
  257.     public void open() throws XException
  258.     {
  259. -       try
  260. -       {
  261. -           if (mSession == null)
  262. -           {
  263. -               mSession = Session.getInstance(new Properties());
  264. -           }
  265. -
  266. -           if (mStore == null)
  267. -           {
  268. -               mStore = mSession.getStore("pop3");
  269. -               mStore.connect(mHost, mUser, mPassword);
  270. -           }
  271. -
  272. -           if (mFolder == null)
  273. -           {
  274. -               mFolder = mStore.getFolder("INBOX");
  275. -               mFolder.open(Folder.READ_WRITE);
  276. -           }
  277. -       }
  278. -       catch (NoSuchProviderException e)
  279. -       {
  280. -           mSession = null;
  281. -           mStore = null;
  282. -           mFolder = null;
  283. -           throw new XException(Constants.LOCATION_EXTERN,
  284. -                   Constants.LAYER_TECHNICAL,
  285. -                   Constants.PACKAGE_TECHNICAL_MAIL, "0", e);
  286. -       }
  287. -       catch (MessagingException e)
  288. -       {
  289. -           mSession = null;
  290. -           mStore = null;
  291. -           mFolder = null;
  292. -           throw new XException(Constants.LOCATION_EXTERN,
  293. -                   Constants.LAYER_TECHNICAL,
  294. -                   Constants.PACKAGE_TECHNICAL_MAIL, "0", e);
  295. -       }
  296. +       Clazz1950677.open(this);
  297.     }
  298.  
  299.     /**
  300. @@ -435,33 +397,7 @@ public class POP3XMLReceiver
  301.      */
  302.     public void close() throws XException
  303.     {
  304. -       closeFolder();
  305. -
  306. -       try
  307. -       {
  308. -           if (mStore != null)
  309. -           {
  310. -               mStore.close();
  311. -               mStore = null;
  312. -               mSession = null;
  313. -           }
  314. -       }
  315. -       catch (MessagingException e)
  316. -       {
  317. -           throw new XException(Constants.LOCATION_EXTERN,
  318. -                   Constants.LAYER_TECHNICAL,
  319. -                   Constants.PACKAGE_TECHNICAL_MAIL, "0", e);
  320. -       }
  321. -   }
  322. -
  323. -   /**
  324. -    * Returns the onError.
  325. -    *
  326. -    * @return String
  327. -    */
  328. -   public String getOnError()
  329. -   {
  330. -       return mOnError;
  331. +       Clazz1950677.close(this);
  332.     }
  333.  
  334.     /**
  335. @@ -520,80 +456,16 @@ public class POP3XMLReceiver
  336.      */
  337.     protected void readConfiguration(String system) throws XException
  338.     {
  339. -       Configuration config = Configuration.getInstance();
  340. -       mResolution = getResolution(system);
  341. -       mOnError = getOnError(system);
  342. -
  343. -       mHost = config.getValue(Constants.CHAPTER_SYSTEM, system, "Host");
  344. -       mUser = config.getValue(Constants.CHAPTER_SYSTEM, system, "User");
  345. -       mPassword = config.getValue(Constants.CHAPTER_SYSTEM, system,
  346. -               "Password");
  347. +       Clazz8549921 c = Clazz8549921.getInstance();
  348. +      
  349. +       mResolution = c.getResolution(system);
  350. +       mOnError = c.getOnError(system);
  351. +       clazz1572373 = c.getMailAccount(system);
  352.     }
  353.  
  354. -   /**
  355. -    * Reads final resolution (resolved action with the email after that it was
  356. -    * read) for the for the given system name from the standard configuration
  357. -    * and checks its conformity with the allowed ones:
  358. -    * <p>
  359. -    * <dl>
  360. -    * <dd><code>Preserve</code> &nbsp;-email is remained without
  361. -    * modifications
  362. -    * <dd><code>Delete</code> &nbsp;&nbsp;&nbsp;- email is deleted
  363. -    * </dl>
  364. -    *
  365. -    * @param system Sytem name which resoltion must be read.
  366. -    * @return exist resolution (Preserve, Rename or Delete) as String
  367. -    * @exception XException if resolution is falsh or any errors occurs
  368. -    */
  369. -   private String getResolution(String system) throws XException
  370. -   {
  371. -       Configuration config = Configuration.getInstance();
  372. -       String resolution = config.getValue(Constants.CHAPTER_SYSTEM, system,
  373. -               Constants.KEY_RECEIVE_RESOL);
  374. -       if (!resolution.equals(Constants.READ_PRESERVE)
  375. -               && !resolution.equals(Constants.READ_DELETE))
  376. -       {
  377. -           List params = new Vector();
  378. -           params.add(mResolution);
  379. -           throw new XException(Constants.LOCATION_INTERN,
  380. -                   Constants.LAYER_TECHNICAL,
  381. -                   Constants.PACKAGE_TECHNICAL_MAIL, "1", params);
  382. -       }
  383. -       return resolution;
  384. -   }
  385. -
  386. -   /**
  387. -    * Reads the action which should happen with the email after an error for
  388. -    * the for the given system name from the standard configuration and checks
  389. -    * its conformity with the allowed ones:
  390. -    * <p>
  391. -    * <dl>
  392. -    * <dd><code>Preserve</code> &nbsp;-email is remained without
  393. -    * modifications
  394. -    * <dd><code>Delete</code> &nbsp;&nbsp;&nbsp;- email is deleted
  395. -    * </dl>
  396. -    *
  397. -    * @param system Sytem name which resoltion must be read.
  398. -    * @return exist resolution (Preserve, Rename or Delete) as String
  399. -    * @exception XException if resolution is falsh or any errors occurs
  400. -    */
  401. -   private String getOnError(String system) throws XException
  402. -   {
  403. -       Configuration config = Configuration.getInstance();
  404. -       String onError = config.getValue(Constants.CHAPTER_SYSTEM, system,
  405. -               "OnError");
  406. -       if (!onError.equals(Constants.READ_PRESERVE)
  407. -               && !onError.equals(Constants.READ_DELETE))
  408. -       {
  409. -           List params = new Vector();
  410. -           params.add(onError);
  411. -           throw new XException(Constants.LOCATION_INTERN,
  412. -                   Constants.LAYER_TECHNICAL,
  413. -                   Constants.PACKAGE_TECHNICAL_MAIL, "2", params);
  414. -       }
  415. -       return onError;
  416. -   }
  417. +  
  418.  
  419. +  
  420.     /**
  421.      * @throws XException
  422.      */
  423. @@ -627,7 +499,7 @@ public class POP3XMLReceiver
  424.  
  425.     protected String getAddress()
  426.     {
  427. -       return new StringBuffer(mUser).append("@").append(mHost).toString();
  428. +       return clazz1572373.getAddress();
  429.     }
  430.  
  431.     /**
  432. @@ -637,4 +509,36 @@ public class POP3XMLReceiver
  433.     {
  434.         return mReturncode;
  435.     }
  436. +  
  437. +   public Session getmSession() {
  438. +       return mSession;
  439. +   }
  440. +
  441. +   public void setmSession(Session mSession) {
  442. +       this.mSession = mSession;
  443. +   }
  444. +
  445. +   public Store getmStore() {
  446. +       return mStore;
  447. +   }
  448. +
  449. +   public Folder getmFolder() {
  450. +       return mFolder;
  451. +   }
  452. +
  453. +   public void setmStore(Store mStore) {
  454. +       this.mStore = mStore;
  455. +   }
  456. +
  457. +   public void setmFolder(Folder mFolder) {
  458. +       this.mFolder = mFolder;
  459. +   }
  460. +
  461. +   public Clazz1572373 getMailAccount() {
  462. +       return clazz1572373;
  463. +   }
  464. +
  465. +   public void setMailAccount(Clazz1572373 clazz1572373) {
  466. +       this.clazz1572373 = clazz1572373;
  467. +   }
  468.  }
Add Comment
Please, Sign In to add comment