PageRenderTime 36ms CodeModel.GetById 15ms RepoModel.GetById 1ms app.codeStats 0ms

/net/suddenelfilio/ws/tag/VCardTag.java

https://bitbucket.org/suddenelfilio/mstagjavalib
Java | 256 lines | 206 code | 50 blank | 0 comment | 46 complexity | e2ffd8572d0c5260ffdd4b6730b0cdf7 MD5 | raw file
  1. package net.suddenelfilio.ws.tag;
  2. import java.net.URL;
  3. import java.util.HashMap;
  4. import java.util.Map;
  5. public final class VCardTag extends Tag
  6. {
  7. public VCardTag()
  8. {
  9. TagStatus = Status.Active;
  10. Types = ImageTypes.Jpeg;
  11. }
  12. public String City;
  13. public String Company;
  14. public String Country;
  15. public String Email;
  16. public String Fax;
  17. public String Firstname;
  18. public String Lastname;
  19. public String MobilePhone;
  20. public String State;
  21. public String Street;
  22. public String Webpage;
  23. public String Workphone;
  24. public String Zip;
  25. public String Password;
  26. public String CurrentTitle;
  27. public URL ToURL(URLType type) throws Exception
  28. {
  29. if (MSTagService.SVCAPITOKEN == null || MSTagService.SVCAPITOKEN.equals(""))
  30. throw new Exception("Did you forget to set the MSTagService.SVCAPITOKEN with your token?");
  31. Map<String, String> mp = new HashMap<String, String>();
  32. mp.put("at", MSTagService.SVCAPITOKEN);
  33. switch (type)
  34. {
  35. case CREATE :
  36. if (IsNullOrEmpty(CategoryName))
  37. throw new Exception("The CategoryName cannot be null or empty when creating a Tag.");
  38. else
  39. mp.put("cn", CategoryName);
  40. if (IsNullOrEmpty(InteractionNote))
  41. mp.put("in", "");
  42. else
  43. mp.put("in", InteractionNote);
  44. if (IsNullOrEmpty(City))
  45. mp.put("c", "");
  46. else
  47. mp.put("c", City);
  48. if (IsNullOrEmpty(Company))
  49. mp.put("co", "");
  50. else
  51. mp.put("co", Company);
  52. if (IsNullOrEmpty(Country))
  53. mp.put("cou", "");
  54. else
  55. mp.put("cou", Country);
  56. if (IsNullOrEmpty(Email))
  57. mp.put("e", "");
  58. else
  59. mp.put("e", Email);
  60. if (IsNullOrEmpty(Fax))
  61. mp.put("f", "");
  62. else
  63. mp.put("f", Fax);
  64. if (IsNullOrEmpty(Firstname))
  65. mp.put("fn", "");
  66. else
  67. mp.put("fn", Firstname);
  68. if (IsNullOrEmpty(Lastname))
  69. mp.put("ln", "");
  70. else
  71. mp.put("ln", Lastname);
  72. if (IsNullOrEmpty(MobilePhone))
  73. mp.put("mp", "");
  74. else
  75. mp.put("mp", MobilePhone);
  76. if (IsNullOrEmpty(State))
  77. mp.put("st", "");
  78. else
  79. mp.put("st", State);
  80. if (IsNullOrEmpty(Webpage))
  81. mp.put("w", "");
  82. else
  83. mp.put("w", Webpage);
  84. if (IsNullOrEmpty(Workphone))
  85. mp.put("wp", "");
  86. else
  87. mp.put("wp", Workphone);
  88. if (IsNullOrEmpty(Zip))
  89. mp.put("z", "");
  90. else
  91. mp.put("z", Zip);
  92. if (IsNullOrEmpty(Street))
  93. mp.put("str", "");
  94. else
  95. mp.put("str", Street);
  96. if (IsNullOrEmpty(Password))
  97. mp.put("p", "");
  98. else
  99. mp.put("p", Password);
  100. if (TagStatus == null)
  101. mp.put("ts", "");
  102. else
  103. mp.put("ts", TagStatus.toString());
  104. if (IsNullOrEmpty(Title))
  105. throw new Exception("The Title cannot be null or empty when creating a Tag.");
  106. else
  107. mp.put("t", Title);
  108. if (IsNullOrEmpty(UTCEndDate))
  109. mp.put("ued", "");
  110. else
  111. mp.put("ued", UTCEndDate);
  112. if (IsNullOrEmpty(UTCStartDate))
  113. mp.put("usd", "");
  114. else
  115. mp.put("usd", UTCStartDate);
  116. return new URL(GenerateURL(mp, "CreateVcardTag"));
  117. case EDIT :
  118. if (IsNullOrEmpty(CurrentTitle))
  119. throw new Exception("The CurrentTile cannot be null or empty when editing a Tag.");
  120. else
  121. mp.put("ct", CurrentTitle);
  122. if (IsNullOrEmpty(CategoryName))
  123. mp.put("cn", "");
  124. else
  125. mp.put("cn", CategoryName);
  126. if (IsNullOrEmpty(City))
  127. mp.put("c", "");
  128. else
  129. mp.put("c", City);
  130. if (IsNullOrEmpty(Company))
  131. mp.put("co", "");
  132. else
  133. mp.put("co", Company);
  134. if (IsNullOrEmpty(Country))
  135. mp.put("cou", "");
  136. else
  137. mp.put("cou", Country);
  138. if (IsNullOrEmpty(Email))
  139. mp.put("e", "");
  140. else
  141. mp.put("e", Email);
  142. if (IsNullOrEmpty(Fax))
  143. mp.put("f", "");
  144. else
  145. mp.put("f", Fax);
  146. if (IsNullOrEmpty(Firstname))
  147. mp.put("fn", "");
  148. else
  149. mp.put("fn", Firstname);
  150. if (IsNullOrEmpty(Lastname))
  151. mp.put("ln", "");
  152. else
  153. mp.put("ln", Lastname);
  154. if (IsNullOrEmpty(MobilePhone))
  155. mp.put("mp", "");
  156. else
  157. mp.put("mp", MobilePhone);
  158. if (IsNullOrEmpty(State))
  159. mp.put("st", "");
  160. else
  161. mp.put("st", State);
  162. if (IsNullOrEmpty(Webpage))
  163. mp.put("w", "");
  164. else
  165. mp.put("w", Webpage);
  166. if (IsNullOrEmpty(Workphone))
  167. mp.put("wp", "");
  168. else
  169. mp.put("wp", Workphone);
  170. if (IsNullOrEmpty(Zip))
  171. mp.put("z", "");
  172. else
  173. mp.put("z", Zip);
  174. if (IsNullOrEmpty(Street))
  175. mp.put("str", "");
  176. else
  177. mp.put("str", Street);
  178. if (IsNullOrEmpty(Password))
  179. mp.put("p", "");
  180. else
  181. mp.put("p", Password);
  182. if (TagStatus == null)
  183. mp.put("ts", "");
  184. else
  185. mp.put("ts", TagStatus.toString());
  186. if (IsNullOrEmpty(Title))
  187. throw new Exception("The Title cannot be null or empty when editing a Tag.");
  188. else
  189. mp.put("t", Title);
  190. if (IsNullOrEmpty(UTCEndDate))
  191. mp.put("ued", "");
  192. else
  193. mp.put("ued", UTCEndDate);
  194. if (IsNullOrEmpty(UTCStartDate))
  195. mp.put("usd", "");
  196. else
  197. mp.put("usd", UTCStartDate);
  198. return new URL(GenerateURL(mp, "EditVcardTag"));
  199. case ACTIVE :
  200. return Activate();
  201. case PAUSE :
  202. return Pause();
  203. }
  204. return null;
  205. }
  206. }