public static void cutManage(Event<CutManageComponent> event, UIJCRExplorer uiExplorer) throws Exception { UIWorkingArea uiWorkingArea = event.getSource().getParent(); String nodePath = event.getRequestContext().getRequestParameter(OBJECTID); if (nodePath.indexOf(";") > -1) { uiWorkingArea.getVirtualClipboards().clear(); processMultipleCut(nodePath.split(";"), event, uiExplorer); } else { processCut(nodePath, event, uiExplorer, false); } }
public void processRender(UIContainer uicomponent, WebuiRequestContext context) throws Exception { UIWorkingArea uiWorkingArea = uicomponent.getAncestorOfType(UIWorkingArea.class); UIActionBar uiActionBar = uiWorkingArea.getChild(UIActionBar.class); boolean isUISelectDocumentTemplateTitleRendered = uiWorkingArea.isUISelectDocumentTemplateTitleRendered(); context .getWriter() .append("<div class=\"") .append(uicomponent.getId()) .append( isUISelectDocumentTemplateTitleRendered || uiActionBar.isRendered() ? StringUtils.EMPTY : " uiDocumentWorkspaceBox") .append("\" id=\"") .append(uicomponent.getId()) .append("\">"); uicomponent.renderChildren(context); context.getWriter().append("</div>"); }
private static void processCut( String nodePath, Event<CutManageComponent> event, UIJCRExplorer uiExplorer, boolean isMultiSelect) throws Exception { UIWorkingArea uiWorkingArea = uiExplorer.getChild(UIWorkingArea.class); UIApplication uiApp = event.getSource().getAncestorOfType(UIApplication.class); Matcher matcher = UIWorkingArea.FILE_EXPLORER_URL_SYNTAX.matcher(nodePath); String wsName = null; if (matcher.find()) { wsName = matcher.group(1); nodePath = matcher.group(2); } else { throw new IllegalArgumentException("The ObjectId is invalid '" + nodePath + "'"); } Session session = uiExplorer.getSessionByWorkspace(wsName); Node selectedNode; try { // Use the method getNodeByPath because it is link aware selectedNode = uiExplorer.getNodeByPath(nodePath, session, false); // Reset the path to manage the links that potentially create virtual path nodePath = selectedNode.getPath(); // Reset the session to manage the links that potentially change of workspace session = selectedNode.getSession(); // Reset the workspace name to manage the links that potentially change of workspace wsName = session.getWorkspace().getName(); } catch (ConstraintViolationException cons) { uiExplorer.getSession().refresh(false); uiExplorer.refreshExplorer(); uiApp.addMessage( new ApplicationMessage( "UIPopupMenu.msg.constraintviolation-exception", null, ApplicationMessage.WARNING)); uiExplorer.updateAjax(event); return; } catch (PathNotFoundException path) { uiApp.addMessage( new ApplicationMessage( "UIPopupMenu.msg.path-not-found-exception", null, ApplicationMessage.WARNING)); return; } catch (Exception e) { if (LOG.isErrorEnabled()) { LOG.error("an unexpected error occurs while cuting the node", e); } JCRExceptionManager.process(uiApp, e); return; } try { List<ClipboardCommand> clipboards = uiExplorer.getAllClipBoard(); for (ClipboardCommand command : clipboards) { if (command.getSrcPath().equals(nodePath)) { clipboards.remove(command); break; } } ClipboardCommand clipboard = new ClipboardCommand(); clipboard.setType(ClipboardCommand.CUT); clipboard.setSrcPath(nodePath); clipboard.setWorkspace(wsName); uiExplorer.getAllClipBoard().add(clipboard); if (isMultiSelect) { uiWorkingArea.getVirtualClipboards().add(clipboard); } else { session.save(); uiExplorer.updateAjax(event); } } catch (Exception e) { JCRExceptionManager.process(uiApp, e); } }