KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * File : $Source: /usr/local/cvs/opencms/src/org/opencms/workplace/explorer/CmsNewResourceXmlContent.java,v $
3  * Date : $Date: 2006/03/28 16:48:21 $
4  * Version: $Revision: 1.15 $
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.I_CmsResourceType;
35 import org.opencms.jsp.CmsJspActionElement;
36 import org.opencms.main.OpenCms;
37 import org.opencms.workplace.CmsWorkplaceMessages;
38 import org.opencms.workplace.CmsWorkplaceSettings;
39
40 import java.util.List JavaDoc;
41
42 import javax.servlet.http.HttpServletRequest JavaDoc;
43 import javax.servlet.http.HttpServletResponse JavaDoc;
44 import javax.servlet.jsp.JspException JavaDoc;
45 import javax.servlet.jsp.PageContext JavaDoc;
46
47 /**
48  * The new resource xmlcontent dialog handles the creation of a xmlcontent.<p>
49  *
50  * The following files use this class:
51  * <ul>
52  * <li>/commons/newresource_xmlcontent.jsp
53  * </ul>
54  * <p>
55  *
56  * @author Michael Emmerich
57  *
58  * @version $Revision: 1.15 $
59  *
60  * @since 6.0.0
61  */

62 public class CmsNewResourceXmlContent extends CmsNewResource {
63
64     /**
65      * Public constructor with JSP action element.<p>
66      *
67      * @param jsp an initialized JSP action element
68      */

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

81     public CmsNewResourceXmlContent(PageContext JavaDoc context, HttpServletRequest JavaDoc req, HttpServletResponse JavaDoc res) {
82
83         this(new CmsJspActionElement(context, req, res));
84     }
85
86     /**
87      * Creates the resource using the specified resource name and the newresourcetype parameter.<p>
88      *
89      * @throws JspException if inclusion of error dialog fails
90      */

91     public void actionCreateResource() throws JspException JavaDoc {
92
93         try {
94             // calculate the new resource Title property value
95
String JavaDoc title = computeNewTitleProperty();
96             // create the full resource name
97
String JavaDoc fullResourceName = computeFullResourceName();
98             // eventually append ".html" suffix to new file if not present
99
fullResourceName = appendSuffixHtml(fullResourceName, false);
100             // create the Title and Navigation properties if configured
101
I_CmsResourceType resType = OpenCms.getResourceManager().getResourceType(getParamNewResourceType());
102             List JavaDoc properties = createResourceProperties(fullResourceName, resType.getTypeName(), title);
103             // create the folder
104
getCms().createResource(fullResourceName, resType.getTypeId(), null, properties);
105             setParamResource(fullResourceName);
106             setResourceCreated(true);
107         } catch (Throwable JavaDoc e) {
108             // error creating file, show error dialog
109
includeErrorpage(this, e);
110         }
111     }
112
113     /**
114      * @see org.opencms.workplace.CmsWorkplace#initWorkplaceRequestValues(org.opencms.workplace.CmsWorkplaceSettings, javax.servlet.http.HttpServletRequest)
115      */

116     protected void initWorkplaceRequestValues(CmsWorkplaceSettings settings, HttpServletRequest JavaDoc request) {
117
118         // fill the parameter values in the get/set methods
119
fillParamValues(request);
120         // set the dialog type
121
setParamDialogtype(DIALOG_TYPE);
122         // set the action for the JSP switch
123
if (DIALOG_OK.equals(getParamAction())) {
124             setAction(ACTION_OK);
125         } else if (DIALOG_SUBMITFORM.equals(getParamAction())) {
126             setAction(ACTION_SUBMITFORM);
127         } else if (DIALOG_NEWFORM.equals(getParamAction())) {
128             setAction(ACTION_NEWFORM);
129             String JavaDoc title = CmsWorkplaceMessages.getNewResourceTitle(this, getParamNewResourceType());
130             setParamTitle(title);
131         } else if (DIALOG_CANCEL.equals(getParamAction())) {
132             setAction(ACTION_CANCEL);
133         } else {
134             setAction(ACTION_DEFAULT);
135             // build title for new resource dialog
136
setParamTitle(key(Messages.GUI_NEWRESOURCE_XMLCONTENT_0));
137         }
138     }
139 }
Popular Tags