Advertisement
Guest User

mm_83_1_POP3XMLReceiver

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