use of javax.faces.context.FacesContext in project acs-community-packaging by Alfresco.
the class EditNodeCategoriesDialog method init.
// ------------------------------------------------------------------------------
// Dialog implementation
@Override
public void init(Map<String, String> parameters) {
super.init(parameters);
// reset variables
this.categories = null;
this.addedCategory = null;
// retrieve parameters
String nodeRef = parameters.get("nodeRef");
// make sure nodeRef was supplied
ParameterCheck.mandatoryString("nodeRef", nodeRef);
// create the node
this.node = new Node(new NodeRef(nodeRef));
// determine description for dialog
FacesContext context = FacesContext.getCurrentInstance();
if (getDictionaryService().isSubClass(this.node.getType(), ContentModel.TYPE_FOLDER)) {
this.description = Application.getMessage(context, "editcategory_space_description");
} else {
this.description = Application.getMessage(context, "editcategory_description");
}
}
use of javax.faces.context.FacesContext in project acs-community-packaging by Alfresco.
the class ClipboardBean method addClipboardNode.
/**
* Add a clipboard node to the clipboard ready for a cut/copy operation
*
* @param ref NodeRef of the item for the operation
* @param parent Parent of the item for the operation
* @param mode ClipboardStatus for the operation
*/
private void addClipboardNode(NodeRef ref, NodeRef parent, ClipboardStatus mode) {
// construct item based on store protocol
ClipboardItem item = null;
if (StoreRef.PROTOCOL_WORKSPACE.equals(ref.getStoreRef().getProtocol())) {
item = new WorkspaceClipboardItem(ref, parent, mode, customPasteViewIds);
}
if (item != null) {
// check for duplicates first
boolean foundDuplicate = false;
for (int i = 0; i < items.size(); i++) {
if (items.get(i).equals(item)) {
// found a duplicate replace with new instance as copy mode may have changed
items.set(i, item);
foundDuplicate = true;
break;
}
}
// if duplicate not found, then append to list
if (foundDuplicate == false) {
items.add(item);
}
// add a message to inform the user of the clipboard state now if configured
FacesContext context = FacesContext.getCurrentInstance();
if (Application.getClientConfig(context).isClipboardStatusVisible()) {
String pattern = Application.getMessage(context, "node_added_clipboard");
String msg = MessageFormat.format(pattern, items.size());
FacesMessage facesMsg = new FacesMessage(FacesMessage.SEVERITY_INFO, msg, msg);
context.addMessage(null, facesMsg);
}
}
}
use of javax.faces.context.FacesContext in project acs-community-packaging by Alfresco.
the class AjaxServlet method service.
/**
* @see javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
*/
protected void service(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException {
request.setCharacterEncoding("utf-8");
// set default character encoding for the response
response.setCharacterEncoding("utf-8");
response.setContentType("text/xml;charset=UTF-8");
long startTime = 0;
String uri = request.getRequestURI();
if (logger.isDebugEnabled()) {
final String queryString = request.getQueryString();
logger.debug("Processing URL: " + uri + ((queryString != null && queryString.length() > 0) ? ("?" + queryString) : ""));
}
// dump the request headers
if (headersLogger.isDebugEnabled()) {
final Enumeration<?> headers = request.getHeaderNames();
while (headers.hasMoreElements()) {
final String name = (String) headers.nextElement();
headersLogger.debug(name + ": " + request.getHeader(name));
}
}
try {
// Make sure the user is authenticated, if not throw an error to return the
// 500 Internal Server Error code back to the client
AuthenticationStatus status = servletAuthenticate(request, response, false);
if (status == AuthenticationStatus.Failure) {
response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Access Denied: User not authenticated");
return;
}
setNoCacheHeaders(response);
uri = uri.substring(request.getContextPath().length() + "/".length());
final String[] tokens = uri.split("/");
if (tokens.length < 3) {
throw new AlfrescoRuntimeException("Servlet URL did not contain all required args: " + uri);
}
// retrieve the command from the URL
final String commandName = tokens[1];
// retrieve the binding expression from the URL
final String expression = tokens[2];
// setup the faces context
final FacesContext facesContext = FacesHelper.getFacesContext(request, response, getServletContext());
// start a timer
if (perfLogger.isDebugEnabled())
startTime = System.currentTimeMillis();
// instantiate the relevant command
AjaxCommand command = null;
if (Command.invoke.toString().equals(commandName)) {
command = new InvokeCommand();
} else if (Command.get.toString().equals(commandName)) {
command = new GetCommand();
} else {
throw new AlfrescoRuntimeException("Unrecognised command received: " + commandName);
}
// execute the command
command.execute(facesContext, expression, request, response);
} catch (RuntimeException error) {
handleError(response, error);
} finally {
// measure the time taken
if (perfLogger.isDebugEnabled()) {
perfLogger.debug("Time to execute command: " + (System.currentTimeMillis() - startTime) + "ms");
}
ContextHolder.setContext(null);
}
}
use of javax.faces.context.FacesContext in project acs-community-packaging by Alfresco.
the class EditContentPropertiesCommand method execute.
/**
* @see org.alfresco.web.app.servlet.command.Command#execute(org.alfresco.service.ServiceRegistry, java.util.Map)
*/
public Object execute(ServiceRegistry serviceRegistry, Map<String, Object> properties) {
ServletContext sc = (ServletContext) properties.get(PROP_SERVLETCONTEXT);
ServletRequest req = (ServletRequest) properties.get(PROP_REQUEST);
ServletResponse res = (ServletResponse) properties.get(PROP_RESPONSE);
FacesContext fc = FacesHelper.getFacesContext(req, res, sc, "/jsp/close.jsp");
BrowseBean browseBean = (BrowseBean) FacesHelper.getManagedBean(fc, BrowseBean.BEAN_NAME);
// setup context from url args in properties map
String strNodeRef = (String) properties.get(PROP_NODEREF);
ParameterCheck.mandatoryString(PROP_NODEREF, strNodeRef);
browseBean.setDocument(new Node(new NodeRef(strNodeRef)));
NavigationHandler navigationHandler = fc.getApplication().getNavigationHandler();
navigationHandler.handleNavigation(fc, null, "dialog:editContentProperties");
String viewId = fc.getViewRoot().getViewId();
try {
sc.getRequestDispatcher(BaseServlet.FACES_SERVLET + viewId).forward(req, res);
} catch (Exception e) {
throw new AlfrescoRuntimeException("Unable to forward to viewId: " + viewId, e);
}
return null;
}
use of javax.faces.context.FacesContext in project acs-community-packaging by Alfresco.
the class ManageTaskDialogCommand method execute.
/**
* @see org.alfresco.web.app.servlet.command.Command#execute(org.alfresco.service.ServiceRegistry, java.util.Map)
*/
public Object execute(ServiceRegistry serviceRegistry, Map<String, Object> properties) {
ServletContext sc = (ServletContext) properties.get(PROP_SERVLETCONTEXT);
ServletRequest req = (ServletRequest) properties.get(PROP_REQUEST);
ServletResponse res = (ServletResponse) properties.get(PROP_RESPONSE);
FacesContext fc = FacesHelper.getFacesContext(req, res, sc, "/jsp/close.jsp");
WorkflowBean wfBean = (WorkflowBean) FacesHelper.getManagedBean(fc, WorkflowBean.BEAN_NAME);
// setup dialog context from url args in properties map
String taskId = (String) properties.get(PROP_TASKID);
ParameterCheck.mandatoryString(PROP_TASKID, taskId);
String taskType = (String) properties.get(PROP_TASKTYPE);
ParameterCheck.mandatoryString(PROP_TASKTYPE, taskType);
wfBean.setupTaskDialog(taskId, taskType);
NavigationHandler navigationHandler = fc.getApplication().getNavigationHandler();
navigationHandler.handleNavigation(fc, null, "dialog:manageTask");
String viewId = fc.getViewRoot().getViewId();
try {
sc.getRequestDispatcher(BaseServlet.FACES_SERVLET + viewId).forward(req, res);
} catch (Exception e) {
throw new AlfrescoRuntimeException("Unable to forward to viewId: " + viewId, e);
}
return null;
}
Aggregations