PageRenderTime 47ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 0ms

/net/suddenelfilio/ws/tag/URITag.java

https://bitbucket.org/suddenelfilio/mstagjavalib
Java | 118 lines | 93 code | 25 blank | 0 comment | 21 complexity | 00254162f8eb7f828eb4466ac0446abd 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 URITag extends Tag
  6. {
  7. public URITag()
  8. {
  9. TagStatus = Status.Active;
  10. Types = ImageTypes.Jpeg;
  11. }
  12. public String MedFiUrl;
  13. public String CurrentTitle;
  14. public URL ToURL(URLType type) throws Exception
  15. {
  16. if (MSTagService.SVCAPITOKEN == null || MSTagService.SVCAPITOKEN.equals(""))
  17. throw new Exception("Did you forget to set the MSTagService.SVCAPITOKEN with your token?");
  18. Map<String, String> mp = new HashMap<String, String>();
  19. mp.put("at", MSTagService.SVCAPITOKEN);
  20. switch (type)
  21. {
  22. case CREATE :
  23. if (IsNullOrEmpty(CategoryName))
  24. throw new Exception("The CategoryName cannot be null or empty when creating a Tag.");
  25. else
  26. mp.put("cn", CategoryName);
  27. if (IsNullOrEmpty(InteractionNote))
  28. mp.put("in", "");
  29. else
  30. mp.put("in", InteractionNote);
  31. if (IsNullOrEmpty(MedFiUrl))
  32. throw new Exception("The MedFiUrl cannot be null or empty when creating a Tag.");
  33. else
  34. mp.put("mfu", MedFiUrl);
  35. if (TagStatus == null)
  36. mp.put("ts", "");
  37. else
  38. mp.put("ts", TagStatus.toString());
  39. if (IsNullOrEmpty(Title))
  40. throw new Exception("The Title cannot be null or empty when creating a Tag.");
  41. else
  42. mp.put("t", Title);
  43. if (IsNullOrEmpty(UTCEndDate))
  44. mp.put("ued", "");
  45. else
  46. mp.put("ued", UTCEndDate);
  47. if (IsNullOrEmpty(UTCStartDate))
  48. mp.put("usd", "");
  49. else
  50. mp.put("usd", UTCStartDate);
  51. return new URL(GenerateURL(mp, "CreateURITag"));
  52. case EDIT :
  53. if (IsNullOrEmpty(CurrentTitle))
  54. throw new Exception("The CurrentTile cannot be null or empty when editing a Tag.");
  55. else
  56. mp.put("ct", CurrentTitle);
  57. if (IsNullOrEmpty(CategoryName))
  58. mp.put("cn", "");
  59. else
  60. mp.put("cn", CategoryName);
  61. if (IsNullOrEmpty(InteractionNote))
  62. mp.put("in", "");
  63. else
  64. mp.put("in", InteractionNote);
  65. if (IsNullOrEmpty(MedFiUrl))
  66. throw new Exception("The MedFiUrl cannot be null or empty when editing a Tag.");
  67. else
  68. mp.put("mfu", MedFiUrl);
  69. if (TagStatus == null)
  70. mp.put("ts", "");
  71. else
  72. mp.put("ts", TagStatus.toString());
  73. if (IsNullOrEmpty(Title))
  74. mp.put("t", "");
  75. else
  76. mp.put("t", Title);
  77. if (IsNullOrEmpty(UTCEndDate))
  78. mp.put("ued", "");
  79. else
  80. mp.put("ued", UTCEndDate);
  81. if (IsNullOrEmpty(UTCStartDate))
  82. mp.put("usd", "");
  83. else
  84. mp.put("usd", UTCStartDate);
  85. return new URL(GenerateURL(mp, "EditURITag"));
  86. case ACTIVE :
  87. return Activate();
  88. case PAUSE :
  89. return Pause();
  90. }
  91. return null;
  92. }
  93. }