mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-06-23 18:05:32 +00:00
. Added client config setting to allow the Shelf component to be hidden by default
. Added ExpiringValueCache class used to hold simple lists in the client that don't need refreshing constantly git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2105 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
parent
2652d33f08
commit
aaff54e53c
@ -100,6 +100,9 @@
|
||||
<!-- the maximum number of items to show in the recent spaces shelf component -->
|
||||
<recent-spaces-items>6</recent-spaces-items>
|
||||
|
||||
<!-- Shelf component default visibility, set to false to hide the shelf by default -->
|
||||
<shelf-visible>true</shelf-visible>
|
||||
|
||||
<!-- the minimum number of characters required for a valid search string -->
|
||||
<search-minimum>3</search-minimum>
|
||||
|
||||
|
@ -28,7 +28,6 @@ import java.util.Map;
|
||||
import javax.faces.component.UISelectBoolean;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.event.ActionEvent;
|
||||
import javax.faces.event.ValueChangeEvent;
|
||||
import javax.faces.model.DataModel;
|
||||
import javax.faces.model.ListDataModel;
|
||||
import javax.faces.model.SelectItem;
|
||||
@ -36,6 +35,7 @@ import javax.transaction.UserTransaction;
|
||||
|
||||
import org.alfresco.config.ConfigService;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.cache.ExpiringValueCache;
|
||||
import org.alfresco.repo.content.MimetypeMap;
|
||||
import org.alfresco.repo.security.permissions.AccessDeniedException;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
@ -866,6 +866,7 @@ public class AdvancedSearchBean
|
||||
|
||||
tx.commit();
|
||||
|
||||
this.cachedSavedSearches.clear();
|
||||
this.savedSearch = null;
|
||||
}
|
||||
catch (Throwable e)
|
||||
@ -885,54 +886,58 @@ public class AdvancedSearchBean
|
||||
*/
|
||||
public List<SelectItem> getSavedSearches()
|
||||
{
|
||||
// TODO: cache for 1 minute? - dirty cache when new search is saved!
|
||||
FacesContext fc = FacesContext.getCurrentInstance();
|
||||
String xpath = ".//*";
|
||||
|
||||
ServiceRegistry services = Repository.getServiceRegistry(fc);
|
||||
|
||||
List<SelectItem> savedSearches = null;
|
||||
NodeRef searchesRef = getSavedSearchesRef();
|
||||
if (searchesRef != null)
|
||||
List<SelectItem> savedSearches = cachedSavedSearches.get();
|
||||
if (savedSearches == null)
|
||||
{
|
||||
List<NodeRef> results = searchService.selectNodes(
|
||||
searchesRef,
|
||||
xpath,
|
||||
null,
|
||||
namespaceService,
|
||||
false);
|
||||
savedSearches = new ArrayList<SelectItem>(results.size() + 1);
|
||||
if (results.size() != 0)
|
||||
FacesContext fc = FacesContext.getCurrentInstance();
|
||||
String xpath = ".//*";
|
||||
|
||||
ServiceRegistry services = Repository.getServiceRegistry(fc);
|
||||
|
||||
NodeRef searchesRef = getSavedSearchesRef();
|
||||
if (searchesRef != null)
|
||||
{
|
||||
DictionaryService dd = services.getDictionaryService();
|
||||
for (NodeRef ref : results)
|
||||
List<NodeRef> results = searchService.selectNodes(
|
||||
searchesRef,
|
||||
xpath,
|
||||
null,
|
||||
namespaceService,
|
||||
false);
|
||||
savedSearches = new ArrayList<SelectItem>(results.size() + 1);
|
||||
if (results.size() != 0)
|
||||
{
|
||||
Node childNode = new Node(ref);
|
||||
if (dd.isSubClass(childNode.getType(), ContentModel.TYPE_CONTENT))
|
||||
DictionaryService dd = services.getDictionaryService();
|
||||
for (NodeRef ref : results)
|
||||
{
|
||||
savedSearches.add(new SelectItem(childNode.getId(), childNode.getName()));
|
||||
Node childNode = new Node(ref);
|
||||
if (dd.isSubClass(childNode.getType(), ContentModel.TYPE_CONTENT))
|
||||
{
|
||||
savedSearches.add(new SelectItem(childNode.getId(), childNode.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
// make sure the list is sorted by the label
|
||||
QuickSort sorter = new QuickSort(savedSearches, "label", true, IDataContainer.SORT_CASEINSENSITIVE);
|
||||
sorter.sort();
|
||||
}
|
||||
|
||||
// make sure the list is sorted by the label
|
||||
QuickSort sorter = new QuickSort(savedSearches, "label", true, IDataContainer.SORT_CASEINSENSITIVE);
|
||||
sorter.sort();
|
||||
}
|
||||
else
|
||||
{
|
||||
// handle missing folder case
|
||||
savedSearches = new ArrayList<SelectItem>(1);
|
||||
}
|
||||
|
||||
// add an entry (at the start) to instruct the user to select a saved search
|
||||
savedSearches.add(0, new SelectItem(NO_SELECTION,
|
||||
Application.getMessage(FacesContext.getCurrentInstance(), MSG_SELECT_SAVED_SEARCH)));
|
||||
|
||||
// store in the cache (will auto-expire)
|
||||
cachedSavedSearches.put(savedSearches);
|
||||
}
|
||||
else
|
||||
{
|
||||
// handle missing folder case
|
||||
savedSearches = new ArrayList<SelectItem>(1);
|
||||
}
|
||||
|
||||
// add an entry (at the start) to instruct the user to select a saved search
|
||||
savedSearches.add(0, new SelectItem(NO_SELECTION,
|
||||
Application.getMessage(FacesContext.getCurrentInstance(), MSG_SELECT_SAVED_SEARCH)));
|
||||
|
||||
return savedSearches;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Action handler called when a saved search is selected by the user
|
||||
*/
|
||||
@ -1384,4 +1389,6 @@ public class AdvancedSearchBean
|
||||
private String savedSearch = null;
|
||||
|
||||
private String editSearchName = null;
|
||||
|
||||
private ExpiringValueCache<List<SelectItem>> cachedSavedSearches = new ExpiringValueCache<List<SelectItem>>();
|
||||
}
|
||||
|
@ -61,9 +61,18 @@ import org.apache.log4j.Logger;
|
||||
*/
|
||||
public class NavigationBean
|
||||
{
|
||||
/**
|
||||
* Default constructor
|
||||
*/
|
||||
public NavigationBean()
|
||||
{
|
||||
initFromClientConfig();
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Bean property getters and setters
|
||||
|
||||
// Bean property getters and setters
|
||||
|
||||
/**
|
||||
* @param nodeService The nodeService to set.
|
||||
*/
|
||||
@ -104,14 +113,6 @@ public class NavigationBean
|
||||
this.contentDiskDriver = contentDiskDriver;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param configService The ConfigService to set.
|
||||
*/
|
||||
public void setConfigService(ConfigService configService)
|
||||
{
|
||||
this.configService = configService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the User object representing the current instance for this user
|
||||
*/
|
||||
@ -177,10 +178,6 @@ public class NavigationBean
|
||||
*/
|
||||
public String getHelpUrl()
|
||||
{
|
||||
if (this.clientConfig == null)
|
||||
{
|
||||
initFromClientConfig();
|
||||
}
|
||||
return this.helpUrl;
|
||||
}
|
||||
|
||||
@ -534,6 +531,7 @@ public class NavigationBean
|
||||
return this.cifsServerPath;
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Private helpers
|
||||
|
||||
@ -542,12 +540,15 @@ public class NavigationBean
|
||||
*/
|
||||
private void initFromClientConfig()
|
||||
{
|
||||
this.clientConfig = (ClientConfigElement)this.configService.getGlobalConfig().getConfigElement(
|
||||
ClientConfigElement.CONFIG_ELEMENT_ID);
|
||||
this.clientConfig = (ClientConfigElement)Application.getConfigService(
|
||||
FacesContext.getCurrentInstance()).getGlobalConfig().
|
||||
getConfigElement(ClientConfigElement.CONFIG_ELEMENT_ID);
|
||||
|
||||
this.helpUrl = clientConfig.getHelpUrl();
|
||||
this.shelfExpanded = clientConfig.isShelfVisible();
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Inner classes
|
||||
|
||||
@ -636,9 +637,6 @@ public class NavigationBean
|
||||
/** CIFS content disk driver bean reference */
|
||||
private ContentDiskInterface contentDiskDriver;
|
||||
|
||||
/** ConfigService bean reference */
|
||||
private ConfigService configService;
|
||||
|
||||
/** Client configuration object */
|
||||
private ClientConfigElement clientConfig = null;
|
||||
|
||||
|
@ -26,6 +26,7 @@ import javax.faces.event.ActionEvent;
|
||||
import javax.faces.model.SelectItem;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.cache.ExpiringValueCache;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
@ -67,6 +68,9 @@ public abstract class BasePreviewBean
|
||||
|
||||
protected NodeRef template;
|
||||
|
||||
/** cache of templates that last 10 seconds - enough for a couple of page refreshes */
|
||||
private ExpiringValueCache<List<SelectItem>> cachedTemplates = new ExpiringValueCache<List<SelectItem>>(1000*10);
|
||||
|
||||
|
||||
/**
|
||||
* @param nodeService The nodeService to set.
|
||||
@ -130,40 +134,45 @@ public abstract class BasePreviewBean
|
||||
/**
|
||||
* @return the list of available Content Templates that can be applied to the current document.
|
||||
*/
|
||||
public SelectItem[] getTemplates()
|
||||
public List<SelectItem> getTemplates()
|
||||
{
|
||||
// TODO: could cache this last for say 1 minute before requerying
|
||||
// get the template from the special Content Templates folder
|
||||
FacesContext context = FacesContext.getCurrentInstance();
|
||||
String xpath = Application.getRootPath(context) + "/" +
|
||||
Application.getGlossaryFolderName(context) + "/" +
|
||||
Application.getContentTemplatesFolderName(context) + "//*";
|
||||
NodeRef rootNodeRef = this.nodeService.getRootNode(Repository.getStoreRef());
|
||||
NamespaceService resolver = Repository.getServiceRegistry(context).getNamespaceService();
|
||||
List<NodeRef> results = this.searchService.selectNodes(rootNodeRef, xpath, null, resolver, false);
|
||||
|
||||
List<SelectItem> templates = new ArrayList<SelectItem>(results.size() + 1);
|
||||
if (results.size() != 0)
|
||||
List<SelectItem> templates = cachedTemplates.get();
|
||||
if (templates == null)
|
||||
{
|
||||
DictionaryService dd = Repository.getServiceRegistry(context).getDictionaryService();
|
||||
for (NodeRef ref : results)
|
||||
// get the template from the special Content Templates folder
|
||||
FacesContext context = FacesContext.getCurrentInstance();
|
||||
String xpath = Application.getRootPath(context) + "/" +
|
||||
Application.getGlossaryFolderName(context) + "/" +
|
||||
Application.getContentTemplatesFolderName(context) + "//*";
|
||||
NodeRef rootNodeRef = this.nodeService.getRootNode(Repository.getStoreRef());
|
||||
NamespaceService resolver = Repository.getServiceRegistry(context).getNamespaceService();
|
||||
List<NodeRef> results = this.searchService.selectNodes(rootNodeRef, xpath, null, resolver, false);
|
||||
|
||||
templates = new ArrayList<SelectItem>(results.size() + 1);
|
||||
if (results.size() != 0)
|
||||
{
|
||||
Node childNode = new Node(ref);
|
||||
if (dd.isSubClass(childNode.getType(), ContentModel.TYPE_CONTENT))
|
||||
DictionaryService dd = Repository.getServiceRegistry(context).getDictionaryService();
|
||||
for (NodeRef ref : results)
|
||||
{
|
||||
templates.add(new SelectItem(childNode.getId(), childNode.getName()));
|
||||
Node childNode = new Node(ref);
|
||||
if (dd.isSubClass(childNode.getType(), ContentModel.TYPE_CONTENT))
|
||||
{
|
||||
templates.add(new SelectItem(childNode.getId(), childNode.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
// make sure the list is sorted by the label
|
||||
QuickSort sorter = new QuickSort(templates, "label", true, IDataContainer.SORT_CASEINSENSITIVE);
|
||||
sorter.sort();
|
||||
}
|
||||
|
||||
// make sure the list is sorted by the label
|
||||
QuickSort sorter = new QuickSort(templates, "label", true, IDataContainer.SORT_CASEINSENSITIVE);
|
||||
sorter.sort();
|
||||
// add an entry (at the start) to instruct the user to select a template
|
||||
templates.add(0, new SelectItem(NO_SELECTION, Application.getMessage(FacesContext.getCurrentInstance(), "select_a_template")));
|
||||
|
||||
cachedTemplates.put(templates);
|
||||
}
|
||||
|
||||
// add an entry (at the start) to instruct the user to select a template
|
||||
templates.add(0, new SelectItem(NO_SELECTION, Application.getMessage(FacesContext.getCurrentInstance(), "select_a_template")));
|
||||
|
||||
return templates.toArray(new SelectItem[templates.size()]);
|
||||
return templates;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -176,10 +185,10 @@ public abstract class BasePreviewBean
|
||||
/** Template Image resolver helper */
|
||||
protected TemplateImageResolver imageResolver = new TemplateImageResolver()
|
||||
{
|
||||
public String resolveImagePathForName(String filename, boolean small)
|
||||
{
|
||||
return Utils.getFileTypeImage(filename, small);
|
||||
}
|
||||
public String resolveImagePathForName(String filename, boolean small)
|
||||
{
|
||||
return Utils.getFileTypeImage(filename, small);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -61,6 +61,7 @@ public class ClientConfigElement extends ConfigElementAdapter
|
||||
private List<String> descendingSorts = new ArrayList<String>(1);
|
||||
|
||||
private int recentSpacesItems = 6;
|
||||
private boolean shelfVisible = true;
|
||||
private int searchMinimum = 3;
|
||||
private String helpUrl = null;
|
||||
private String editLinkType = null;
|
||||
@ -260,6 +261,22 @@ public class ClientConfigElement extends ConfigElementAdapter
|
||||
this.recentSpacesItems = recentSpacesItems;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns if the shelf component is visible by default.
|
||||
*/
|
||||
public boolean isShelfVisible()
|
||||
{
|
||||
return this.shelfVisible;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param shelfVisible True if the shelf component is visible by default.
|
||||
*/
|
||||
/*package*/ void setShelfVisible(boolean shelfVisible)
|
||||
{
|
||||
this.shelfVisible = shelfVisible;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a language locale and display label to the list.
|
||||
*
|
||||
|
@ -59,6 +59,7 @@ public class ClientElementReader implements ConfigElementReader
|
||||
public static final String ATTRIBUTE_PROPERTY = "property";
|
||||
public static final String ATTRIBUTE_ASPECT = "aspect";
|
||||
public static final String ATTRIBUTE_DISPLAYLABEL = "displayLabelId";
|
||||
public static final String ELEMENT_SHELFVISIBLE = "shelf-visible";
|
||||
|
||||
private static Log logger = LogFactory.getLog(ClientElementReader.class);
|
||||
|
||||
@ -164,6 +165,13 @@ public class ClientElementReader implements ConfigElementReader
|
||||
configElement.setRecentSpacesItems(Integer.parseInt(recentSpaces.getTextTrim()));
|
||||
}
|
||||
|
||||
// get the shelf component default visibility
|
||||
Element shelfVisible = element.element(ELEMENT_SHELFVISIBLE);
|
||||
if (shelfVisible != null)
|
||||
{
|
||||
configElement.setShelfVisible(Boolean.parseBoolean(shelfVisible.getTextTrim()));
|
||||
}
|
||||
|
||||
// get the Help url
|
||||
Element helpUrl = element.element(ELEMENT_HELPURL);
|
||||
if (helpUrl != null)
|
||||
|
@ -74,10 +74,6 @@
|
||||
<property-name>cifsServer</property-name>
|
||||
<value>#{cifsServer}</value>
|
||||
</managed-property>
|
||||
<managed-property>
|
||||
<property-name>configService</property-name>
|
||||
<value>#{configService}</value>
|
||||
</managed-property>
|
||||
</managed-bean>
|
||||
|
||||
<managed-bean>
|
||||
|
Loading…
x
Reference in New Issue
Block a user