. Checkpoint of WCM UI

- Browsing of AVM files and folders within a sandbox
  - Navigation into sub-folders and viewing of file content

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3827 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Kevin Roast
2006-09-18 13:56:37 +00:00
parent 97ea14c605
commit 61175d2192
5 changed files with 547 additions and 15 deletions

View File

@@ -17,26 +17,35 @@
package org.alfresco.web.bean.wcm; package org.alfresco.web.bean.wcm;
import java.text.MessageFormat; import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import javax.faces.context.FacesContext; import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent; import javax.faces.event.ActionEvent;
import javax.transaction.UserTransaction;
import org.alfresco.model.ContentModel; import org.alfresco.model.ContentModel;
import org.alfresco.repo.avm.AVMNodeConverter;
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.service.cmr.dictionary.DictionaryService; import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.repository.ContentService;
import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.search.SearchService; import org.alfresco.service.cmr.search.SearchService;
import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.web.app.Application; import org.alfresco.web.app.Application;
import org.alfresco.web.app.context.IContextListener; import org.alfresco.web.app.context.IContextListener;
import org.alfresco.web.app.context.UIContextService; import org.alfresco.web.app.context.UIContextService;
import org.alfresco.web.app.servlet.DownloadContentServlet;
import org.alfresco.web.bean.BrowseBean; import org.alfresco.web.bean.BrowseBean;
import org.alfresco.web.bean.NavigationBean; import org.alfresco.web.bean.NavigationBean;
import org.alfresco.web.bean.repository.Node; import org.alfresco.web.bean.repository.Node;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.ui.common.Utils;
import org.alfresco.web.ui.common.component.IBreadcrumbHandler;
import org.alfresco.web.ui.common.component.UIActionLink; import org.alfresco.web.ui.common.component.UIActionLink;
import org.alfresco.web.ui.common.component.UIBreadcrumb;
import org.alfresco.web.ui.common.component.data.UIRichList; import org.alfresco.web.ui.common.component.data.UIRichList;
import org.alfresco.web.ui.wcm.WebResources; import org.alfresco.web.ui.wcm.WebResources;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
@@ -57,10 +66,16 @@ public class AVMBrowseBean implements IContextListener
private String sandbox; private String sandbox;
private String username; private String username;
private String sandboxTitle = null; private String sandboxTitle = null;
private String currentPath = null;
private UIRichList foldersRichList; private UIRichList foldersRichList;
private UIRichList filesRichList; private UIRichList filesRichList;
private List<Map> files = null;
private List<Map> folders = null;
private List<IBreadcrumbHandler> location = null;
/** The NodeService to be used by the bean */ /** The NodeService to be used by the bean */
protected NodeService nodeService; protected NodeService nodeService;
@@ -79,6 +94,9 @@ public class AVMBrowseBean implements IContextListener
/** The NavigationBean bean reference */ /** The NavigationBean bean reference */
protected NavigationBean navigator; protected NavigationBean navigator;
/** AVM service bean reference */
protected AVMService avmService;
/** /**
* Default Constructor * Default Constructor
@@ -94,6 +112,14 @@ public class AVMBrowseBean implements IContextListener
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
// Bean property getters and setters // Bean property getters and setters
/**
* @param avmService The AVMService to set.
*/
public void setAvmService(AVMService avmService)
{
this.avmService = avmService;
}
/** /**
* @param nodeService The NodeService to set. * @param nodeService The NodeService to set.
*/ */
@@ -259,12 +285,77 @@ public class AVMBrowseBean implements IContextListener
public List<Map> getFolders() public List<Map> getFolders()
{ {
return Collections.emptyList(); if (this.folders == null)
{
getNodes();
}
return this.folders;
} }
public List<Map> getFiles() public List<Map> getFiles()
{ {
return Collections.emptyList(); if (this.files == null)
{
getNodes();
}
return this.files;
}
private void getNodes()
{
UserTransaction tx = null;
try
{
FacesContext context = FacesContext.getCurrentInstance();
tx = Repository.getUserTransaction(context, true);
tx.begin();
Map<String, AVMNodeDescriptor> nodes = this.avmService.getDirectoryListing(-1, getCurrentPath());
this.files = new ArrayList<Map>(nodes.size());
this.folders = new ArrayList<Map>(nodes.size());
for (String name : nodes.keySet())
{
AVMNodeDescriptor avmRef = nodes.get(name);
// build the client representation of the AVM node
AVMNode node = new AVMNode(avmRef);
// add any common properties
// properties specific to folders or files
if (avmRef.isDirectory())
{
node.getProperties().put("smallIcon", BrowseBean.SPACE_SMALL_DEFAULT);
this.folders.add(node);
}
else
{
node.getProperties().put("fileType16", Utils.getFileTypeImage(name, true));
node.getProperties().put("url", DownloadContentServlet.generateBrowserURL(
AVMNodeConverter.ToNodeRef(-1, avmRef.getPath()), name));
this.files.add(node);
}
}
// commit the transaction
tx.commit();
}
catch (Throwable err)
{
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(
FacesContext.getCurrentInstance(), Repository.ERROR_GENERIC), err.getMessage()), err);
this.folders = Collections.<Map>emptyList();
this.files = Collections.<Map>emptyList();
try { if (tx != null) {tx.rollback();} } catch (Exception tex) {}
}
}
public void clickFolder(ActionEvent event)
{
UIActionLink link = (UIActionLink)event.getComponent();
Map<String, String> params = link.getParameterMap();
String path = params.get("id");
updateUILocation(path);
} }
/** /**
@@ -295,9 +386,65 @@ public class AVMBrowseBean implements IContextListener
this.sandboxTitle = null; this.sandboxTitle = null;
// update UI state ready for return to the previous screen // update UI state ready for return to the previous screen
this.location = null;
setCurrentPath(null);
}
/**
* @return Breadcrumb location list
*/
public List<IBreadcrumbHandler> getLocation()
{
if (this.location == null)
{
List<IBreadcrumbHandler> loc = new ArrayList<IBreadcrumbHandler>(8);
loc.add(new AVMBreadcrumbHandler(getCurrentPath()));
this.location = loc;
}
return this.location;
}
/**
* @param location Breadcrumb location list
*/
public void setLocation(List<IBreadcrumbHandler> location)
{
this.location = location;
}
/**
* @return the internal AVM path to the current folder for browsing
*/
private String getCurrentPath()
{
if (this.currentPath == null)
{
this.currentPath = AVMConstants.buildAVMStoreRootPath(getSandbox());
}
return this.currentPath;
}
/**
* @param path the internal AVM path to the current folder for browsing
*/
private void setCurrentPath(String path)
{
this.currentPath = path;
// update UI state ready for screen refresh
UIContextService.getInstance(FacesContext.getCurrentInstance()).notifyBeans(); UIContextService.getInstance(FacesContext.getCurrentInstance()).notifyBeans();
} }
/**
* Update the breadcrumb with the clicked Group location
*/
private void updateUILocation(String path)
{
this.location.add(new AVMBreadcrumbHandler(path));
setCurrentPath(path);
}
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
// IContextListener implementation // IContextListener implementation
@@ -311,20 +458,56 @@ public class AVMBrowseBean implements IContextListener
{ {
this.foldersRichList.setValue(null); this.foldersRichList.setValue(null);
} }
/* if (this.filesRichList != null)
// clear the value for the list components - will cause re-bind to it's data and refresh
if (this.forumsRichList != null)
{ {
this.forumsRichList.setValue(null); this.filesRichList.setValue(null);
if (this.forumsRichList.getInitialSortColumn() == null) }
this.files = null;
this.folders = null;
}
// ------------------------------------------------------------------------------
// Inner classes
/**
* Class to handle breadcrumb interaction for AVM page
*/
private class AVMBreadcrumbHandler implements IBreadcrumbHandler
{
private String path;
AVMBreadcrumbHandler(String path)
{
this.path = path;
}
public String navigationOutcome(UIBreadcrumb breadcrumb)
{
setCurrentPath(path);
setLocation((List)breadcrumb.getValue());
return null;
}
@Override
public String toString()
{
if (AVMConstants.buildAVMStoreRootPath(getSandbox()).equals(path))
{ {
// set the initial sort column and direction // don't display the 'root' webapps path as this will confuse users
this.forumsRichList.setInitialSortColumn( // instead display which sandbox we are in
this.viewsConfig.getDefaultSortColumn(PAGE_NAME_FORUMS)); String label = username;
this.forumsRichList.setInitialSortDescending( if (label == null)
this.viewsConfig.hasDescendingSort(PAGE_NAME_FORUMS)); {
label = Application.getMessage(FacesContext.getCurrentInstance(), MSG_SANDBOXSTAGING);
}
return label;
}
else
{
return path.substring(path.lastIndexOf('/') + 1);
} }
} }
*/
} }
} }

View File

@@ -50,7 +50,7 @@ public final class AVMConstants
public static String buildAVMStoreRootPath(String store) public static String buildAVMStoreRootPath(String store)
{ {
return store + ":/" + DIR_APPBASE + '/' + DIR_WEBAPPS + '/'; return store + ":/" + DIR_APPBASE + '/' + DIR_WEBAPPS;
} }
// names of the stores representing the layers for an AVM website // names of the stores representing the layers for an AVM website

View File

@@ -0,0 +1,220 @@
/*
* Copyright (C) 2005 Alfresco, Inc.
*
* Licensed under the Mozilla Public License version 1.1
* with a permitted attribution clause. You may obtain a
* copy of the License at
*
* http://www.alfresco.org/legal/license.txt
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific
* language governing permissions and limitations under the
* License.
*/
package org.alfresco.web.bean.wcm;
import java.io.Serializable;
import java.util.Collection;
import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;
import javax.faces.context.FacesContext;
import org.alfresco.repo.domain.PropertyValue;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
import org.alfresco.service.namespace.QName;
import org.alfresco.service.namespace.QNameMap;
import org.alfresco.web.bean.repository.NodePropertyResolver;
import org.alfresco.web.bean.repository.QNameNodeMap;
import org.alfresco.web.bean.repository.Repository;
/**
* @author Kevin Roast
*/
public class AVMNode implements Map<String, Object>
{
private QNameMap<String, Object> properties = null;
private ServiceRegistry services = null;
private AVMNodeDescriptor avmRef;
private String path;
private int version;
/**
* Constructor
*/
public AVMNode(AVMNodeDescriptor avmRef)
{
this.avmRef = avmRef;
this.version = -1; // TODO: why does avmNode.getVersionID() return 1?
this.path = avmRef.getPath();
getProperties();
}
/**
* @return All the properties known about this node.
*/
public final Map<String, Object> getProperties()
{
if (this.properties == null)
{
Map<QName, PropertyValue> props = getServiceRegistry().getAVMService().getNodeProperties(this.version, this.path);
this.properties = new QNameMap<String, Object>(getServiceRegistry().getNamespaceService());
for (QName qname: props.keySet())
{
PropertyValue propValue = props.get(qname);
this.properties.put(qname.toString(), propValue.getSerializableValue());
}
this.properties.put("id", this.path);
this.properties.put("path", this.path);
this.properties.put("name", this.avmRef.getName());
this.properties.put("created", this.avmRef.getCreateDate());
this.properties.put("modified", this.avmRef.getModDate());
}
return this.properties;
}
/**
* Determines whether the given property name is held by this node
*
* @param propertyName Property to test existence of
* @return true if property exists, false otherwise
*/
public final boolean hasProperty(String propertyName)
{
return getProperties().containsKey(propertyName);
}
private ServiceRegistry getServiceRegistry()
{
if (this.services == null)
{
this.services = Repository.getServiceRegistry(FacesContext.getCurrentInstance());
}
return this.services;
}
// ------------------------------------------------------------------------------------
// Map implementation - allows the Node bean to be accessed using JSF expression syntax
/**
* @see java.util.Map#clear()
*/
public void clear()
{
getProperties().clear();
}
/**
* @see java.util.Map#containsKey(java.lang.Object)
*/
public boolean containsKey(Object key)
{
return getProperties().containsKey(key);
}
/**
* @see java.util.Map#containsValue(java.lang.Object)
*/
public boolean containsValue(Object value)
{
return getProperties().containsKey(value);
}
/**
* @see java.util.Map#entrySet()
*/
public Set entrySet()
{
return getProperties().entrySet();
}
/**
* @see java.util.Map#get(java.lang.Object)
*/
public Object get(Object key)
{
Object obj = null;
// there are some things that aren't available as properties
// but from method calls, so for these handle them individually
Map<String, Object> props = getProperties();
/*if (propsInitialised == false)
{
// well known properties required as publically accessable map attributes
props.put("id", this.getId());
props.put("name", this.getName()); // TODO: perf test pulling back single prop here instead of all!
props.put("nodeRef", this.getNodeRef());
propsInitialised = true;
}*/
return props.get(key);
}
/**
* @see java.util.Map#isEmpty()
*/
public boolean isEmpty()
{
return getProperties().isEmpty();
}
/**
* @see java.util.Map#keySet()
*/
public Set keySet()
{
return getProperties().keySet();
}
/**
* @see java.util.Map#put(K, V)
*/
public Object put(String key, Object value)
{
return getProperties().put(key, value);
}
/**
* @see java.util.Map#putAll(java.util.Map)
*/
public void putAll(Map t)
{
getProperties().putAll(t);
}
/**
* @see java.util.Map#remove(java.lang.Object)
*/
public Object remove(Object key)
{
return getProperties().remove(key);
}
/**
* @see java.util.Map#size()
*/
public int size()
{
return getProperties().size();
}
/**
* @see java.util.Map#values()
*/
public Collection values()
{
return getProperties().values();
}
}

View File

@@ -595,6 +595,10 @@
<managed-bean-name>AVMBrowseBean</managed-bean-name> <managed-bean-name>AVMBrowseBean</managed-bean-name>
<managed-bean-class>org.alfresco.web.bean.wcm.AVMBrowseBean</managed-bean-class> <managed-bean-class>org.alfresco.web.bean.wcm.AVMBrowseBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope> <managed-bean-scope>session</managed-bean-scope>
<managed-property>
<property-name>avmService</property-name>
<value>#{AVMService}</value>
</managed-property>
<managed-property> <managed-property>
<property-name>navigationBean</property-name> <property-name>navigationBean</property-name>
<value>#{NavigationBean}</value> <value>#{NavigationBean}</value>

View File

@@ -88,6 +88,15 @@
<td><img src="<%=request.getContextPath()%>/images/parts/statuspanel_9.gif" width=4 height=9></td> <td><img src="<%=request.getContextPath()%>/images/parts/statuspanel_9.gif" width=4 height=9></td>
</tr> </tr>
<%-- Website Path Breadcrumb --%>
<tr>
<td style="background-image: url(<%=request.getContextPath()%>/images/parts/whitepanel_4.gif)" width=4></td>
<td style="padding-left:8px;padding-top:4px;padding-bottom:4px">
<a:breadcrumb value="#{AVMBrowseBean.location}" styleClass="title" />
</td>
<td style="background-image: url(<%=request.getContextPath()%>/images/parts/whitepanel_6.gif)" width=4></td>
</tr>
<%-- Details - Folders --%> <%-- Details - Folders --%>
<tr valign=top> <tr valign=top>
<td style="background-image: url(<%=request.getContextPath()%>/images/parts/whitepanel_4.gif)" width=4></td> <td style="background-image: url(<%=request.getContextPath()%>/images/parts/whitepanel_4.gif)" width=4></td>
@@ -100,6 +109,60 @@
styleClass="recordSet" headerStyleClass="recordSetHeader" rowStyleClass="recordSetRow" altRowStyleClass="recordSetRowAlt" width="100%" styleClass="recordSet" headerStyleClass="recordSetHeader" rowStyleClass="recordSetRow" altRowStyleClass="recordSetRowAlt" width="100%"
value="#{AVMBrowseBean.folders}" var="r"> value="#{AVMBrowseBean.folders}" var="r">
<%-- Primary column with folder name --%>
<a:column primary="true" width="200" style="padding:2px;text-align:left">
<f:facet name="header">
<a:sortLink label="#{msg.name}" value="name" mode="case-insensitive" styleClass="header"/>
</f:facet>
<f:facet name="small-icon">
<a:actionLink id="col1-act1" value="#{r.name}" image="/images/icons/#{r.smallIcon}.gif" actionListener="#{AVMBrowseBean.clickFolder}" showLink="false">
<f:param name="id" value="#{r.id}" />
</a:actionLink>
</f:facet>
<a:actionLink id="col1-act2" value="#{r.name}" actionListener="#{AVMBrowseBean.clickFolder}">
<f:param name="id" value="#{r.id}" />
</a:actionLink>
</a:column>
<%-- Description column for all view modes --%>
<a:column id="col4" style="text-align:left">
<f:facet name="header">
<a:sortLink id="col4-sort" label="#{msg.description}" value="description" styleClass="header"/>
</f:facet>
<h:outputText id="col4-txt" value="#{r.description}" />
</a:column>
<%-- Created Date column for details view mode --%>
<a:column id="col6" style="text-align:left">
<f:facet name="header">
<a:sortLink id="col6-sort" label="#{msg.created}" value="created" styleClass="header"/>
</f:facet>
<h:outputText id="col6-txt" value="#{r.created}">
<a:convertXMLDate type="both" pattern="#{msg.date_time_pattern}" />
</h:outputText>
</a:column>
<%-- Modified Date column for details/icons view modes --%>
<a:column id="col7" style="text-align:left">
<f:facet name="header">
<a:sortLink id="col7-sort" label="#{msg.modified}" value="modified" styleClass="header"/>
</f:facet>
<h:outputText id="col7-txt" value="#{r.modified}">
<a:convertXMLDate type="both" pattern="#{msg.date_time_pattern}" />
</h:outputText>
</a:column>
<%-- Space Actions column --%>
<a:column id="col9" actions="true" style="text-align:left">
<f:facet name="header">
<h:outputText id="col9-txt" value="#{msg.actions}"/>
</f:facet>
<%-- actions are configured in web-client-config-actions.xml --%>
<%--<r:actions id="col9-acts1" value="space_browse" context="#{r}" showLink="false" styleClass="inlineAction" />--%>
</a:column>
<a:dataPager id="pager1" styleClass="pager" />
</a:richList> </a:richList>
</a:panel> </a:panel>
@@ -120,6 +183,68 @@
styleClass="recordSet" headerStyleClass="recordSetHeader" rowStyleClass="recordSetRow" altRowStyleClass="recordSetRowAlt" width="100%" styleClass="recordSet" headerStyleClass="recordSetHeader" rowStyleClass="recordSetRow" altRowStyleClass="recordSetRowAlt" width="100%"
value="#{AVMBrowseBean.files}" var="r"> value="#{AVMBrowseBean.files}" var="r">
<%-- Primary column for details view mode --%>
<a:column id="col10" primary="true" width="200" style="padding:2px;text-align:left">
<f:facet name="header">
<a:sortLink id="col10-sort" label="#{msg.name}" value="name" mode="case-insensitive" styleClass="header"/>
</f:facet>
<f:facet name="small-icon">
<a:actionLink id="col10-act1" value="#{r.name}" href="#{r.url}" target="new" image="#{r.fileType16}" showLink="false" styleClass="inlineAction" />
</f:facet>
<a:actionLink id="col10-act2" value="#{r.name}" href="#{r.url}" target="new" />
<r:lockIcon id="col10-lock" value="#{r.nodeRef}" align="absmiddle" />
</a:column>
<%-- Description column for all view modes --%>
<a:column id="col13" style="text-align:left">
<f:facet name="header">
<a:sortLink id="col13-sort" label="#{msg.description}" value="description" styleClass="header"/>
</f:facet>
<h:outputText id="col13-txt" value="#{r.description}" />
</a:column>
<%-- Size for details/icons view modes --%>
<a:column id="col15" style="text-align:left">
<f:facet name="header">
<a:sortLink id="col15-sort" label="#{msg.size}" value="size" styleClass="header"/>
</f:facet>
<h:outputText id="col15-txt" value="#{r.size}">
<a:convertSize />
</h:outputText>
</a:column>
<%-- Created Date column for details view mode --%>
<a:column id="col16" style="text-align:left">
<f:facet name="header">
<a:sortLink id="col16-sort" label="#{msg.created}" value="created" styleClass="header"/>
</f:facet>
<h:outputText id="col16-txt" value="#{r.created}">
<a:convertXMLDate type="both" pattern="#{msg.date_time_pattern}" />
</h:outputText>
</a:column>
<%-- Modified Date column for details/icons view modes --%>
<a:column id="col17" style="text-align:left">
<f:facet name="header">
<a:sortLink id="col17-sort" label="#{msg.modified}" value="modified" styleClass="header"/>
</f:facet>
<h:outputText id="col17-txt" value="#{r.modified}">
<a:convertXMLDate type="both" pattern="#{msg.date_time_pattern}" />
</h:outputText>
</a:column>
<%-- Content Actions column --%>
<a:column id="col18" actions="true" style="text-align:left">
<f:facet name="header">
<h:outputText id="col18-txt" value="#{msg.actions}"/>
</f:facet>
<%-- actions are configured in web-client-config-actions.xml --%>
<%-- <r:actions id="col18-acts1" value="document_browse" context="#{r}" showLink="false" styleClass="inlineAction" /> --%>
</a:column>
<a:dataPager id="pager2" styleClass="pager" />
</a:richList> </a:richList>
</a:panel> </a:panel>