BrightSide Workbench Full Report + Source Code
UserCommand.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2018 Lluis TurrĂ³ Cutiller <http://www.turro.org/>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Affero General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Affero General Public License for more details.
14  *
15  * You should have received a copy of the GNU Affero General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 package org.turro.elephant.menu;
20 
21 import javax.servlet.ServletContext;
22 import javax.servlet.http.HttpServletRequest;
23 import javax.servlet.http.HttpServletResponse;
24 import org.amic.util.string.Strings;
25 import org.turro.action.Actions;
26 import org.turro.elephant.direct.DirectContents;
27 import org.turro.elephant.direct.DirectContent;
28 import org.turro.collections.KeyValueMap;
29 import org.turro.elephant.context.ElephantContext;
30 import org.turro.elephant.direct.IDirectContent;
31 
36 @Deprecated
37 //@DirectContent(identifier="user-command")
38 public class UserCommand implements IDirectContent {
39 
40  public static String createURL(IUserAction userAction) {
41  if(userAction.isValid()) {
42  String exrino = Actions.createRightNowAction("idAction=" + userAction.getId());
45  "?" + exrino;
46  }
47  return null;
48  }
49 
50  public static String getIdentifier() {
51  return UserCommand.class.getAnnotation(DirectContent.class).identifier();
52  }
53 
54  @Override
55  public boolean itsMe(String id) {
56  return getIdentifier().equals(id);
57  }
58 
59  @Override
60  public boolean myTurn(HttpServletRequest request) {
61  return DirectContents.isYourTurn(request, getIdentifier());
62  }
63 
64  @Override
65  public void execute(ServletContext context, HttpServletRequest request, HttpServletResponse response) {
66  KeyValueMap map = Actions.getRightNowAction(ElephantContext.getConstructor(request, response));
67  String idAction = map.get("idAction");
68  if(!Strings.isBlank(idAction)) {
69  UserMenu.executeAction(idAction);
70  }
71  }
72 
73 }
static KeyValueMap getRightNowAction(IConstructor constructor)
Definition: Actions.java:341
static String createRightNowAction(String values)
Definition: Actions.java:312
static IConstructor getConstructor(HttpServletRequest request, HttpServletResponse response)
static boolean isYourTurn(HttpServletRequest request, String path)
void execute(ServletContext context, HttpServletRequest request, HttpServletResponse response)
static String createURL(IUserAction userAction)
boolean myTurn(HttpServletRequest request)
static void executeAction(String idAction)