KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opencms > workplace > explorer > CmsNewResourcePointer


1 /*
2  * File : $Source: /usr/local/cvs/opencms/src/org/opencms/workplace/explorer/CmsNewResourcePointer.java,v $
3  * Date : $Date: 2006/03/27 14:52:30 $
4  * Version: $Revision: 1.14 $
5  *
6  * This library is part of OpenCms -
7  * the Open Source Content Mananagement System
8  *
9  * Copyright (c) 2005 Alkacon Software GmbH (http://www.alkacon.com)
10  *
11  * This library is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Lesser General Public
13  * License as published by the Free Software Foundation; either
14  * version 2.1 of the License, or (at your option) any later version.
15  *
16  * This library is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  * Lesser General Public License for more details.
20  *
21  * For further information about Alkacon Software GmbH, please see the
22  * company website: http://www.alkacon.com
23  *
24  * For further information about OpenCms, please see the
25  * project website: http://www.opencms.org
26  *
27  * You should have received a copy of the GNU Lesser General Public
28  * License along with this library; if not, write to the Free Software
29  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30  */

31
32 package org.opencms.workplace.explorer;
33
34 import org.opencms.file.types.CmsResourceTypePointer;
35 import org.opencms.jsp.CmsJspActionElement;
36 import org.opencms.workplace.CmsWorkplaceSettings;
37
38 import java.util.List JavaDoc;
39
40 import javax.servlet.http.HttpServletRequest JavaDoc;
41 import javax.servlet.http.HttpServletResponse JavaDoc;
42 import javax.servlet.jsp.JspException JavaDoc;
43 import javax.servlet.jsp.PageContext JavaDoc;
44
45 /**
46  * The new resource pointer dialog handles the creation of a pointer (external link).<p>
47  *
48  * The following files use this class:
49  * <ul>
50  * <li>/commons/newresource_pointer.jsp
51  * </ul>
52  * <p>
53  *
54  * @author Andreas Zahner
55  *
56  * @version $Revision: 1.14 $
57  *
58  * @since 6.0.0
59  */

60 public class CmsNewResourcePointer extends CmsNewResource {
61
62     /** Request parameter name for the link target. */
63     public static final String JavaDoc PARAM_LINKTARGET = "linktarget";
64
65     private String JavaDoc m_paramLinkTarget;
66
67     /**
68      * Public constructor with JSP action element.<p>
69      *
70      * @param jsp an initialized JSP action element
71      */

72     public CmsNewResourcePointer(CmsJspActionElement jsp) {
73
74         super(jsp);
75     }
76
77     /**
78      * Public constructor with JSP variables.<p>
79      *
80      * @param context the JSP page context
81      * @param req the JSP request
82      * @param res the JSP response
83      */

84     public CmsNewResourcePointer(PageContext JavaDoc context, HttpServletRequest JavaDoc req, HttpServletResponse JavaDoc res) {
85
86         this(new CmsJspActionElement(context, req, res));
87     }
88
89     /**
90      * Creates the new pointer resource.<p>
91      *
92      * @throws JspException if inclusion of error dialog fails
93      */

94     public void actionCreateResource() throws JspException JavaDoc {
95
96         try {
97             // calculate the new resource Title property value
98
String JavaDoc title = computeNewTitleProperty();
99             // create the full resource name
100
String JavaDoc fullResourceName = computeFullResourceName();
101             // create the Title and Navigation properties if configured
102
List JavaDoc properties = createResourceProperties(
103                 fullResourceName,
104                 CmsResourceTypePointer.getStaticTypeName(),
105                 title);
106             // the link target
107
String JavaDoc linkTarget = getParamLinkTarget();
108             if (linkTarget == null) {
109                 linkTarget = "";
110             }
111             // create the pointer
112
getCms().createResource(
113                 fullResourceName,
114                 CmsResourceTypePointer.getStaticTypeId(),
115                 linkTarget.getBytes(),
116                 properties);
117             setParamResource(fullResourceName);
118             setResourceCreated(true);
119         } catch (Throwable JavaDoc e) {
120             // error creating pointer, show error dialog
121
setParamMessage(Messages.get().getBundle(getLocale()).key(Messages.ERR_CREATE_LINK_0));
122             includeErrorpage(this, e);
123         }
124
125     }
126
127     /**
128      * Returns the link target request parameter value.<p>
129      *
130      * @return the link target request parameter value
131      */

132     public String JavaDoc getParamLinkTarget() {
133
134         return m_paramLinkTarget;
135     }
136
137     /**
138      * Sets the link target request parameter value.<p>
139      *
140      * @param linkTarget the link target request parameter value
141      */

142     public void setParamLinkTarget(String JavaDoc linkTarget) {
143
144         m_paramLinkTarget = linkTarget;
145     }
146
147     /**
148      * @see org.opencms.workplace.CmsWorkplace#initWorkplaceRequestValues(org.opencms.workplace.CmsWorkplaceSettings, javax.servlet.http.HttpServletRequest)
149      */

150     protected void initWorkplaceRequestValues(CmsWorkplaceSettings settings, HttpServletRequest JavaDoc request) {
151
152         // fill the parameter values in the get/set methods
153
fillParamValues(request);
154         // set the dialog type
155
setParamDialogtype(DIALOG_TYPE);
156         // set the action for the JSP switch
157
if (DIALOG_OK.equals(getParamAction())) {
158             setAction(ACTION_OK);
159         } else if (DIALOG_CANCEL.equals(getParamAction())) {
160             setAction(ACTION_CANCEL);
161         } else {
162             setAction(ACTION_DEFAULT);
163             // build title for new resource dialog
164
setParamTitle(key(Messages.GUI_NEWRESOURCE_POINTER_0));
165         }
166     }
167
168 }
Popular Tags