Powered By Blogger

Monday, January 24, 2011

Hiding Guest Home, Data dictionary , Sites from the normal users

Make the below entry in faces-config-custom.xml



The bean that holds folder browse state.

BrowseBean
com.powergrid.web.bean.PowerGridBrowseBean
session

navigator
#{NavigationBean}


nodeService
#{NodeService}


searchService
#{SearchService}


lockService
#{LockService}


dictionaryService
#{DictionaryService}


fileFolderService
#{FileFolderService}


userPreferencesBean
#{UserPreferencesBean}


multilingualContentService
#{MultilingualContentService}


authorityService
#{AuthorityService}







Bean that returns manages the tree data for the navigator component.
Removes Companyhome

NavigatorPluginBean
com.powergrid.web.bean.ajax.CustomNavigatorPluginBean
session

nodeService
#{NodeService}


internalNodeService
#{nodeService}


dictionaryService
#{DictionaryService}





The java files are


/**
*
*/
package com.powergrid.web.bean.ajax;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import javax.transaction.UserTransaction;

import org.alfresco.model.ContentModel;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.security.AuthorityService;
import org.alfresco.service.namespace.RegexQNamePattern;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.ajax.NavigatorPluginBean;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.data.IDataContainer;
import org.alfresco.web.data.QuickSort;
import org.alfresco.web.ui.common.Utils;
import org.alfresco.web.ui.repo.component.UITree.TreeNode;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
* @author basanagowda.patil
* This class is been written to hide some of the folders which are not required to be shown
*
*/
public class CustomNavigatorPluginBean extends NavigatorPluginBean {


private static final long serialVersionUID = 5223411855251335195L;
private static final Log logger = LogFactory.getLog(CustomNavigatorPluginBean.class);
//added by cignex start
NodeService nodeService = null ;
AuthorityService authorityService = null;
// ------------------------------------------------------------------------------
// AJAX handler methods

public AuthorityService getAuthorityService() {
return authorityService;
}




public void setAuthorityService(AuthorityService authorityService) {
this.authorityService = authorityService;
}

//added by cignex ends



/*
*//**
* Retrieves the child folders for the noderef given in the
* 'noderef' parameter and caches the nodes against the area in
* the 'area' parameter.
*//*
public void retrieveChildren() throws IOException
{
FacesContext context = FacesContext.getCurrentInstance();
ResponseWriter out = context.getResponseWriter();

UserTransaction tx = null;
try
{
tx = Repository.getUserTransaction(context, true);
tx.begin();

Map params = context.getExternalContext().getRequestParameterMap();
String nodeRefStr = (String)params.get("nodeRef");
String area = (String)params.get("area");

if (logger.isDebugEnabled())
logger.debug("retrieveChildren: area = " + area + ", nodeRef = " + nodeRefStr);

// work out which list to cache the nodes in
Map currentNodes = getNodesMapForArea(area);

if (nodeRefStr != null && currentNodes != null)
{
// get the given node's details
NodeRef parentNodeRef = new NodeRef(nodeRefStr);
TreeNode parentNode = currentNodes.get(parentNodeRef.toString());
parentNode.setExpanded(true);

if (logger.isDebugEnabled())
logger.debug("retrieving children for noderef: " + parentNodeRef);

// remove any existing children as the latest ones will be added below
parentNode.removeChildren();

// get all the child folder objects for the parent
//added by cignex

if (nodeService == null)
{
nodeService = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getNodeService();
}

List childRefs = nodeService.getChildAssocs(parentNodeRef,
ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL);
List sortedNodes = new ArrayList();
for (ChildAssociationRef ref: childRefs)
{
NodeRef nodeRef = ref.getChildRef();

if (isAddableChild(nodeRef))
{
// build the XML representation of the child node
TreeNode childNode = createTreeNode(nodeRef);
parentNode.addChild(childNode);
currentNodes.put(childNode.getNodeRef(), childNode);
sortedNodes.add(childNode);
}
}

// order the tree nodes by the tree label
if (sortedNodes.size() > 1)
{
QuickSort sorter = new QuickSort(sortedNodes, "name", true, IDataContainer.SORT_CASEINSENSITIVE);
sorter.sort();
}

// generate the XML representation
StringBuilder xml = new StringBuilder("");
for (TreeNode childNode : sortedNodes)
{ //cignex code to remove datdictionary
if(!childNode.getName().equals("Data Dictionary")){
xml.append(childNode.toXML());
}else{
logger.debug("Excluding datadictionary folder");
}

}
xml.append("
");

// send the generated XML back to the tree
out.write(xml.toString());

if (logger.isDebugEnabled())
logger.debug("returning XML: " + xml.toString());
}

// commit the transaction
tx.commit();
}
catch (Throwable err)
{
try { if (tx != null) {tx.rollback();} } catch (Exception tex) {}
}
}
*/



/**
* Returns the root nodes for the company home panel.
*


* As the user expands and collapses nodes in the client this
* cache will be updated with the appropriate nodes and states.
*


*
* @return List of root nodes for the company home panel
*/
public List getCompanyHomeRootNodes()
{
if (this.companyHomeRootNodes == null)
{
this.companyHomeRootNodes = new ArrayList();
this.companyHomeNodes = new HashMap();

UserTransaction tx = null;
try
{
FacesContext fc = FacesContext.getCurrentInstance();
tx = Repository.getUserTransaction(fc, true);
tx.begin();

// query for the child nodes of company home
NodeRef root = new NodeRef(Repository.getStoreRef(), Application.getCompanyRootId(fc));
if (nodeService == null)
{
nodeService = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getNodeService();
}
List childRefs = this.getNodeService().getChildAssocs(root,
ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL);
//added by Cignex to show only to admin
String user = AuthenticationUtil.getRunAsUser();
for (ChildAssociationRef ref: childRefs)
{
NodeRef child = ref.getChildRef();
//added anothe r condition. Cignex.
if (isAddableChild(child) && validFolder(child , user))
{
TreeNode node = createTreeNode(child);
this.companyHomeRootNodes.add(node);
this.companyHomeNodes.put(node.getNodeRef(), node);
}
}

tx.commit();
}
catch (Throwable err)
{
Utils.addErrorMessage("NavigatorPluginBean exception in getCompanyHomeRootNodes()", err);
try { if (tx != null) {tx.rollback();} } catch (Exception tex) {}
}
}

return this.companyHomeRootNodes;
}

/**
* Checks whether to show it or not. Added by cignex
* @param child
* @return
*/
private boolean validFolder(NodeRef child, String user ){
boolean validFolder = true;



if (nodeService == null)
{
nodeService = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getNodeService();
}

String name = (String)nodeService.getProperty(child , ContentModel.PROP_NAME);
if(name.equals("Sites") || name.equals("Data Dictionary") || name.equals("User Homes") || name.equals("Guest Home")){
validFolder = false ;
}

if (authorityService == null)
{
authorityService = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getAuthorityService();
}

//if user is having admin role then show evrything
if(authorityService.isAdminAuthority(user)){
validFolder = true;
}



return validFolder;
}


public NodeService getNodeService() {
return nodeService;
}




public void setNodeService(NodeService nodeService) {
this.nodeService = nodeService;
}



}





_________________________________



/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco 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 3 of the License, or
* (at your option) any later version.
*
* Alfresco 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.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see .
*/
package com.powergrid.web.bean;

import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import javax.faces.context.FacesContext;
import javax.transaction.UserTransaction;

import org.alfresco.model.ApplicationModel;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.search.SearcherException;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.service.cmr.dictionary.TypeDefinition;
import org.alfresco.service.cmr.model.FileInfo;
import org.alfresco.service.cmr.repository.InvalidNodeRefException;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.search.LimitBy;
import org.alfresco.service.cmr.search.ResultSet;
import org.alfresco.service.cmr.search.ResultSetRow;
import org.alfresco.service.cmr.search.SearchParameters;
import org.alfresco.service.cmr.search.SearchService;
import org.alfresco.service.cmr.security.AuthorityService;
import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.service.cmr.security.PersonService;
import org.alfresco.service.namespace.QName;
import org.alfresco.web.app.Application;
import org.alfresco.web.app.servlet.FacesHelper;
import org.alfresco.web.bean.BrowseBean;
import org.alfresco.web.bean.NodeEventListener;
import org.alfresco.web.bean.repository.MapNode;
import org.alfresco.web.bean.repository.Node;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.bean.search.SearchContext;
import org.alfresco.web.ui.common.Utils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.extensions.config.Config;
import org.springframework.extensions.config.ConfigElement;




/**
* Bean providing properties and behaviour for the main folder/document browse screen and
* search results screens.
*
* @author Kevin Roast
*/
public class PowerGridBrowseBean extends BrowseBean
{

private static final long serialVersionUID = -4529711713073442787L;
private static Log logger = LogFactory.getLog(PowerGridBrowseBean.class);
PersonService personService = null;
AuthorityService authorityService = null;
public AuthorityService getAuthorityService() {
return authorityService;
}


public void setAuthorityService(AuthorityService authorityService) {
this.authorityService = authorityService;
}


public PersonService getPersonService() {
return personService;
}


public void setPersonService(PersonService personService) {
this.personService = personService;
}


@Override
public List getNodes() {

// the references to container nodes and content nodes are transient for one use only
// we do this so we only query/search once - as we cannot distinguish between node types
// until after the query. The logic is a bit confusing but otherwise we would need to
// perform the same query or search twice for every screen refresh.
if (this.containerNodes == null)
{
if (this.navigator.getSearchContext() == null)
{
queryBrowseNodes(this.navigator.getCurrentNodeId());
}
else
{
searchBrowseNodes(this.navigator.getSearchContext());
}
}
List result = this.containerNodes;

// we clear the member variable during invalidateComponents()

/*
if(this.containerNodes != null){
int index= 0;
for(Node node : this.containerNodes){
if(node.getName().equals("Sites") || node.getName().equals("Data Dictionary") || node.getName().equals("User Homes")){
result.remove(index);
logger.debug("Removed the folders:::"+node.getName());
}
index ++;

}


}*/

return result;

}


/**
* Query a list of nodes for the specified parent node Id
*
* @param parentNodeId Id of the parent node or null for the root node
*/
private void queryBrowseNodes(String parentNodeId)
{
long startTime = 0;
if (logger.isDebugEnabled())
startTime = System.currentTimeMillis();

UserTransaction tx = null;
try
{
FacesContext context = FacesContext.getCurrentInstance();
tx = Repository.getUserTransaction(context, true);
tx.begin();

NodeRef parentRef;
if (parentNodeId == null)
{
// no specific parent node specified - use the root node
parentRef = this.getNodeService().getRootNode(Repository.getStoreRef());
}
else
{
// build a NodeRef for the specified Id and our store
parentRef = new NodeRef(Repository.getStoreRef(), parentNodeId);
}

List children = this.getFileFolderService().list(parentRef);
this.containerNodes = new ArrayList(children.size());
this.contentNodes = new ArrayList(children.size());

// in case of dynamic config, only lookup once
Set nodeEventListeners = this.getNodeEventListeners();

for (FileInfo fileInfo : children)
{
// create our Node representation from the NodeRef
NodeRef nodeRef = fileInfo.getNodeRef();

// find it's type so we can see if it's a node we are interested in
QName type = this.getNodeService().getType(nodeRef);

// make sure the type is defined in the data dictionary
TypeDefinition typeDef = this.getDictionaryService().getType(type);

if (typeDef != null)
{
MapNode node = null;

// look for File content node
if (this.getDictionaryService().isSubClass(type, ContentModel.TYPE_CONTENT))
{
// create our Node representation
node = new MapNode(nodeRef, this.getNodeService(), fileInfo.getProperties());
setupCommonBindingProperties(node);

this.contentNodes.add(node);
}
// look for Space folder node
else if (this.getDictionaryService().isSubClass(type, ContentModel.TYPE_FOLDER) == true &&
this.getDictionaryService().isSubClass(type, ContentModel.TYPE_SYSTEM_FOLDER) == false)
{
// create our Node representation
node = new MapNode(nodeRef, this.getNodeService(), fileInfo.getProperties());
node.addPropertyResolver("icon", this.resolverSpaceIcon);
node.addPropertyResolver("smallIcon", this.resolverSmallIcon);
//added by cignex to filter the folders
if(!filterFoldes(node.getName())) {
this.containerNodes.add(node);
}






}
// look for File Link object node
else if (ApplicationModel.TYPE_FILELINK.equals(type))
{
// create our File Link Node representation
node = new MapNode(nodeRef, this.getNodeService(), fileInfo.getProperties());
// only display the user has the permissions to navigate to the target of the link
NodeRef destRef = (NodeRef)node.getProperties().get(ContentModel.PROP_LINK_DESTINATION);
if (destRef != null && new Node(destRef).hasPermission(PermissionService.READ) == true)
{
node.addPropertyResolver("url", this.resolverLinkUrl);
node.addPropertyResolver("downloadUrl", this.resolverLinkDownload);
node.addPropertyResolver("webdavUrl", this.resolverLinkWebdavUrl);
node.addPropertyResolver("cifsPath", this.resolverLinkCifsPath);
node.addPropertyResolver("fileType16", this.resolverFileType16);
node.addPropertyResolver("fileType32", this.resolverFileType32);
node.addPropertyResolver("size", this.resolverSize);
node.addPropertyResolver("lang", this.resolverLang);

this.contentNodes.add(node);
}
}
else if (ApplicationModel.TYPE_FOLDERLINK.equals(type))
{
// create our Folder Link Node representation
node = new MapNode(nodeRef, this.getNodeService(), fileInfo.getProperties());
// only display the user has the permissions to navigate to the target of the link
NodeRef destRef = (NodeRef)node.getProperties().get(ContentModel.PROP_LINK_DESTINATION);
if (destRef != null && new Node(destRef).hasPermission(PermissionService.READ) == true)
{
node.addPropertyResolver("icon", this.resolverSpaceIcon);
node.addPropertyResolver("smallIcon", this.resolverSmallIcon);

this.containerNodes.add(node);
}
}

// inform any listeners that a Node wrapper has been created
if (node != null)
{
for (NodeEventListener listener : nodeEventListeners)
{
listener.created(node, type);
}
}
}
else
{
if (logger.isWarnEnabled())
logger.warn("Found invalid object in database: id = " + nodeRef + ", type = " + type);
}
}

// commit the transaction
tx.commit();
}
catch (InvalidNodeRefException refErr)
{
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(
FacesContext.getCurrentInstance(), Repository.ERROR_NODEREF), new Object[] {refErr.getNodeRef()}), refErr );
this.containerNodes = Collections.emptyList();
this.contentNodes = Collections.emptyList();
try { if (tx != null) {tx.rollback();} } catch (Exception tex) {}
}
catch (Throwable err)
{
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(
FacesContext.getCurrentInstance(), Repository.ERROR_GENERIC), err.getMessage()), err);
this.containerNodes = Collections.emptyList();
this.contentNodes = Collections.emptyList();
try { if (tx != null) {tx.rollback();} } catch (Exception tex) {}
}

if (logger.isDebugEnabled())
{
long endTime = System.currentTimeMillis();
logger.debug("Time to query and build map nodes: " + (endTime - startTime) + "ms");
}
}




/**
* Search for a list of nodes using the specific search context
*
* @param searchContext To use to perform the search
*/
private void searchBrowseNodes(SearchContext searchContext)
{
long startTime = 0;
if (logger.isDebugEnabled())
startTime = System.currentTimeMillis();

// get the searcher object to build the query
String query = searchContext.buildQuery(getMinimumSearchLength());
if (query == null)
{
// failed to build a valid query, the user probably did not enter the
// minimum text required to construct a valid search
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(FacesContext.getCurrentInstance(), MSG_SEARCH_MINIMUM),
new Object[] {getMinimumSearchLength()}));
this.containerNodes = Collections.emptyList();
this.contentNodes = Collections.emptyList();
return;
}

// perform the search against the repo
UserTransaction tx = null;
ResultSet results = null;
try
{
tx = Repository.getUserTransaction(FacesContext.getCurrentInstance(), true);
tx.begin();

// build up the search parameters
SearchParameters sp = new SearchParameters();
sp.setLanguage(SearchService.LANGUAGE_LUCENE);
sp.setQuery(query);
sp.addStore(Repository.getStoreRef());

// limit search results size as configured
int searchLimit = Application.getClientConfig(FacesContext.getCurrentInstance()).getSearchMaxResults();
if (searchLimit > 0)
{
sp.setLimitBy(LimitBy.FINAL_SIZE);
sp.setLimit(searchLimit);
}

results = this.getSearchService().query(sp);
if (logger.isDebugEnabled())
logger.debug("Search results returned: " + results.length());

// create a list of items from the results
this.containerNodes = new ArrayList(results.length());
this.contentNodes = new ArrayList(results.length());
if (results.length() != 0)
{
// in case of dynamic config, only lookup once
Set nodeEventListeners = getNodeEventListeners();

for (ResultSetRow row: results)
{
NodeRef nodeRef = row.getNodeRef();

if (this.getNodeService().exists(nodeRef))
{
// find it's type so we can see if it's a node we are interested in
QName type = this.getNodeService().getType(nodeRef);

// make sure the type is defined in the data dictionary
TypeDefinition typeDef = this.getDictionaryService().getType(type);

if (typeDef != null)
{
MapNode node = null;

// look for Space or File nodes
if (this.getDictionaryService().isSubClass(type, ContentModel.TYPE_FOLDER) &&
this.getDictionaryService().isSubClass(type, ContentModel.TYPE_SYSTEM_FOLDER) == false)
{
// create our Node representation
node = new MapNode(nodeRef, this.getNodeService(), false);

node.addPropertyResolver("path", this.resolverPath);
node.addPropertyResolver("displayPath", this.resolverDisplayPath);
node.addPropertyResolver("icon", this.resolverSpaceIcon);
node.addPropertyResolver("smallIcon", this.resolverSmallIcon);
if(!filterFoldes(node.getName())) {
this.containerNodes.add(node);
}

}
else if (this.getDictionaryService().isSubClass(type, ContentModel.TYPE_CONTENT))
{
// create our Node representation
node = new MapNode(nodeRef, this.getNodeService(), false);

setupCommonBindingProperties(node);

node.addPropertyResolver("path", this.resolverPath);
node.addPropertyResolver("displayPath", this.resolverDisplayPath);

this.contentNodes.add(node);
}
// look for File Link object node
else if (ApplicationModel.TYPE_FILELINK.equals(type))
{
// create our File Link Node representation
node = new MapNode(nodeRef, this.getNodeService(), false);
// only display the user has the permissions to navigate to the target of the link
NodeRef destRef = (NodeRef)node.getProperties().get(ContentModel.PROP_LINK_DESTINATION);
if (new Node(destRef).hasPermission(PermissionService.READ) == true)
{
node.addPropertyResolver("url", this.resolverLinkUrl);
node.addPropertyResolver("downloadUrl", this.resolverLinkDownload);
node.addPropertyResolver("webdavUrl", this.resolverLinkWebdavUrl);
node.addPropertyResolver("cifsPath", this.resolverLinkCifsPath);
node.addPropertyResolver("fileType16", this.resolverFileType16);
node.addPropertyResolver("fileType32", this.resolverFileType32);
node.addPropertyResolver("size", this.resolverSize);
node.addPropertyResolver("lang", this.resolverLang);
node.addPropertyResolver("path", this.resolverPath);
node.addPropertyResolver("displayPath", this.resolverDisplayPath);

this.contentNodes.add(node);
}
}
else if (ApplicationModel.TYPE_FOLDERLINK.equals(type))
{
// create our Folder Link Node representation
node = new MapNode(nodeRef, this.getNodeService(), false);
// only display the user has the permissions to navigate to the target of the link
NodeRef destRef = (NodeRef)node.getProperties().get(ContentModel.PROP_LINK_DESTINATION);
if (new Node(destRef).hasPermission(PermissionService.READ) == true)
{
node.addPropertyResolver("icon", this.resolverSpaceIcon);
node.addPropertyResolver("smallIcon", this.resolverSmallIcon);
node.addPropertyResolver("path", this.resolverPath);
node.addPropertyResolver("displayPath", this.resolverDisplayPath);

this.containerNodes.add(node);
}
}

// inform any listeners that a Node wrapper has been created
if (node != null)
{
for (NodeEventListener listener : nodeEventListeners)
{
listener.created(node, type);
}
}
}
else
{
if (logger.isWarnEnabled())
logger.warn("Found invalid object in database: id = " + nodeRef + ", type = " + type);
}
}
else
{
if (logger.isWarnEnabled())
logger.warn("Missing object returned from search indexes: id = " + nodeRef + " search query: " + query);
}
}
}

// commit the transaction
tx.commit();
}
catch (InvalidNodeRefException refErr)
{
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(
FacesContext.getCurrentInstance(), Repository.ERROR_NODEREF), new Object[] {refErr.getNodeRef()}), refErr );
this.containerNodes = Collections.emptyList();
this.contentNodes = Collections.emptyList();
try { if (tx != null) {tx.rollback();} } catch (Exception tex) {}
}
catch (SearcherException serr)
{
logger.info("Search failed for: " + query, serr);
Utils.addErrorMessage(Application.getMessage(
FacesContext.getCurrentInstance(), Repository.ERROR_QUERY));
this.containerNodes = Collections.emptyList();
this.contentNodes = Collections.emptyList();
try { if (tx != null) {tx.rollback();} } catch (Exception tex) {}
}
catch (Throwable err)
{
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(
FacesContext.getCurrentInstance(), Repository.ERROR_SEARCH), new Object[] {err.getMessage()}), err );
this.containerNodes = Collections.emptyList();
this.contentNodes = Collections.emptyList();
try { if (tx != null) {tx.rollback();} } catch (Exception tex) {}
}
finally
{
if (results != null)
{
results.close();
}
}

if (logger.isDebugEnabled())
{
long endTime = System.currentTimeMillis();
logger.debug("Time to query and build map nodes: " + (endTime - startTime) + "ms");
}
}



/**
* @return the Set of NodeEventListeners registered against this bean
*/
private Set getNodeEventListeners()
{
if ((this.nodeEventListeners == null) || (Application.isDynamicConfig(FacesContext.getCurrentInstance())))
{
Set allNodeEventListeners = new HashSet();

if (Application.isDynamicConfig(FacesContext.getCurrentInstance()) && (this.nodeEventListeners != null))
{
// for dynamic config, can add/remove node event listeners dynamically ...
// however, in case anyone is using public methods (add/removeNodeEventListener)
// we merge list here with list returned from the config
allNodeEventListeners.addAll(this.nodeEventListeners);
}

FacesContext fc = FacesContext.getCurrentInstance();
Config listenerConfig = Application.getConfigService(fc).getConfig("Node Event Listeners");
if (listenerConfig != null)
{
ConfigElement listenerElement = listenerConfig.getConfigElement("node-event-listeners");
if (listenerElement != null)
{
for (ConfigElement child : listenerElement.getChildren())
{
if (child.getName().equals("listener"))
{
// retrieved the JSF Managed Bean identified in the config
String listenerName = child.getValue().trim();
Object bean = FacesHelper.getManagedBean(fc, listenerName);
if (bean instanceof NodeEventListener)
{
allNodeEventListeners.add((NodeEventListener)bean);
}
}
}
}
}

if (Application.isDynamicConfig(FacesContext.getCurrentInstance()))
{
return allNodeEventListeners;
}
else
{
this.nodeEventListeners = allNodeEventListeners;
}
}
return this.nodeEventListeners;
}




/**
* Added code filter the folders not required
* @param name
* @return
*/
private boolean filterFoldes(String name){
boolean filter = false;

String user = AuthenticationUtil.getRunAsUser();
if(name.equals("Sites") || name.equals("Data Dictionary") || name.equals("User Homes") || name.equals("Guest Home")){
filter = true;
logger.debug("Removed the folders:::"+name);
}

if( authorityService.isAdminAuthority(user)){
logger.debug("Showing all the users since the user is admin");
filter = false;
}
return filter;

}


}

No comments:

Post a Comment