/src/main/java/com/google/ie/common/objectionable/ObjectionableManager.java

http://thoughtsite.googlecode.com/ · Java · 65 lines · 22 code · 8 blank · 35 comment · 0 complexity · 22d57c16a1daecb863aad54575cd83d1 MD5 · raw file

  1. /* Copyright 2010 Google Inc.
  2. *
  3. * Licensed under the Apache License, Version 2.0 (the "License");
  4. * you may not use this file except in compliance with the License.
  5. * You may obtain a copy of the License at
  6. *
  7. * http://www.apache.org/licenses/LICENSE-2.0
  8. *
  9. * Unless required by applicable law or agreed to in writing, software
  10. * distributed under the License is distributed on an "AS IS" BASIS.
  11. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. * See the License for the specific language governing permissions and
  13. * limitations under the License
  14. */
  15. package com.google.ie.common.objectionable;
  16. import com.google.appengine.api.labs.taskqueue.Queue;
  17. import com.google.appengine.api.labs.taskqueue.QueueFactory;
  18. import com.google.appengine.api.labs.taskqueue.TaskOptions;
  19. import com.google.ie.common.constants.IdeaExchangeConstants;
  20. /**
  21. * An object that check the objectionable content in idea.
  22. * This class is used to queue a task for checking objectionable content
  23. * when ever an Idea gets published.
  24. *
  25. * @author gmaurya
  26. */
  27. public class ObjectionableManager {
  28. /**
  29. * Add the task to check objectionable content to the specific queue.
  30. *
  31. * @param ideaKey key of the idea to be checked
  32. */
  33. public static void checkObjectionable(String key) {
  34. /* Use Task Queue to queue the task for checking objectionable content. */
  35. Queue queue = QueueFactory.getQueue(IdeaExchangeConstants.OBJECTIONABLE_QUEUE);
  36. TaskOptions taskOptions = TaskOptions.Builder.url(
  37. IdeaExchangeConstants.CHECK_OBJECTIONABLE_URL
  38. + IdeaExchangeConstants.BACKSLASH + key);
  39. queue.add(taskOptions);
  40. }
  41. /**
  42. * It's a worker task queue which is initiated by main task queue for
  43. * checking the objectionable content on particular attribute of Idea.
  44. *
  45. * @param ideaKey key of Idea
  46. * @param fieldType marker for the field of Idea to be checked
  47. */
  48. public static void startCheckObjectionableWorker(String key, String fieldName) {
  49. /* Use Task Queue to check objectionable content in idea attributes. */
  50. Queue queue = QueueFactory.getQueue(IdeaExchangeConstants.OBJECTIONABLE_WORKER_QUEUE);
  51. TaskOptions taskOptions = TaskOptions.Builder.url(
  52. IdeaExchangeConstants.CHECK_OBJECTIONABLE_WORKER_URL
  53. + IdeaExchangeConstants.BACKSLASH + key
  54. + IdeaExchangeConstants.BACKSLASH + fieldName);
  55. queue.add(taskOptions);
  56. }
  57. }