Source code: com/obinary/cms/taglibs/Init.java
1 /**
2 *
3 * Magnolia and its source-code is licensed under the LGPL.
4 * You may copy, adapt, and redistribute this file for commercial or non-commercial use.
5 * When copying, adapting, or redistributing this document in keeping with the guidelines above,
6 * you are required to provide proper attribution to obinary.
7 * If you reproduce or distribute the document without making any substantive modifications to its content,
8 * please use the following attribution line:
9 *
10 * Copyright 1993-2003 obinary Ltd. (http://www.obinary.com) All rights reserved.
11 *
12 * */
13
14
15
16
17
18 package com.obinary.cms.taglibs;
19
20
21 import com.obinary.cms.util.Resource;
22 import com.obinary.cms.Aggregator;
23 import com.obinary.cms.beans.ServerInfo;
24 import com.obinary.cms.core.Content;
25
26 import javax.servlet.jsp.tagext.TagSupport;
27 import javax.servlet.jsp.PageContext;
28 import javax.servlet.http.HttpServletRequest;
29 import javax.servlet.http.HttpServletResponse;
30
31
32 /**
33 * User: sameercharles
34 * Date: Apr 28, 2003
35 * Time: 11:20:59 AM
36 * @author Sameer Charles
37 * @version 1.0
38 */
39
40
41 public class Init extends TagSupport {
42
43 private HttpServletRequest req;
44
45
46 /**
47 * <p>starts init tag</p>
48 *
49 * @return int
50 */
51 public int doStartTag() {
52 this.req = (HttpServletRequest)pageContext.getRequest();
53 pageContext.setAttribute(Aggregator.CURRENT_ACTPAGE,Resource.getCurrentActivePage(this.req),PageContext.REQUEST_SCOPE);
54 pageContext.setAttribute(Aggregator.HIERARCHY_MANAGER,Resource.getHierarchyManager(this.req),PageContext.REQUEST_SCOPE);
55 checkRedirect();
56 return SKIP_BODY;
57 }
58
59
60
61 /**
62 * <p>end init</p>
63 *
64 * @return int
65 */
66 public int doEndTag() {
67 return EVAL_PAGE;
68 }
69
70 private void checkRedirect() {
71 Content actpage = Resource.getCurrentActivePage(this.req);
72 String redirectURL = "";
73 try {
74 redirectURL = actpage.getAtom("redirectURL").getString();
75 if (!redirectURL.equals("")) {
76 if (!ServerInfo.isAdmin() || Resource.showPreview(this.req)) ((HttpServletResponse)pageContext.getResponse()).sendRedirect(redirectURL);
77 }
78 }
79 catch (Exception e) {}
80 }
81
82
83
84
85
86
87 }