mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-06-30 18:15:39 +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 -->
|
<!-- the maximum number of items to show in the recent spaces shelf component -->
|
||||||
<recent-spaces-items>6</recent-spaces-items>
|
<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 -->
|
<!-- the minimum number of characters required for a valid search string -->
|
||||||
<search-minimum>3</search-minimum>
|
<search-minimum>3</search-minimum>
|
||||||
|
|
||||||
|
@ -28,7 +28,6 @@ import java.util.Map;
|
|||||||
import javax.faces.component.UISelectBoolean;
|
import javax.faces.component.UISelectBoolean;
|
||||||
import javax.faces.context.FacesContext;
|
import javax.faces.context.FacesContext;
|
||||||
import javax.faces.event.ActionEvent;
|
import javax.faces.event.ActionEvent;
|
||||||
import javax.faces.event.ValueChangeEvent;
|
|
||||||
import javax.faces.model.DataModel;
|
import javax.faces.model.DataModel;
|
||||||
import javax.faces.model.ListDataModel;
|
import javax.faces.model.ListDataModel;
|
||||||
import javax.faces.model.SelectItem;
|
import javax.faces.model.SelectItem;
|
||||||
@ -36,6 +35,7 @@ import javax.transaction.UserTransaction;
|
|||||||
|
|
||||||
import org.alfresco.config.ConfigService;
|
import org.alfresco.config.ConfigService;
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
|
import org.alfresco.repo.cache.ExpiringValueCache;
|
||||||
import org.alfresco.repo.content.MimetypeMap;
|
import org.alfresco.repo.content.MimetypeMap;
|
||||||
import org.alfresco.repo.security.permissions.AccessDeniedException;
|
import org.alfresco.repo.security.permissions.AccessDeniedException;
|
||||||
import org.alfresco.service.ServiceRegistry;
|
import org.alfresco.service.ServiceRegistry;
|
||||||
@ -866,6 +866,7 @@ public class AdvancedSearchBean
|
|||||||
|
|
||||||
tx.commit();
|
tx.commit();
|
||||||
|
|
||||||
|
this.cachedSavedSearches.clear();
|
||||||
this.savedSearch = null;
|
this.savedSearch = null;
|
||||||
}
|
}
|
||||||
catch (Throwable e)
|
catch (Throwable e)
|
||||||
@ -885,54 +886,58 @@ public class AdvancedSearchBean
|
|||||||
*/
|
*/
|
||||||
public List<SelectItem> getSavedSearches()
|
public List<SelectItem> getSavedSearches()
|
||||||
{
|
{
|
||||||
// TODO: cache for 1 minute? - dirty cache when new search is saved!
|
List<SelectItem> savedSearches = cachedSavedSearches.get();
|
||||||
FacesContext fc = FacesContext.getCurrentInstance();
|
if (savedSearches == null)
|
||||||
String xpath = ".//*";
|
|
||||||
|
|
||||||
ServiceRegistry services = Repository.getServiceRegistry(fc);
|
|
||||||
|
|
||||||
List<SelectItem> savedSearches = null;
|
|
||||||
NodeRef searchesRef = getSavedSearchesRef();
|
|
||||||
if (searchesRef != null)
|
|
||||||
{
|
{
|
||||||
List<NodeRef> results = searchService.selectNodes(
|
FacesContext fc = FacesContext.getCurrentInstance();
|
||||||
searchesRef,
|
String xpath = ".//*";
|
||||||
xpath,
|
|
||||||
null,
|
ServiceRegistry services = Repository.getServiceRegistry(fc);
|
||||||
namespaceService,
|
|
||||||
false);
|
NodeRef searchesRef = getSavedSearchesRef();
|
||||||
savedSearches = new ArrayList<SelectItem>(results.size() + 1);
|
if (searchesRef != null)
|
||||||
if (results.size() != 0)
|
|
||||||
{
|
{
|
||||||
DictionaryService dd = services.getDictionaryService();
|
List<NodeRef> results = searchService.selectNodes(
|
||||||
for (NodeRef ref : results)
|
searchesRef,
|
||||||
|
xpath,
|
||||||
|
null,
|
||||||
|
namespaceService,
|
||||||
|
false);
|
||||||
|
savedSearches = new ArrayList<SelectItem>(results.size() + 1);
|
||||||
|
if (results.size() != 0)
|
||||||
{
|
{
|
||||||
Node childNode = new Node(ref);
|
DictionaryService dd = services.getDictionaryService();
|
||||||
if (dd.isSubClass(childNode.getType(), ContentModel.TYPE_CONTENT))
|
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
|
||||||
else
|
{
|
||||||
{
|
// handle missing folder case
|
||||||
// handle missing folder case
|
savedSearches = new ArrayList<SelectItem>(1);
|
||||||
savedSearches = new ArrayList<SelectItem>(1);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// add an entry (at the start) to instruct the user to select a saved search
|
// add an entry (at the start) to instruct the user to select a saved search
|
||||||
savedSearches.add(0, new SelectItem(NO_SELECTION,
|
savedSearches.add(0, new SelectItem(NO_SELECTION,
|
||||||
Application.getMessage(FacesContext.getCurrentInstance(), MSG_SELECT_SAVED_SEARCH)));
|
Application.getMessage(FacesContext.getCurrentInstance(), MSG_SELECT_SAVED_SEARCH)));
|
||||||
|
|
||||||
|
// store in the cache (will auto-expire)
|
||||||
|
cachedSavedSearches.put(savedSearches);
|
||||||
|
}
|
||||||
|
|
||||||
return savedSearches;
|
return savedSearches;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action handler called when a saved search is selected by the user
|
* 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 savedSearch = null;
|
||||||
|
|
||||||
private String editSearchName = null;
|
private String editSearchName = null;
|
||||||
|
|
||||||
|
private ExpiringValueCache<List<SelectItem>> cachedSavedSearches = new ExpiringValueCache<List<SelectItem>>();
|
||||||
}
|
}
|
||||||
|
@ -61,6 +61,15 @@ import org.apache.log4j.Logger;
|
|||||||
*/
|
*/
|
||||||
public class NavigationBean
|
public class NavigationBean
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Default constructor
|
||||||
|
*/
|
||||||
|
public NavigationBean()
|
||||||
|
{
|
||||||
|
initFromClientConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------
|
||||||
// Bean property getters and setters
|
// Bean property getters and setters
|
||||||
|
|
||||||
@ -104,14 +113,6 @@ public class NavigationBean
|
|||||||
this.contentDiskDriver = contentDiskDriver;
|
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
|
* @return the User object representing the current instance for this user
|
||||||
*/
|
*/
|
||||||
@ -177,10 +178,6 @@ public class NavigationBean
|
|||||||
*/
|
*/
|
||||||
public String getHelpUrl()
|
public String getHelpUrl()
|
||||||
{
|
{
|
||||||
if (this.clientConfig == null)
|
|
||||||
{
|
|
||||||
initFromClientConfig();
|
|
||||||
}
|
|
||||||
return this.helpUrl;
|
return this.helpUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -534,6 +531,7 @@ public class NavigationBean
|
|||||||
return this.cifsServerPath;
|
return this.cifsServerPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------
|
||||||
// Private helpers
|
// Private helpers
|
||||||
|
|
||||||
@ -542,12 +540,15 @@ public class NavigationBean
|
|||||||
*/
|
*/
|
||||||
private void initFromClientConfig()
|
private void initFromClientConfig()
|
||||||
{
|
{
|
||||||
this.clientConfig = (ClientConfigElement)this.configService.getGlobalConfig().getConfigElement(
|
this.clientConfig = (ClientConfigElement)Application.getConfigService(
|
||||||
ClientConfigElement.CONFIG_ELEMENT_ID);
|
FacesContext.getCurrentInstance()).getGlobalConfig().
|
||||||
|
getConfigElement(ClientConfigElement.CONFIG_ELEMENT_ID);
|
||||||
|
|
||||||
this.helpUrl = clientConfig.getHelpUrl();
|
this.helpUrl = clientConfig.getHelpUrl();
|
||||||
|
this.shelfExpanded = clientConfig.isShelfVisible();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------
|
||||||
// Inner classes
|
// Inner classes
|
||||||
|
|
||||||
@ -636,9 +637,6 @@ public class NavigationBean
|
|||||||
/** CIFS content disk driver bean reference */
|
/** CIFS content disk driver bean reference */
|
||||||
private ContentDiskInterface contentDiskDriver;
|
private ContentDiskInterface contentDiskDriver;
|
||||||
|
|
||||||
/** ConfigService bean reference */
|
|
||||||
private ConfigService configService;
|
|
||||||
|
|
||||||
/** Client configuration object */
|
/** Client configuration object */
|
||||||
private ClientConfigElement clientConfig = null;
|
private ClientConfigElement clientConfig = null;
|
||||||
|
|
||||||
|
@ -26,6 +26,7 @@ import javax.faces.event.ActionEvent;
|
|||||||
import javax.faces.model.SelectItem;
|
import javax.faces.model.SelectItem;
|
||||||
|
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
|
import org.alfresco.repo.cache.ExpiringValueCache;
|
||||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.repository.NodeService;
|
import org.alfresco.service.cmr.repository.NodeService;
|
||||||
@ -67,6 +68,9 @@ public abstract class BasePreviewBean
|
|||||||
|
|
||||||
protected NodeRef template;
|
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.
|
* @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.
|
* @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
|
List<SelectItem> templates = cachedTemplates.get();
|
||||||
// get the template from the special Content Templates folder
|
if (templates == null)
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
DictionaryService dd = Repository.getServiceRegistry(context).getDictionaryService();
|
// get the template from the special Content Templates folder
|
||||||
for (NodeRef ref : results)
|
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);
|
DictionaryService dd = Repository.getServiceRegistry(context).getDictionaryService();
|
||||||
if (dd.isSubClass(childNode.getType(), ContentModel.TYPE_CONTENT))
|
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
|
// add an entry (at the start) to instruct the user to select a template
|
||||||
QuickSort sorter = new QuickSort(templates, "label", true, IDataContainer.SORT_CASEINSENSITIVE);
|
templates.add(0, new SelectItem(NO_SELECTION, Application.getMessage(FacesContext.getCurrentInstance(), "select_a_template")));
|
||||||
sorter.sort();
|
|
||||||
|
cachedTemplates.put(templates);
|
||||||
}
|
}
|
||||||
|
|
||||||
// add an entry (at the start) to instruct the user to select a template
|
return templates;
|
||||||
templates.add(0, new SelectItem(NO_SELECTION, Application.getMessage(FacesContext.getCurrentInstance(), "select_a_template")));
|
|
||||||
|
|
||||||
return templates.toArray(new SelectItem[templates.size()]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -176,10 +185,10 @@ public abstract class BasePreviewBean
|
|||||||
/** Template Image resolver helper */
|
/** Template Image resolver helper */
|
||||||
protected TemplateImageResolver imageResolver = new TemplateImageResolver()
|
protected TemplateImageResolver imageResolver = new TemplateImageResolver()
|
||||||
{
|
{
|
||||||
public String resolveImagePathForName(String filename, boolean small)
|
public String resolveImagePathForName(String filename, boolean small)
|
||||||
{
|
{
|
||||||
return Utils.getFileTypeImage(filename, small);
|
return Utils.getFileTypeImage(filename, small);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -61,6 +61,7 @@ public class ClientConfigElement extends ConfigElementAdapter
|
|||||||
private List<String> descendingSorts = new ArrayList<String>(1);
|
private List<String> descendingSorts = new ArrayList<String>(1);
|
||||||
|
|
||||||
private int recentSpacesItems = 6;
|
private int recentSpacesItems = 6;
|
||||||
|
private boolean shelfVisible = true;
|
||||||
private int searchMinimum = 3;
|
private int searchMinimum = 3;
|
||||||
private String helpUrl = null;
|
private String helpUrl = null;
|
||||||
private String editLinkType = null;
|
private String editLinkType = null;
|
||||||
@ -260,6 +261,22 @@ public class ClientConfigElement extends ConfigElementAdapter
|
|||||||
this.recentSpacesItems = recentSpacesItems;
|
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.
|
* 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_PROPERTY = "property";
|
||||||
public static final String ATTRIBUTE_ASPECT = "aspect";
|
public static final String ATTRIBUTE_ASPECT = "aspect";
|
||||||
public static final String ATTRIBUTE_DISPLAYLABEL = "displayLabelId";
|
public static final String ATTRIBUTE_DISPLAYLABEL = "displayLabelId";
|
||||||
|
public static final String ELEMENT_SHELFVISIBLE = "shelf-visible";
|
||||||
|
|
||||||
private static Log logger = LogFactory.getLog(ClientElementReader.class);
|
private static Log logger = LogFactory.getLog(ClientElementReader.class);
|
||||||
|
|
||||||
@ -164,6 +165,13 @@ public class ClientElementReader implements ConfigElementReader
|
|||||||
configElement.setRecentSpacesItems(Integer.parseInt(recentSpaces.getTextTrim()));
|
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
|
// get the Help url
|
||||||
Element helpUrl = element.element(ELEMENT_HELPURL);
|
Element helpUrl = element.element(ELEMENT_HELPURL);
|
||||||
if (helpUrl != null)
|
if (helpUrl != null)
|
||||||
|
@ -74,10 +74,6 @@
|
|||||||
<property-name>cifsServer</property-name>
|
<property-name>cifsServer</property-name>
|
||||||
<value>#{cifsServer}</value>
|
<value>#{cifsServer}</value>
|
||||||
</managed-property>
|
</managed-property>
|
||||||
<managed-property>
|
|
||||||
<property-name>configService</property-name>
|
|
||||||
<value>#{configService}</value>
|
|
||||||
</managed-property>
|
|
||||||
</managed-bean>
|
</managed-bean>
|
||||||
|
|
||||||
<managed-bean>
|
<managed-bean>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user