PageRenderTime 18ms CodeModel.GetById 12ms app.highlight 3ms RepoModel.GetById 2ms app.codeStats 0ms

/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
16package com.google.ie.common.objectionable;
17
18import com.google.appengine.api.labs.taskqueue.Queue;
19import com.google.appengine.api.labs.taskqueue.QueueFactory;
20import com.google.appengine.api.labs.taskqueue.TaskOptions;
21import com.google.ie.common.constants.IdeaExchangeConstants;
22
23/**
24 * An object that check the objectionable content in idea.
25 * This class is used to queue a task for checking objectionable content
26 * when ever an Idea gets published.
27 * 
28 * @author gmaurya
29 */
30public class ObjectionableManager {
31
32    /**
33     * Add the task to check objectionable content to the specific queue.
34     * 
35     * @param ideaKey key of the idea to be checked
36     */
37    public static void checkObjectionable(String key) {
38        /* Use Task Queue to queue the task for checking objectionable content. */
39        Queue queue = QueueFactory.getQueue(IdeaExchangeConstants.OBJECTIONABLE_QUEUE);
40        TaskOptions taskOptions = TaskOptions.Builder.url(
41                        IdeaExchangeConstants.CHECK_OBJECTIONABLE_URL
42                        + IdeaExchangeConstants.BACKSLASH + key);
43        queue.add(taskOptions);
44
45    }
46
47    /**
48     * It's a worker task queue which is initiated by main task queue for
49     * checking the objectionable content on particular attribute of Idea.
50     * 
51     * @param ideaKey key of Idea
52     * @param fieldType marker for the field of Idea to be checked
53     */
54    public static void startCheckObjectionableWorker(String key, String fieldName) {
55        /* Use Task Queue to check objectionable content in idea attributes. */
56        Queue queue = QueueFactory.getQueue(IdeaExchangeConstants.OBJECTIONABLE_WORKER_QUEUE);
57        TaskOptions taskOptions = TaskOptions.Builder.url(
58                        IdeaExchangeConstants.CHECK_OBJECTIONABLE_WORKER_URL
59                        + IdeaExchangeConstants.BACKSLASH + key
60                        + IdeaExchangeConstants.BACKSLASH + fieldName);
61        queue.add(taskOptions);
62
63    }
64}
65