use of org.alfresco.web.bean.repository.Node in project acs-community-packaging by Alfresco.
the class BrowseBean method setupContentAction.
/**
* Public helper to setup action pages with content context
*
* @param id of the content node to setup context for
*/
public void setupContentAction(String id, boolean invalidate) {
if (id != null && id.length() != 0) {
if (logger.isDebugEnabled())
logger.debug("Setup for action, setting current document to: " + id);
try {
// create the node ref, then our node representation
NodeRef ref = new NodeRef(Repository.getStoreRef(), id);
Node node = new MapNode(ref);
// store the URL to for downloading the content
if (ApplicationModel.TYPE_FILELINK.equals(node.getType())) {
node.addPropertyResolver("url", this.resolverLinkDownload);
node.addPropertyResolver("downloadUrl", this.resolverLinkDownload);
} else {
node.addPropertyResolver("url", this.resolverDownload);
node.addPropertyResolver("downloadUrl", this.resolverDownload);
}
node.addPropertyResolver("webdavUrl", this.resolverWebdavUrl);
node.addPropertyResolver("cifsPath", this.resolverCifsPath);
node.addPropertyResolver("fileType32", this.resolverFileType32);
node.addPropertyResolver("mimetype", this.resolverMimetype);
node.addPropertyResolver("encoding", this.resolverEncoding);
node.addPropertyResolver("size", this.resolverSize);
node.addPropertyResolver("lang", this.resolverLang);
for (NodeEventListener listener : getNodeEventListeners()) {
listener.created(node, node.getType());
}
// get hold of the DocumentDetailsDialog and reset it
DocumentDetailsDialog docDetails = (DocumentDetailsDialog) FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("DocumentDetailsDialog");
if (docDetails != null) {
docDetails.reset();
}
// remember the document
setDocument(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 }));
throw new AbortProcessingException("Invalid node reference");
}
} else {
setDocument(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.web.bean.repository.Node 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.web.bean.repository.Node 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.web.bean.repository.Node 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 }));
}
}
}
use of org.alfresco.web.bean.repository.Node in project acs-community-packaging by Alfresco.
the class DeleteCategoryDialog method init.
@Override
public void init(Map<String, String> parameters) {
this.isFinished = false;
this.categoryFlag = false;
// retrieve parameters
String categoryRef = parameters.get(CategoriesDialog.PARAM_CATEGORY_REF);
// make sure nodeRef was supplied
ParameterCheck.mandatoryString(CategoriesDialog.PARAM_CATEGORY_REF, categoryRef);
// create the node
this.category = new Node(new NodeRef(categoryRef));
setActionCategory(category);
}
Aggregations