📄 cmsadminprojectnew.java
字号:
/*
* File : $Source: /usr/local/cvs/opencms/src/com/opencms/workplace/CmsAdminProjectNew.java,v $
* Date : $Date: 2003/02/15 11:14:53 $
* Version: $Revision: 1.73 $
*
* This library is part of OpenCms -
* the Open Source Content Mananagement System
*
* Copyright (C) 2001 The OpenCms Group
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* For further information about OpenCms, please see the
* OpenCms Website: http://www.opencms.org
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package com.opencms.workplace;
import com.opencms.boot.I_CmsLogChannels;
import com.opencms.core.A_OpenCms;
import com.opencms.core.CmsException;
import com.opencms.core.I_CmsConstants;
import com.opencms.core.I_CmsSession;
import com.opencms.file.CmsGroup;
import com.opencms.file.CmsObject;
import com.opencms.file.CmsProject;
import com.opencms.file.CmsRequestContext;
import com.opencms.file.I_CmsRegistry;
import com.opencms.template.CmsXmlTemplateFile;
import com.opencms.util.Utils;
import java.util.Hashtable;
import java.util.StringTokenizer;
import java.util.Vector;
/**
* Template class for displaying OpenCms workplace admin project screens.
* <P>
*
* @author Andreas Schouten
* @author Michael Emmerich
* @author Mario Stanke
* @version $Revision: 1.73 $ $Date: 2003/02/15 11:14:53 $
* @see com.opencms.workplace.CmsXmlWpTemplateFile
*/
public class CmsAdminProjectNew extends CmsWorkplaceDefault implements I_CmsConstants {
/** Session key */
private static String C_NEWNAME = "new_project_name";
/** Session key */
private static String C_NEWDESCRIPTION = "new_project_description";
/** Session key */
private static String C_NEWGROUP = "new_project_group";
/** Session key */
private static String C_NEWMANAGERGROUP = "new_project_managergroup";
/** Session key */
private static String C_NEWFOLDER = "new_project_folder";
/** Session key */
private static String C_NEWTYPE = "projecttype";
/** Session key */
private static String C_NEWRESOURCES = "ALLRES";
/** Session key */
private static String C_NEWCHANNELS = "ALLCHAN";
/** Check whether some of the resources are redundant because a superfolder has also
* been selected.
*
* @param resources containts the full pathnames of all the resources
* @return A vector with the same resources, but the paths in the return value are disjoint
*/
private void checkRedundancies(Vector resources) {
int i, j;
if(resources == null) {
return ;
}
Vector redundant = new Vector();
int n = resources.size();
if(n < 2) {
// no check needed, because there is only one resource or
// no resources selected, return empty Vector
return ;
}
for(i = 0;i < n;i++) {
redundant.addElement(new Boolean(false));
}
for(i = 0;i < n - 1;i++) {
for(j = i + 1;j < n;j++) {
if(((String)resources.elementAt(i)).length() <
((String)resources.elementAt(j)).length()) {
if(((String)resources.elementAt(j)).startsWith((String)resources.elementAt(i))) {
redundant.setElementAt(new Boolean(true), j);
}
}
else {
if(((String)resources.elementAt(i)).startsWith((String)resources.elementAt(j))) {
redundant.setElementAt(new Boolean(true), i);
}
}
}
}
for(i = n - 1;i >= 0;i--) {
if(((Boolean)redundant.elementAt(i)).booleanValue()) {
resources.removeElementAt(i);
}
}
}
/**
* Gets the content of a defined section in a given template file and its subtemplates
* with the given parameters.
*
* @see #getContent(CmsObject, String, String, Hashtable, String)
* @param cms CmsObject Object for accessing system resources.
* @param templateFile Filename of the template file.
* @param elementName Element name of this template in our parent template.
* @param parameters Hashtable with all template class parameters.
* @param templateSelector template section that should be processed.
*/
public byte[] getContent(CmsObject cms, String templateFile, String elementName,
Hashtable parameters, String templateSelector) throws CmsException {
if(I_CmsLogChannels.C_PREPROCESSOR_IS_LOGGING && A_OpenCms.isLogging() && C_DEBUG) {
A_OpenCms.log(C_OPENCMS_DEBUG, this.getClassName()
+ "getting content of element " + ((elementName == null) ? "<root>" : elementName));
A_OpenCms.log(C_OPENCMS_DEBUG, this.getClassName() + "template file is: "
+ templateFile);
A_OpenCms.log(C_OPENCMS_DEBUG, this.getClassName() + "selected template section is: "
+ ((templateSelector == null) ? "<default>" : templateSelector));
}
I_CmsSession session = cms.getRequestContext().getSession(true);
CmsRequestContext reqCont = cms.getRequestContext();
CmsXmlLanguageFile lang = new CmsXmlLanguageFile(cms);
// flag for extended features in the editor, e.g. list of external links
I_CmsRegistry registry = cms.getRegistry();
boolean extendedNavigation = "on".equals(registry.getSystemValue("extendedNavigation"));
// clear session values on first load
String initial = (String)parameters.get(C_PARA_INITIAL);
if(initial != null) {
// remove all session values
session.removeValue(C_NEWNAME);
session.removeValue(C_NEWGROUP);
session.removeValue(C_NEWDESCRIPTION);
session.removeValue(C_NEWMANAGERGROUP);
session.removeValue(C_NEWFOLDER);
session.removeValue(C_NEWRESOURCES);
session.removeValue(C_NEWCHANNELS);
session.removeValue(C_NEWTYPE);
session.removeValue("lasturl");
session.removeValue("newProjectCallingFrom");
reqCont.setCurrentProject(cms.onlineProject().getId());
}
String newName, newGroup, newDescription, newManagerGroup;
int projectType = 0;
String newType = new String();
String action = new String();
action = (String)parameters.get("action");
CmsXmlTemplateFile xmlTemplateDocument = getOwnTemplateFile(cms, templateFile,
elementName, parameters, templateSelector);
//look if we come from the explorer view
String fileToGo = (String)parameters.get("file");
if (fileToGo == null){
fileToGo = (String)session.getValue("newProjectCallingFrom");
}
String lasturl = (String)parameters.get("lasturl");
if (lasturl == null){
lasturl = (String)session.getValue("lasturl");
}
newName = (String)parameters.get(C_PROJECTNEW_NAME);
if(newName == null) {
newName = (String)session.getValue(C_NEWNAME);
}
String errorTemplateAddOn = "";
if (fileToGo != null){
// this is from the explorer view
if((!cms.getRequestContext().isProjectManager()) && (!cms.isAdmin())){
// user has no rights to create a project
return startProcessing(cms, xmlTemplateDocument, elementName,parameters, "norigths");
}
errorTemplateAddOn = "explorer";
session.putValue("newProjectCallingFrom", fileToGo);
xmlTemplateDocument.setData("pathCorrection","");
xmlTemplateDocument.setData("backButton",lasturl);
xmlTemplateDocument.setData("myUrl","resource_to_project.html");
xmlTemplateDocument.setData("dontDoIt", " //");
// we have to put the file in the box and set the projectname
xmlTemplateDocument.setData("doThis","addFolder(document.PROJECTNEW.new_ressources,'"+fileToGo+"');");
if (newName == null){
newName = getProjectName(cms,fileToGo);
}
}else{
// this is from the administration view
xmlTemplateDocument.setData("pathCorrection","../../");
xmlTemplateDocument.setData("backButton","../../../action/administration_content_top.html?sender=/system/workplace/administration/project/");
xmlTemplateDocument.setData("myUrl","index.html");
xmlTemplateDocument.setData("dontDoIt", "");
xmlTemplateDocument.setData("doThis","");
}
xmlTemplateDocument.setData("onlineId", "" + cms.onlineProject().getId());
newGroup = (String)parameters.get(C_PROJECTNEW_GROUP);
newDescription = (String)parameters.get(C_PROJECTNEW_DESCRIPTION);
newManagerGroup = (String)parameters.get(C_PROJECTNEW_MANAGERGROUP);
String allResources = (String)parameters.get(C_NEWRESOURCES);
String allChannels = (String)parameters.get(C_NEWCHANNELS);
newType = (String)parameters.get(C_NEWTYPE);
// if there are still values in the session (like after an error), use them
if(newGroup == null) {
newGroup = (String)session.getValue(C_NEWGROUP);
}
if(newDescription == null) {
newDescription = (String)session.getValue(C_NEWDESCRIPTION);
}
if(newManagerGroup == null) {
newManagerGroup = (String)session.getValue(C_NEWMANAGERGROUP);
}
if(allResources == null) {
allResources = (String)session.getValue(C_NEWRESOURCES);
}
if(allChannels == null) {
allChannels = (String)session.getValue(C_NEWCHANNELS);
}
if(newType == null) {
newType = (String)session.getValue(C_NEWTYPE);
}
if(newName == null) {
newName = "";
}
if(newGroup == null) {
newGroup = "";
}
if(newDescription == null) {
newDescription = "";
}
if(newManagerGroup == null) {
newManagerGroup = "";
}
if(allResources == null) {
allResources = "";
}
if(allChannels == null) {
allChannels = "";
}
if(newType == null || "".equals(newType)) {
projectType = I_CmsConstants.C_PROJECT_TYPE_NORMAL;
newType = "";
} else {
projectType = I_CmsConstants.C_PROJECT_TYPE_TEMPORARY;
}
if(parameters.get("submitform") != null) {
// the form has just been submitted, store the data in the session
session.putValue(C_NEWNAME, newName);
session.putValue(C_NEWGROUP, newGroup);
session.putValue(C_NEWDESCRIPTION, newDescription);
session.putValue(C_NEWMANAGERGROUP, newManagerGroup);
session.putValue(C_NEWTYPE, newType);
session.putValue(C_NEWCHANNELS, allChannels);
if(newName.equals("") || newGroup.equals("") || newManagerGroup.equals("")
|| (allResources.equals("") && allChannels.equals(""))) {
templateSelector = "datamissing"+errorTemplateAddOn;
}
else {
session.putValue(C_NEWRESOURCES, allResources);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -