use of org.alfresco.service.cmr.repository.InvalidNodeRefException in project acs-community-packaging by Alfresco.
the class BrowseBean method clickSpacePath.
/**
* Handler called when a path element is clicked - navigate to the appropriate Space
*/
public void clickSpacePath(ActionEvent event) {
UINodePath.PathElementEvent pathEvent = (UINodePath.PathElementEvent) event;
NodeRef ref = pathEvent.NodeReference;
try {
// refresh UI based on node selection
this.updateUILocation(ref);
} catch (InvalidNodeRefException refErr) {
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(FacesContext.getCurrentInstance(), Repository.ERROR_NODEREF), new Object[] { ref.getId() }));
}
}
use of org.alfresco.service.cmr.repository.InvalidNodeRefException in project acs-community-packaging by Alfresco.
the class BrowseBean method setupSpaceAction.
/**
* Public helper to setup action pages with Space context
*
* @param id of the Space node to setup context for
*/
public void setupSpaceAction(String id, boolean invalidate) {
if (id != null && id.length() != 0) {
if (logger.isDebugEnabled())
logger.debug("Setup for action, setting current space to: " + id);
try {
// create the node ref, then our node representation
NodeRef ref = new NodeRef(Repository.getStoreRef(), id);
Node node = new Node(ref);
// resolve icon in-case one has not been set
node.addPropertyResolver("icon", this.resolverSpaceIcon);
// prepare a node for the action context
setActionSpace(node);
// setup the dispatch context in case it is required
this.navigator.setupDispatchContext(node);
} catch (InvalidNodeRefException refErr) {
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(FacesContext.getCurrentInstance(), Repository.ERROR_NODEREF), new Object[] { id }));
}
} else {
setActionSpace(null);
}
// clear the UI state in preparation for finishing the next action
if (invalidate == true) {
// use the context service to notify all registered beans
UIContextService.getInstance(FacesContext.getCurrentInstance()).notifyBeans();
}
}
use of org.alfresco.service.cmr.repository.InvalidNodeRefException in project acs-community-packaging by Alfresco.
the class CategoriesDialog method clickCategory.
/**
* Action called when a category folder is clicked.
* Navigate into the category.
*/
public void clickCategory(ActionEvent event) {
UIActionLink link = (UIActionLink) event.getComponent();
Map<String, String> params = link.getParameterMap();
String id = params.get("id");
if (id != null && id.length() != 0) {
try {
NodeRef ref = new NodeRef(Repository.getStoreRef(), id);
// refresh UI based on node selection
updateUILocation(ref);
} catch (InvalidNodeRefException refErr) {
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(FacesContext.getCurrentInstance(), Repository.ERROR_NODEREF), new Object[] { id }));
}
}
}
use of org.alfresco.service.cmr.repository.InvalidNodeRefException in project acs-community-packaging by Alfresco.
the class CategoriesDialog method getCategories.
/**
* @return The list of categories Nodes to display. Returns the list root categories or the
* list of sub-categories for the current category if set.
*/
public List<Node> getCategories() {
List<Node> categories;
UserTransaction tx = null;
try {
FacesContext context = FacesContext.getCurrentInstance();
tx = Repository.getUserTransaction(context, true);
tx.begin();
Collection<ChildAssociationRef> refs;
if (getCategoryRef() == null) {
// root categories
refs = getCategoryService().getCategories(Repository.getStoreRef(), ContentModel.ASPECT_GEN_CLASSIFIABLE, Depth.IMMEDIATE);
} else {
// sub-categories of an existing category
refs = getCategoryService().getChildren(getCategoryRef(), Mode.SUB_CATEGORIES, Depth.IMMEDIATE);
}
categories = new ArrayList<Node>(refs.size());
for (ChildAssociationRef child : refs) {
Node categoryNode = new Node(child.getChildRef());
// force early props init within transaction
categoryNode.getProperties();
categories.add(categoryNode);
}
// commit the transaction
tx.commit();
} catch (InvalidNodeRefException refErr) {
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(FacesContext.getCurrentInstance(), Repository.ERROR_NODEREF), new Object[] { refErr.getNodeRef() }));
categories = 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);
categories = Collections.<Node>emptyList();
try {
if (tx != null) {
tx.rollback();
}
} catch (Exception tex) {
}
}
return categories;
}
use of org.alfresco.service.cmr.repository.InvalidNodeRefException in project acs-community-packaging by Alfresco.
the class CategoriesDialog method setupCategoryAction.
/**
* Set the Category to be used for next action dialog
*/
public void setupCategoryAction(ActionEvent event) {
UIActionLink link = (UIActionLink) event.getComponent();
Map<String, String> params = link.getParameterMap();
String id = params.get("id");
if (id != null && id.length() != 0) {
if (logger.isDebugEnabled())
logger.debug("Setup for action, setting current Category to: " + id);
try {
// create the node ref, then our node representation
NodeRef ref = new NodeRef(Repository.getStoreRef(), id);
Node node = new Node(ref);
// prepare a node for the action context
setActionCategory(node);
// clear datalist cache ready from return from action dialog
contextUpdated();
} catch (InvalidNodeRefException refErr) {
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(FacesContext.getCurrentInstance(), Repository.ERROR_NODEREF), new Object[] { id }));
}
}
}
Aggregations