use of org.alfresco.web.bean.NavigationBean in project acs-community-packaging by Alfresco.
the class AlfrescoNavigationHandler method handleDispatch.
private void handleDispatch(FacesContext context, String fromAction, String outcome, Node dispatchNode) {
if (dispatchNode != null) {
if (logger.isDebugEnabled())
logger.debug("Found node with type '" + dispatchNode.getType().toString() + "' in dispatch context");
// get the current view id
String viewId = context.getViewRoot().getViewId();
// see if there is any navigation config for the node type
ConfigService configSvc = Application.getConfigService(context);
NavigationConfigElement navigationCfg = null;
try {
Config nodeConfig = configSvc.getConfig(dispatchNode);
navigationCfg = (NavigationConfigElement) nodeConfig.getConfigElement(NavigationElementReader.ELEMENT_NAVIGATION);
} catch (InvalidNodeRefException e) {
if (logger.isDebugEnabled())
logger.debug("Invalid node reference: " + dispatchNode);
}
if (navigationCfg != null) {
// see if there is config for the current view state
NavigationResult navResult = navigationCfg.getOverride(viewId, outcome);
if (navResult != null) {
if (logger.isDebugEnabled())
logger.debug("Found navigation config: " + navResult);
if (navResult.isOutcome()) {
navigate(context, fromAction, navResult.getResult());
} else {
String newViewId = navResult.getResult();
if (newViewId.equals(viewId) == false) {
if (logger.isDebugEnabled())
logger.debug("Dispatching to new view id: " + newViewId);
goToView(context, newViewId);
} else {
if (logger.isDebugEnabled())
logger.debug("New view id is the same as the current one so setting outcome to null");
navigate(context, fromAction, null);
}
}
} else {
if (logger.isDebugEnabled())
logger.debug("No override configuration found for current view or outcome");
navigate(context, fromAction, outcome);
}
} else {
if (logger.isDebugEnabled())
logger.debug("No navigation configuration found for node");
navigate(context, fromAction, outcome);
}
// reset the dispatch context
((NavigationBean) context.getExternalContext().getSessionMap().get(NavigationBean.BEAN_NAME)).resetDispatchContext();
} else {
if (logger.isDebugEnabled())
logger.debug("No dispatch context found");
// pass off to the original handler
navigate(context, fromAction, outcome);
}
}
use of org.alfresco.web.bean.NavigationBean in project acs-community-packaging by Alfresco.
the class UserMembersBean method removeOK.
/**
* Action handler called when the OK button is clicked on the Remove User page
*/
public String removeOK() {
String outcome = getDefaultFinishOutcome();
UserTransaction tx = null;
FacesContext context = FacesContext.getCurrentInstance();
try {
tx = Repository.getUserTransaction(context);
tx.begin();
// remove the invited User
if (getPersonAuthority() != null) {
// clear permissions for the specified Authority
this.getPermissionService().clearPermission(getNode().getNodeRef(), getPersonAuthority());
}
// commit the transaction
tx.commit();
} catch (Exception e) {
// rollback the transaction
try {
if (tx != null) {
tx.rollback();
}
} catch (Exception tex) {
}
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(FacesContext.getCurrentInstance(), ERROR_DELETE), e.getMessage()), e);
}
// pressing the top level navigation button i.e. My Home
if (this.getPermissionService().hasPermission(getNode().getNodeRef(), PermissionService.CHANGE_PERMISSIONS) == AccessStatus.DENIED) {
NavigationBean nb = (NavigationBean) FacesHelper.getManagedBean(context, NavigationBean.BEAN_NAME);
if (nb != null) {
try {
nb.processToolbarLocation(nb.getToolbarLocation(), true);
outcome = "browse";
} catch (InvalidNodeRefException refErr) {
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(FacesContext.getCurrentInstance(), Repository.ERROR_NOHOME), Application.getCurrentUser(context).getHomeSpaceId()), refErr);
} catch (Exception err) {
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(FacesContext.getCurrentInstance(), Repository.ERROR_GENERIC), err.getMessage()), err);
}
}
}
return outcome;
}
use of org.alfresco.web.bean.NavigationBean in project acs-community-packaging by Alfresco.
the class UserPreferencesBean method getStartLocations.
/**
* @return the list of available start locations
*/
public SelectItem[] getStartLocations() {
FacesContext fc = FacesContext.getCurrentInstance();
NavigationBean navigator = (NavigationBean) FacesHelper.getManagedBean(fc, "NavigationBean");
ResourceBundle msg = Application.getBundle(fc);
List<SelectItem> locations = new ArrayList<SelectItem>(4);
// add My Alfresco location
locations.add(new SelectItem(NavigationBean.LOCATION_MYALFRESCO, msg.getString(NavigationBean.MSG_MYALFRESCO)));
// add My Home location
locations.add(new SelectItem(NavigationBean.LOCATION_HOME, msg.getString(NavigationBean.MSG_MYHOME)));
// add Company Home location if visible
if (navigator.getCompanyHomeVisible()) {
locations.add(new SelectItem(NavigationBean.LOCATION_COMPANY, msg.getString(NavigationBean.MSG_COMPANYHOME)));
}
// add Guest Home location if visible
if (navigator.getGuestHomeVisible()) {
locations.add(new SelectItem(NavigationBean.LOCATION_GUEST, msg.getString(NavigationBean.MSG_GUESTHOME)));
}
return locations.toArray(new SelectItem[locations.size()]);
}
Aggregations