📄 cmsadminprojectnew.java
字号:
/*
* File : $Source: /usr/local/cvs/opencms/src-modules/com/opencms/workplace/CmsAdminProjectNew.java,v $
* Date : $Date: 2005/06/27 23:22:07 $
* Version: $Revision: 1.5 $
*
* 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 org.opencms.file.CmsGroup;
import org.opencms.file.CmsObject;
import org.opencms.file.CmsProject;
import org.opencms.file.CmsRequestContext;
import org.opencms.file.CmsResource;
import org.opencms.main.CmsException;
import org.opencms.main.CmsLog;
import org.opencms.main.OpenCms;
import org.opencms.workplace.CmsWorkplace;
import com.opencms.core.I_CmsSession;
import com.opencms.legacy.CmsXmlTemplateLoader;
import com.opencms.template.CmsXmlTemplateFile;
import java.util.Collections;
import java.util.Hashtable;
import java.util.List;
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.5 $ $Date: 2005/06/27 23:22:07 $
* @see com.opencms.workplace.CmsXmlWpTemplateFile
*
* @deprecated Will not be supported past the OpenCms 6 release.
*/
public class CmsAdminProjectNew extends CmsWorkplaceDefault {
/** 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(CmsLog.getLog(this).isDebugEnabled() && C_DEBUG) {
CmsLog.getLog(this).debug("Getting content of element " + ((elementName==null)?"<root>":elementName));
CmsLog.getLog(this).debug("Template file is: " + templateFile);
CmsLog.getLog(this).debug("Selected template section is: " + ((templateSelector==null)?"<default>":templateSelector));
}
I_CmsSession session = CmsXmlTemplateLoader.getSession(cms.getRequestContext(), true);
CmsRequestContext reqCont = cms.getRequestContext();
CmsXmlLanguageFile lang = new CmsXmlLanguageFile(cms);
// clear session values on first load
String initial = (String)parameters.get(CmsWorkplaceDefault.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.readProject(CmsProject.ONLINE_PROJECT_ID));
}
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(CmsWorkplaceDefault.C_PARA_RESOURCE);
if (fileToGo == null){
fileToGo = (String)session.getValue("newProjectCallingFrom");
} else {
CmsResource resource = cms.readResource(fileToGo);
if (resource.isFolder() && !resource.getRootPath().endsWith("/")) {
fileToGo += "/";
}
}
String lasturl = (String)parameters.get("lasturl");
if (lasturl == null){
lasturl = (String)session.getValue("lasturl");
}
newName = (String)parameters.get(CmsWorkplaceDefault.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.isManagerOfProject()){
// 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=" + CmsWorkplace.VFS_PATH_WORKPLACE + "administration/project/");
xmlTemplateDocument.setData("myUrl","index.html");
xmlTemplateDocument.setData("dontDoIt", "");
xmlTemplateDocument.setData("doThis","");
}
xmlTemplateDocument.setData("onlineId", "" + CmsProject.ONLINE_PROJECT_ID);
newGroup = (String)parameters.get(CmsWorkplaceDefault.C_PROJECTNEW_GROUP);
newDescription = (String)parameters.get(CmsWorkplaceDefault.C_PROJECTNEW_DESCRIPTION);
newManagerGroup = (String)parameters.get(CmsWorkplaceDefault.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 = CmsProject.PROJECT_TYPE_NORMAL;
newType = "";
} else {
projectType = CmsProject.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;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -