BrightSide Workbench Full Report + Source Code
DossierInterceptor.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2011 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 package org.turro.dossier.command;
19 
20 import java.io.IOException;
21 import org.turro.action.AbstractInterceptor;
22 import org.turro.action.Parameters;
23 import org.turro.annotation.ElephantInterceptor;
24 import org.turro.collections.KeyValueMap;
25 import org.turro.dossier.zul.menu.DossierMenu;
26 import org.turro.elephant.context.Application;
27 import org.turro.elephant.context.ElephantContext;
28 import org.turro.elephant.context.IConstructor;
29 import org.turro.string.Strings;
30 
35 @ElephantInterceptor
37 
38  @Override
39  protected boolean doExecuteWeb(IConstructor constructor, String goTo, KeyValueMap kvm) throws IOException {
40  if("dossier".equals(goTo)) {
41  String path = ElephantContext.getEntityWebContext("/dossier");
42  if(Strings.isBlank(path)) {
43  path = "/user/mydossiers";
44  }
45  constructor.redirect(Parameters.path(path)
46  .add("item", kvm.get("dossierId"))
47  .plain());
48  constructor.redirect(path + "?item=" + kvm.get(Long.class, "dossierId"));
49  return true;
50  } else if("project".equals(goTo)) {
51  String path = ElephantContext.getEntityWebContext("/project");
52  if(Strings.isBlank(path)) {
53  path = "/user/myprojects";
54  }
55  constructor.redirect(Parameters.path(path)
56  .add("item", kvm.get("projectId"))
57  .plain());
58  return true;
59  } else if("axproject".equals(goTo)) {
60  String path = ElephantContext.getEntityWebContext("/axproject");
61  if(Strings.isBlank(path)) {
62  path = ElephantContext.getEntityWebContext("/project");
63  if(!Strings.isBlank(path)) {
64  path = path + "/alliance";
65  }
66  }
67  if(Strings.isBlank(path)) {
68  path = "/user/alliance/projects";
69  }
70  constructor.redirect(Parameters.path(path)
71  .add("serverDomain", kvm.get("server"))
72  .add("service", "/axserver")
73  .add("item", kvm.get("axprojectId"))
74  .plain());
75  return true;
76  }
77  return false;
78  }
79 
80  @Override
81  protected boolean doExecuteApp(Application application, String goTo, KeyValueMap kvm) {
82  if("issue".equals(goTo)) {
83  if(Application.getApplication().isInRole("issue:edit")) {
84  DossierMenu.showIssue(kvm.get(Long.class, "issueId"));
85  }
86  return true;
87  } else if("dossier".equals(goTo)) {
88  if(Application.getApplication().isInRole("dossier:edit")) {
89  DossierMenu.showDossier(kvm.get(Long.class, "dossierId"));
90  }
91  return true;
92  } else if("project".equals(goTo)) {
93  if(Application.getApplication().isInRole("dossier:edit")) {
94  DossierMenu.showDossier(kvm.get(Long.class, "projectId"));
95  }
96  return true;
97  } else if("myissues".equals(goTo)) {
99  return true;
100  }
101  return false;
102  }
103 
104 }
Parameters add(String key, Object value)
Definition: Parameters.java:48
static Parameters path(String path)
boolean doExecuteWeb(IConstructor constructor, String goTo, KeyValueMap kvm)
boolean doExecuteApp(Application application, String goTo, KeyValueMap kvm)
static void showDossier(Dossier dossier)
static String getEntityWebContext(String path)