use of org.alfresco.web.bean.repository.Node in project acs-community-packaging by Alfresco.
the class BrowseBean method updateUILocation.
/**
* Refresh the UI after a Space selection change. Adds the selected space to the breadcrumb
* location path and also updates the list components in the UI.
*
* @param ref NodeRef of the selected space
*/
public void updateUILocation(NodeRef ref) {
// get the current breadcrumb location and append a new handler to it
// our handler know the ID of the selected node and the display label for it
List<IBreadcrumbHandler> location = this.navigator.getLocation();
if (location.size() != 0) {
// attempt to find the ID - if it's already in the breadcrumb then we
// navigate directly to that node - rather than add duplication to the breadcrumb path
boolean foundNode = false;
for (int i = 0; i < location.size(); i++) {
IBreadcrumbHandler element = location.get(i);
if (element instanceof IRepoBreadcrumbHandler) {
NodeRef nodeRef = ((IRepoBreadcrumbHandler) element).getNodeRef();
if (ref.equals(nodeRef) == true) {
// TODO: we should be able to do this - but the UIBreadcrumb component modifies
// it's own internal value when clicked - then uses that from then on!
// the other ops are using the same List object and modding it directly.
// List<IBreadcrumbHandler> newLocation = new ArrayList<IBreadcrumbHandler>(i+1);
// newLocation.addAll(location.subList(0, i + 1));
// this.navigator.setLocation(newLocation);
// TODO: but instead for now we do this:
int count = location.size();
for (int n = i + 1; n < count; n++) {
location.remove(i + 1);
}
foundNode = true;
break;
}
}
}
// add new node to the end of the existing breadcrumb
if (foundNode == false) {
FacesContext context = FacesContext.getCurrentInstance();
String breadcrumbMode = Application.getClientConfig(context).getBreadcrumbMode();
if (ClientConfigElement.BREADCRUMB_LOCATION.equals(breadcrumbMode)) {
// if the breadcrumb is in "location" mode set the breadcrumb
// to the full path to the node
// TODO: check the end of the current breadcrumb, if the given
// node is a child then we can shortcut the build of the
// whole path.
Repository.setupBreadcrumbLocation(context, this.navigator, location, ref);
} else {
// if the breadcrum is in "path" mode just add the given item to the end
String name = Repository.getNameForNode(this.getNodeService(), ref);
location.add(new BrowseBreadcrumbHandler(ref, name));
}
}
} else {
// special case to add first item to the location
String name = Repository.getNameForNode(this.getNodeService(), ref);
location.add(new BrowseBreadcrumbHandler(ref, name));
}
if (logger.isDebugEnabled())
logger.debug("Updated breadcrumb: " + location);
// set the current node Id ready for page refresh
this.navigator.setCurrentNodeId(ref.getId());
// set up the dispatch context for the navigation handler
this.navigator.setupDispatchContext(new Node(ref));
// inform any listeners that the current space has changed
UIContextService.getInstance(FacesContext.getCurrentInstance()).spaceChanged();
navigateBrowseScreen();
}
use of org.alfresco.web.bean.repository.Node in project acs-community-packaging by Alfresco.
the class BrowseBean method isSitesSpace.
/**
* Determines whether the current space is a 'Sites' space
*
* @return true if the current space is a 'Sites' space
*/
public boolean isSitesSpace() {
boolean siteSpace = false;
Node currentNode = this.navigator.getCurrentNode();
if (currentNode != null) {
// check the type of the node to see if it is a 'site' related space
QName currentNodeType = currentNode.getType();
if (SiteModel.TYPE_SITES.isMatch(currentNodeType) || SiteModel.TYPE_SITE.isMatch(currentNodeType) || getDictionaryService().isSubClass(currentNodeType, SiteModel.TYPE_SITE)) {
siteSpace = true;
}
}
return siteSpace;
}
use of org.alfresco.web.bean.repository.Node in project acs-community-packaging by Alfresco.
the class BrowseBean method deleteSpace.
/**
* Handles the deleteSpace action by deciding which delete dialog to display
*/
public void deleteSpace(ActionEvent event) {
setupDeleteAction(event);
boolean hasMultipleParents = false;
boolean showDeleteAssocDialog = false;
// determine if the node being delete has multiple parents
Node node = this.getActionSpace();
List<ChildAssociationRef> parents = this.nodeService.getParentAssocs(node.getNodeRef(), ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL);
if (parents != null && parents.size() > 1) {
hasMultipleParents = true;
}
// determine which delete dialog to display
if (this.navigator.getSearchContext() == null && hasMultipleParents) {
// if we are not in a search and the node has multiple parents
// see if the current node has the primary parent association
NodeRef parentSpace = this.navigator.getCurrentNode().getNodeRef();
ChildAssociationRef assoc = this.nodeService.getPrimaryParent(node.getNodeRef());
// show delete assoc dialog if the current space is not the primary parent for the node
showDeleteAssocDialog = !parentSpace.equals(assoc.getParentRef());
}
// show the appropriate dialog
FacesContext fc = FacesContext.getCurrentInstance();
if (showDeleteAssocDialog) {
fc.getApplication().getNavigationHandler().handleNavigation(fc, null, "dialog:deleteSpaceAssoc");
} else {
final Map<String, String> dialogParams = new HashMap<String, String>(1);
dialogParams.put("hasMultipleParents", Boolean.toString(hasMultipleParents));
Application.getDialogManager().setupParameters(dialogParams);
fc.getApplication().getNavigationHandler().handleNavigation(fc, null, "dialog:deleteSpace");
}
}
use of org.alfresco.web.bean.repository.Node in project acs-community-packaging by Alfresco.
the class BrowseBean method queryBrowseNodes.
// ------------------------------------------------------------------------------
// Helper methods
/**
* 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<FileInfo> children = null;
FileFilterMode.setClient(Client.webclient);
try {
children = this.getFileFolderService().list(parentRef);
} finally {
FileFilterMode.clearClient();
}
this.containerNodes = new ArrayList<Node>(children.size());
this.contentNodes = new ArrayList<Node>(children.size());
// in case of dynamic config, only lookup once
Set<NodeEventListener> nodeEventListeners = 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);
} else // look for Space folder node
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);
this.containerNodes.add(node);
} else // look for File Link object node
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("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.<Node>emptyList();
this.contentNodes = Collections.<Node>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.<Node>emptyList();
this.contentNodes = Collections.<Node>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");
}
}
use of org.alfresco.web.bean.repository.Node in project acs-community-packaging by Alfresco.
the class BrowseBean method setupDeleteAction.
/**
* Acrtion event called by Delete Space actions. We setup the action space as normal, then prepare
* any special case message string to be shown to the user if they are trying to delete specific spaces.
*/
public void setupDeleteAction(ActionEvent event) {
String message = null;
setupSpaceAction(event);
Node node = getActionSpace();
if (node != null) {
FacesContext fc = FacesContext.getCurrentInstance();
NodeRef companyRootRef = new NodeRef(Repository.getStoreRef(), Application.getCompanyRootId(fc));
if (node.getNodeRef().equals(companyRootRef)) {
message = Application.getMessage(fc, MSG_DELETE_COMPANYROOT);
}
}
setDeleteMessage(message);
}
Aggregations