New features proposed III
sito <[email protected]>
| Newsgroups | gmane.comp.cms.infoglue.devel |
|---|---|
| Message-ID | <[email protected]> |
**********************************************************************************************
THIRD NEW FEATURE
**********************************************************************************************
When users are about to create a content in a site, they can choose
among all the content types available. Right now, even if their roles do
not allow you to create some content types, they are given those types
as options and when they try to create them, they fail.
They are not allowed to create the content, so "it works", but it is
confusing for our users, so we have made a small modification that
restricts the content types a user is offered, so only the ones allowed
by their roles are displayed (using
getAuthorizedContentTypeDefinitionVOList as an alternative to
getContentTypeDefinitionVOList if the content types are protected ).
File:
org.infoglue.cms.applications.contenttool.actions.ViewContentPropertiesAction.java
FULL CODE CONTENT:
**********************************************************************************************
/*
===============================================================================
*
* Part of the InfoGlue Content Management Platform (www.infoglue.org)
*
*
===============================================================================
*
* Copyright (C)
*
* This program is free software; you can redistribute it and/or modify
it under
* the terms of the GNU General Public License version 2, as published
by the
* Free Software Foundation. See the file LICENSE.html for more information.
*
* This program is distributed in the hope that it will be useful, but
WITHOUT
* ANY WARRANTY, including the implied warranty of MERCHANTABILITY or
FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
details.
*
* You should have received a copy of the GNU General Public License
along with
* this program; if not, write to the Free Software Foundation, Inc. /
59 Temple
* Place, Suite 330 / Boston, MA 02111-1307 / USA.
*
*
===============================================================================
*/
package org.infoglue.cms.applications.contenttool.actions;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Collections;
import org.apache.log4j.Logger;
import
org.infoglue.cms.applications.common.actions.InfoGluePropertiesAbstractAction;
import org.infoglue.cms.controllers.kernel.impl.simple.ContentController;
import
org.infoglue.cms.controllers.kernel.impl.simple.ContentTypeDefinitionController;
import org.infoglue.cms.controllers.kernel.impl.simple.LanguageController;
import org.infoglue.cms.entities.content.ContentVO;
import org.infoglue.cms.entities.management.ContentTypeDefinitionVO;
import com.opensymphony.module.propertyset.PropertySet;
import com.opensymphony.module.propertyset.PropertySetManager;
import org.infoglue.cms.applications.common.VisualFormatter;
import org.infoglue.cms.applications.common.actions.InfoGlueAbstractAction;
import
org.infoglue.cms.controllers.kernel.impl.simple.AccessRightController;
import
org.infoglue.cms.controllers.kernel.impl.simple.ContentControllerProxy;
import
org.infoglue.cms.controllers.kernel.impl.simple.ContentTypeDefinitionController;
import org.infoglue.cms.entities.content.ContentVO;
import org.infoglue.cms.exception.AccessConstraintException;
import org.infoglue.cms.util.AccessConstraintExceptionBuffer;
import org.infoglue.cms.util.CmsPropertyHandler;
import org.infoglue.cms.util.ConstraintExceptionBuffer;
import org.infoglue.cms.util.sorters.ReflectionComparator;
/**
* This class implements the action class for viewContentProperties.
* The use-case lets the user see all extra-properties for a content
*
* @author Mattias Bogeblad
*/
public class ViewContentPropertiesAction extends
InfoGluePropertiesAbstractAction
{
private final static Logger logger =
Logger.getLogger(ViewContentPropertiesAction.class.getName());
private static final long serialVersionUID = 1L;
private ContentVO contentVO = new ContentVO();
private PropertySet propertySet = null;
private List contentTypeDefinitionVOList = null;
private List languageVOList = null;
private String allowedContentTypeNames = null;
private String defaultContentTypeName = null;
private String initialLanguageId = null;
public ViewContentPropertiesAction()
{
}
//--------------------------------------------
// CHANGES : UIB - List of CTD permited
//--------------------------------------------
public List getContentTypeDefinitions() throws Exception
{
List contentTypeVOList = null;
String protectContentTypes =
CmsPropertyHandler.getProtectContentTypes();
if(protectContentTypes != null &&
protectContentTypes.equalsIgnoreCase("true"))
contentTypeVOList =
ContentTypeDefinitionController.getController().getAuthorizedContentTypeDefinitionVOList(this.getInfoGluePrincipal());
else
contentTypeVOList =
ContentTypeDefinitionController.getController().getContentTypeDefinitionVOList();
Collections.sort(contentTypeVOList, new
ReflectionComparator("name"));
return contentTypeVOList;
}
protected void initialize(Integer contentId) throws Exception
{
this.contentVO =
ContentController.getContentController().getContentVOWithId(contentId);
this.contentTypeDefinitionVOList =getContentTypeDefinitions();
//UIB COMMENT:
ContentTypeDefinitionController.getController().getContentTypeDefinitionVOList(ContentTypeDefinitionVO.CONTENT);
this.languageVOList =
LanguageController.getController().getLanguageVOList(this.contentVO.getRepositoryId());
Map args = new HashMap();
args.put("globalKey", "infoglue");
PropertySet ps = PropertySetManager.getInstance("jdbc", args);
if ( ps.exists("content_" + this.getContentId() +
"_allowedContentTypeNames" ) )
{
this.allowedContentTypeNames = ps.getString("content_" +
this.getContentId() + "_allowedContentTypeNames");
}
this.defaultContentTypeName = ps.getString("content_" +
this.getContentId() + "_defaultContentTypeName");
this.initialLanguageId = ps.getString("content_" +
this.getContentId() + "_initialLanguageId");
logger.info("allowedContentTypeNames:" + allowedContentTypeNames);
logger.info("defaultContentTypeName:" + defaultContentTypeName);
logger.info("initialLanguageId:" + initialLanguageId);
}
/**
* The main method that fetches the Value-objects for this use-case
*/
public String doExecute() throws Exception
{
this.initialize(getContentId());
return "success";
}
/**
* The main method that fetches the Value-objects for this use-case
*/
public String doSave() throws Exception
{
String allowedContentTypeNames = null;
String[] allowedContentTypeNameArray =
getRequest().getParameterValues("allowedContentTypeName");
if(allowedContentTypeNameArray != null)
{
logger.info("allowedContentTypeNameArray:" +
allowedContentTypeNameArray);
allowedContentTypeNames = "";
for(int i=0; i<allowedContentTypeNameArray.length; i++)
{
allowedContentTypeNames +=
allowedContentTypeNameArray[i] + ",";
}
}
Map args = new HashMap();
args.put("globalKey", "infoglue");
PropertySet ps = PropertySetManager.getInstance("jdbc", args);
if(allowedContentTypeNames != null )
ps.setString("content_" + this.getContentId() +
"_allowedContentTypeNames", allowedContentTypeNames);
if(defaultContentTypeName != null)
ps.setString("content_" + this.getContentId() +
"_defaultContentTypeName", defaultContentTypeName);
if(initialLanguageId != null)
ps.setString("content_" + this.getContentId() +
"_initialLanguageId", initialLanguageId);
return "save";
}
/**
* The main method that fetches the Value-objects for this use-case
*/
public String doSaveAndExit() throws Exception
{
doSave();
return "saveAndExit";
}
public java.lang.Integer getContentId()
{
return this.contentVO.getContentId();
}
public void setContentId(java.lang.Integer contentId) throws Exception
{
this.contentVO.setContentId(contentId);
}
public ContentVO getContentVO()
{
return contentVO;
}
public List getContentTypeDefinitionVOList()
{
return contentTypeDefinitionVOList;
}
public String getAllowedContentTypeNames()
{
return allowedContentTypeNames;
}
public String getDefaultContentTypeName()
{
return defaultContentTypeName;
}
public void setDefaultContentTypeName(String defaultContentTypeName)
{
this.defaultContentTypeName = defaultContentTypeName;
}
public List getLanguageVOList()
{
return languageVOList;
}
public String getInitialLanguageId()
{
return initialLanguageId;
}
public void setInitialLanguageId(String initialLanguageId)
{
this.initialLanguageId = initialLanguageId;
}
}
**********************************************************************************************
**********************************************************************************************
END NEW FEATURES
--
--------------======ooOO000OOoo======---------------
Vicente Javier Rosselló Ferrer
E-mail: vrossello [arroba] uib.es
Tel: 971 17 2884
Centre de Tecnologies de la Informació a la UIB
CTI - http://www.cti.uib.es
Edifici Anselm Turmeda
Ctra. Valldemossa 7.5km
Universitat de les Illes Balears - http://www.uib.es
====================================================
------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H