1 /*
2 * Copyright 2012 smartics, Kronseder & Reiner GmbH
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package de.smartics.maven.bugzilla.command;
17
18 import java.util.ArrayList;
19 import java.util.List;
20
21 import de.smartics.maven.issue.command.AbstractCommand;
22 import de.smartics.maven.issue.command.CommandArgument;
23 import de.smartics.maven.issue.command.CommandResult.Page;
24 import de.smartics.maven.issue.command.ProductNavigationCommand;
25
26 /**
27 * Implementation of the {@link ProductNavigationCommand} for Bugzilla.
28 * <p>
29 * <code>http://server/editversions.cgi?action=add&product=[PRODUCT]</code>
30 * </p>
31 */
32 public final class BugzillaProductNavigationCommand extends
33 AbstractCommand<ProductNavigationCommand> implements
34 ProductNavigationCommand
35 {
36 // ********************************* Fields *********************************
37
38 // --- constants ------------------------------------------------------------
39
40 /**
41 * The class version identifier.
42 * <p>
43 * The value of this constant is {@value}.
44 * </p>
45 */
46 private static final long serialVersionUID = 1L;
47
48 // --- members --------------------------------------------------------------
49
50 // ****************************** Initializer *******************************
51
52 // ****************************** Constructors ******************************
53
54 /**
55 * Convenience constructor executing the <code>add</code> action.
56 *
57 * @param service the service on the command target to call.
58 * @param product the product of the context to navigate.
59 */
60 protected BugzillaProductNavigationCommand(final String service,
61 final CommandArgument<ProductNavigationCommand> product)
62 {
63 this(service, CommandArgument.create(
64 ProductNavigationCommand.Parameter.ACTION, "add"), product);
65 }
66
67 /**
68 * Default constructor.
69 *
70 * @param service the service on the command target to call.
71 * @param action the action to execute.
72 * @param product the product of the context to navigate.
73 */
74 protected BugzillaProductNavigationCommand(final String service,
75 final CommandArgument<ProductNavigationCommand> action,
76 final CommandArgument<ProductNavigationCommand> product)
77 {
78 super(service, attachDefaulArguments(action, product));
79 }
80
81 // ****************************** Inner Classes *****************************
82
83 // ********************************* Methods ********************************
84
85 // --- init -----------------------------------------------------------------
86
87 private static List<CommandArgument<ProductNavigationCommand>> attachDefaulArguments(
88 final CommandArgument<ProductNavigationCommand> action,
89 final CommandArgument<ProductNavigationCommand> product)
90 {
91 final List<CommandArgument<ProductNavigationCommand>> allArguments =
92 new ArrayList<CommandArgument<ProductNavigationCommand>>(2);
93 allArguments.add(action);
94 allArguments.add(product);
95 return allArguments;
96 }
97
98 // --- get&set --------------------------------------------------------------
99
100 // --- business -------------------------------------------------------------
101
102 /**
103 * Signals that token is required to be read.
104 *
105 * @return <code>true</code>.
106 */
107 protected boolean isTokenRequiredToRead()
108 {
109 return true;
110 }
111
112 // --- object basics --------------------------------------------------------
113
114 /**
115 * {@inheritDoc}
116 *
117 * @see de.smartics.maven.issue.command.AbstractCommand#checkExpectation(de.smartics.maven.issue.command.CommandResult.Page)
118 */
119 @Override
120 protected Expectation checkExpectation(final Page page)
121 {
122 return Expectation.NO_EXPECTATION;
123 }
124
125 /**
126 * {@inheritDoc}
127 *
128 * @see de.smartics.maven.issue.command.AbstractCommand#getCommandResultDescription(Page,Expectation)
129 */
130 @Override
131 protected String getCommandResultDescription(final Page page,
132 final Expectation expectation)
133 {
134 return null;
135 }
136 }