BrightSide Workbench Full Report + Source Code
IConstructor.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.elephant.context;
19 
20 import java.io.File;
21 import java.io.IOException;
22 import java.io.PrintWriter;
23 import java.util.Map;
24 import javax.servlet.ServletException;
25 import javax.servlet.ServletRequest;
26 import javax.servlet.ServletResponse;
27 import javax.servlet.http.HttpServletRequest;
28 import javax.servlet.http.HttpServletResponse;
29 import org.turro.action.Parameters;
30 import org.turro.elephant.impl.util.Localizer;
31 import org.turro.elephant.web.ElContext;
32 import org.turro.elephant.web.context.WebContext;
33 import org.turro.plugin.contacts.IContact;
34 
42 public interface IConstructor {
43 
44  public boolean isHeadless();
49  public void setRequest(ServletRequest request);
54  public void setResponse(ServletResponse response);
59  public HttpServletRequest getRequest();
64  public HttpServletResponse getResponse();
71  public void setRenderingContext(ElContext context);
72  public void forceIsAContext(ElContext context);
73  public boolean isOriginal();
74 
75  public String getUniqueId();
76 
84  public boolean isFileInternal(File file);
91  public Object findAttribute(String key);
97  public Object getApplicationAttribute(String key);
104  public Object getSessionAttribute(String key);
105  public Map<String, Object> getSessionAttributeMap(String prefix);
112  public Object getRequestAttribute(String key);
118  public void setApplicationAttribute(String key, Object value);
124  public void setSessionAttribute(String key, Object value);
130  public void setRequestAttribute(String key, Object value);
135  public void removeApplicationAttribute(String key);
140  public void removeSessionAttribute(String key);
145  public void removeRequestAttribute(String key);
151  public void setLastReferringContext(String context);
158  public String getLastReferringContext();
163  public void addHeader(String header);
168  public void addCSS(String cssFile);
173  public void addMeta(String meta);
178  public void addJavaScript(String jsFile);
179  public void addOnLoadedJavaScript(String script);
188  public void startConstruction() throws ServletException, IOException;
189  public void startBody();
190  public void endBody();
191  public void setStopper(String stopper);
202  public void includeContent(String path) throws ServletException, IOException;
213  public void renderContext(String path, String stopper) throws ServletException, IOException;
221  public void redirect(String path) throws IOException;
222  public void navigateBack() throws IOException;
223  public void reload() throws IOException;
229  public PrintWriter getOut() throws IOException;
230  public void setOut(PrintWriter out) throws IOException;
231  public void closeOut() throws IOException;
232  public void setPageRendering(boolean value);
233  public void setNullOutput(boolean value);
234  public void setOutputToString();
235  public String getOutputString();
236  public void processOutput(String text) throws ServletException, IOException;
237  public void processOutput(PrintWriter out, String text) throws ServletException, IOException;
238  public void changeCssHeaders(String from, String to);
239 
240 // /**
241 // * This method should return selected context's children. Path is a relative path
242 // * to any context. Level controls which context in path will be selected, for example:
243 // *
244 // * path = /docs/api/elephant
245 // *
246 // * level = 0, returns '/' children.
247 // * level = 1, returns '/docs' children.
248 // * level = 2, returns '/docs/api' children.
249 // *
250 // * and so on.
251 // * @param from Relative context path.
252 // * @param level Context level, starting with root = 0.
253 // * @return Selected context's children.
254 // */
255 // public IContext[] getContexts(String from, int level);
261  public String encodeURL(String url);
267  public String decodeURL(String url);
274  public String getValidUrl(String name);
281  public String getValidFileName(String name);
292  public IContact getUser();
293  public boolean isOutsider();
300  public boolean isInRole(String role);
301  public boolean hasAnyRoleKey(String role);
302  public String getParameter(String param);
303  public String getParameter(String param, boolean decode);
304  public String[] getParameterValues(String param);
306  public String getContextParameter();
307  public String getIdelParameter();
308  public String getActionParameter();
309  //public boolean checkTemporalSession(HttpServletRequest request);
310  public void invalidateSession();
311  public void setMaxInactiveInterval(int i);
312 
313  public boolean canWebAdminister();
314  public boolean isWebAdministering();
315  public void setWebAdministering(boolean value);
316 
321  public boolean fileExists(String filePath);
322 
323  public String getTemplateRoot();
324 
325  /* Repositories */
326 
327  public static String currentRepository(IConstructor constructor) {
328  String repository = WebContext.relativeRepository();
329  if(constructor != null) {
330  ElContext ctx = constructor.getRenderingContext();
331  if(ctx != null) {
332  repository = ctx.getRepositoryPath();
333  }
334  }
335  return ElephantContext.getRootWebPath() + repository;
336  }
337 
338  public static String globalRepository() {
340  }
341 
342 }
void setLastReferringContext(String context)
void setApplicationAttribute(String key, Object value)
void setRequest(ServletRequest request)
String[] getParameterValues(String param)
Map< String, Object > getSessionAttributeMap(String prefix)
void changeCssHeaders(String from, String to)
void addOnLoadedJavaScript(String script)
void setRequestAttribute(String key, Object value)
Object getApplicationAttribute(String key)
void setRenderingContext(ElContext context)
void setSessionAttribute(String key, Object value)
boolean fileExists(String filePath)
void forceIsAContext(ElContext context)
void renderContext(String path, String stopper)
static String currentRepository(IConstructor constructor)
void setResponse(ServletResponse response)