diff --git a/config/alfresco/web-client-config.xml b/config/alfresco/web-client-config.xml
index 0c004735a2..87bd899781 100644
--- a/config/alfresco/web-client-config.xml
+++ b/config/alfresco/web-client-config.xml
@@ -100,6 +100,9 @@
6
+
+ true
+
3
diff --git a/source/java/org/alfresco/web/bean/AdvancedSearchBean.java b/source/java/org/alfresco/web/bean/AdvancedSearchBean.java
index 5d4a1fc490..7907fcefdd 100644
--- a/source/java/org/alfresco/web/bean/AdvancedSearchBean.java
+++ b/source/java/org/alfresco/web/bean/AdvancedSearchBean.java
@@ -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 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 savedSearches = null;
- NodeRef searchesRef = getSavedSearchesRef();
- if (searchesRef != null)
+ List savedSearches = cachedSavedSearches.get();
+ if (savedSearches == null)
{
- List results = searchService.selectNodes(
- searchesRef,
- xpath,
- null,
- namespaceService,
- false);
- savedSearches = new ArrayList(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 results = searchService.selectNodes(
+ searchesRef,
+ xpath,
+ null,
+ namespaceService,
+ false);
+ savedSearches = new ArrayList(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(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(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> cachedSavedSearches = new ExpiringValueCache>();
}
diff --git a/source/java/org/alfresco/web/bean/NavigationBean.java b/source/java/org/alfresco/web/bean/NavigationBean.java
index 86d30b93b2..bb0d8fea2b 100644
--- a/source/java/org/alfresco/web/bean/NavigationBean.java
+++ b/source/java/org/alfresco/web/bean/NavigationBean.java
@@ -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;
diff --git a/source/java/org/alfresco/web/bean/preview/BasePreviewBean.java b/source/java/org/alfresco/web/bean/preview/BasePreviewBean.java
index 9a53ed3297..1472bf6bcb 100644
--- a/source/java/org/alfresco/web/bean/preview/BasePreviewBean.java
+++ b/source/java/org/alfresco/web/bean/preview/BasePreviewBean.java
@@ -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> cachedTemplates = new ExpiringValueCache>(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 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 results = this.searchService.selectNodes(rootNodeRef, xpath, null, resolver, false);
-
- List templates = new ArrayList(results.size() + 1);
- if (results.size() != 0)
+ List 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 results = this.searchService.selectNodes(rootNodeRef, xpath, null, resolver, false);
+
+ templates = new ArrayList(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);
+ }
};
/**
diff --git a/source/java/org/alfresco/web/config/ClientConfigElement.java b/source/java/org/alfresco/web/config/ClientConfigElement.java
index 9bb101d7f7..d99265fbb9 100644
--- a/source/java/org/alfresco/web/config/ClientConfigElement.java
+++ b/source/java/org/alfresco/web/config/ClientConfigElement.java
@@ -61,6 +61,7 @@ public class ClientConfigElement extends ConfigElementAdapter
private List descendingSorts = new ArrayList(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.
*
diff --git a/source/java/org/alfresco/web/config/ClientElementReader.java b/source/java/org/alfresco/web/config/ClientElementReader.java
index e557530375..fa74eb49ee 100644
--- a/source/java/org/alfresco/web/config/ClientElementReader.java
+++ b/source/java/org/alfresco/web/config/ClientElementReader.java
@@ -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)
diff --git a/source/web/WEB-INF/faces-config.xml b/source/web/WEB-INF/faces-config.xml
index 0cdaa67850..ae765c2d33 100644
--- a/source/web/WEB-INF/faces-config.xml
+++ b/source/web/WEB-INF/faces-config.xml
@@ -74,10 +74,6 @@
cifsServer
#{cifsServer}
-
- configService
- #{configService}
-