Esempio n. 1
0
 public void execute(Event<UIAddAttachment> event) throws Exception {
   UIAddAttachment component = event.getSource();
   EventUIComponent eventUIComponent = component.getTargetAttachEvent();
   UIPortletApplication portlet = component.getAncestorOfType(UIPortletApplication.class);
   UIComponent targerComponent = portlet.findComponentById(eventUIComponent.getId());
   Event<UIComponent> xEvent =
       targerComponent.createEvent(
           eventUIComponent.getEventName(), Event.Phase.PROCESS, event.getRequestContext());
   if (!StringUtils.isEmpty(getSelectedFile(event))) {
     processEvent(event);
   } else {
     event
         .getRequestContext()
         .getUIApplication()
         .addMessage(
             new ApplicationMessage(
                 "UIAddAttachment.msg.not-a-file", null, ApplicationMessage.WARNING));
     ((PortalRequestContext) event.getRequestContext().getParentAppRequestContext())
         .ignoreAJAXUpdateOnPortlets(true);
     return;
   }
   if (xEvent != null) {
     xEvent.broadcast();
   }
   UIPopupWindow uiPopupWindow = event.getSource().getParent();
   uiPopupWindow.setRendered(false);
   uiPopupWindow.setUIComponent(null);
   event.getRequestContext().addUIComponentToUpdateByAjax(uiPopupWindow.getParent());
 }
Esempio n. 2
0
 /**
  * Gets the popup container.
  *
  * @param container the current container
  * @return the popup container
  */
 public static UIPopupContainer getPopupContainer(UIContainer container) {
   if (container instanceof UIPortletApplication)
     return container.getChild(UIPopupContainer.class);
   UIPortletApplication portletApplication =
       container.getAncestorOfType(UIPortletApplication.class);
   return portletApplication.getChild(UIPopupContainer.class);
 }
 @Override
 public void processRender(WebuiRequestContext context) throws Exception {
   boolean canAccessMenu = canAcceedMenu();
   if (canAccessMenu) {
     super.processRender(context);
   }
 }
 public void processRender(WebuiApplication app, WebuiRequestContext context) throws Exception {
   // A user could view the toolbar portlet if he has edit permission
   // either on 'active' page, 'active' portal or 'active' navigation
   boolean canAccessMenu = canAcceedMenu();
   if (canAccessMenu) {
     super.processRender(app, context);
   }
 }
  public void processRender(WebuiApplication app, WebuiRequestContext context) throws Exception {
    getChildren().clear();
    PortletRequestContext pContext = (PortletRequestContext) context;
    PortletMode currentMode = pContext.getApplicationMode();

    if (getChild(UIDocumentDemo.class) == null) addChild(UIDocumentDemo.class, null, null);

    super.processRender(app, context);
  }
  /*
   * (non-Javadoc)
   * @see
   * org.exoplatform.webui.core.UIPortletApplication#processRender(org.exoplatform
   * .webui.application.WebuiApplication,
   * org.exoplatform.webui.application.WebuiRequestContext)
   */
  public void processRender(WebuiApplication app, WebuiRequestContext context) throws Exception {
    PortletRequestContext pContext = (PortletRequestContext) context;
    PortletMode newMode = pContext.getApplicationMode();
    PortletPreferences preferences = pContext.getRequest().getPreferences();
    Boolean sharedCache = "true".equals(preferences.getValue(ENABLE_CACHE, "true"));

    if (context.getRemoteUser() == null
        || (Utils.isLiveMode()
            && sharedCache
            && !Utils.isPortalEditMode()
            && Utils.isPortletViewMode(pContext))) {
      WCMService wcmService = getApplicationComponent(WCMService.class);
      pContext
          .getResponse()
          .setProperty(MimeResponse.EXPIRATION_CACHE, "" + wcmService.getPortletExpirationCache());
      if (log.isTraceEnabled())
        log.trace("SCV rendering : cache set to " + wcmService.getPortletExpirationCache());
    }

    if (!newMode.equals(mode)) {
      activateMode(newMode);
      mode = newMode;
    }

    Node nodeView = null;
    if (uiPresentation != null) {
      nodeView = uiPresentation.getNodeView();
      if (nodeView != null) {
        TemplateService templateService = getApplicationComponent(TemplateService.class);
        uiPresentation
            .getChild(UIPresentation.class)
            .setTemplatePath(templateService.getTemplatePath(nodeView, false));
      }
    }

    if (uiPresentation != null && uiPresentation.isContextual() && nodeView != null) {
      RenderResponse response = context.getResponse();
      Element title = response.createElement("title");
      title.setTextContent(uiPresentation.getTitle(nodeView));
      response.addProperty(MimeResponse.MARKUP_HEAD_ELEMENT, title);
    }

    if (context.getRemoteUser() != null && WCMComposer.MODE_EDIT.equals(Utils.getCurrentMode())) {
      pContext.getJavascriptManager().loadScriptResource(ResourceScope.SHARED, "content-selector");
      pContext.getJavascriptManager().loadScriptResource(ResourceScope.SHARED, "quick-edit");
    }

    setId(UISingleContentViewerPortlet.class.getSimpleName() + pContext.getWindowId());
    super.processRender(app, context);
  }
  @Override
  public void serveResource(WebuiRequestContext context) throws Exception {
    super.serveResource(context);

    ResourceRequest req = context.getRequest();
    String nodeURI = req.getResourceID();

    JSONArray jsChilds = getChildrenAsJSON(nodeURI);
    if (jsChilds == null) {
      return;
    }

    MimeResponse res = context.getResponse();
    res.setContentType("text/json");
    res.getWriter().write(jsChilds.toString());
  }
Esempio n. 8
0
 public void processRender(WebuiApplication app, WebuiRequestContext context) throws Exception {
   super.processRender(app, context);
 }
Esempio n. 9
0
    public void execute(Event<UISpaceInfo> event) throws Exception {
      UISpaceInfo uiSpaceInfo = event.getSource();
      SpaceService spaceService = uiSpaceInfo.getSpaceService();
      UIPortal uiPortal = Util.getUIPortal();

      String id = uiSpaceInfo.getUIStringInput(SPACE_ID).getValue();
      String name = uiSpaceInfo.getUIStringInput(SPACE_DISPLAY_NAME).getValue();
      Space space = spaceService.getSpaceById(id);
      String oldDisplayName = space.getDisplayName();
      String existingDescription = space.getDescription();

      if (space == null) {
        // redirect to spaces
        event.getRequestContext().sendRedirect(Utils.getURI("all-spaces"));
        return;
      }

      UserNode selectedNode = uiPortal.getSelectedUserNode();
      UserNode renamedNode = null;

      boolean nameChanged = (!space.getDisplayName().equals(name));
      UIPortletApplication uiApp = uiSpaceInfo.getAncestorOfType(UIPortletApplication.class);
      if (nameChanged) {

        String cleanedString = SpaceUtils.cleanString(name);
        if (spaceService.getSpaceByUrl(cleanedString) != null) {
          // reset to origin values
          uiSpaceInfo.getUIStringInput(SPACE_DISPLAY_NAME).setValue(oldDisplayName);
          uiSpaceInfo.getUIFormTextAreaInput(SPACE_DESCRIPTION).setValue(existingDescription);

          //
          uiApp.addMessage(
              new ApplicationMessage(
                  "UISpaceInfo.msg.current-name-exist", null, ApplicationMessage.INFO));
          return;
        }

        renamedNode = uiSpaceInfo.renamePageNode(name, space);
        if (renamedNode == null) {
          return;
        }
      }
      uiSpaceInfo.invokeSetBindingBean(space);

      String spaceDescription = space.getDescription();
      if (spaceDescription == null || spaceDescription.trim().length() == 0) {
        ResourceBundle resourceBundle = event.getRequestContext().getApplicationResourceBundle();
        space.setDescription(resourceBundle.getString(MSG_DEFAULT_SPACE_DESCRIPTION));
        uiSpaceInfo.getUIFormTextAreaInput(SPACE_DESCRIPTION).setValue(space.getDescription());
      } else {
        space.setDescription(StringEscapeUtils.escapeHtml(space.getDescription()));
        if (!existingDescription.equals(spaceDescription)) {
          space.setField(UpdatedField.DESCRIPTION);
        }
      }

      space.setEditor(Utils.getViewerRemoteId());

      if (nameChanged) {
        space.setDisplayName(oldDisplayName);
        String remoteId = Utils.getViewerRemoteId();
        spaceService.renameSpace(remoteId, space, name);

        // rename group label
        OrganizationService organizationService =
            (OrganizationService)
                ExoContainerContext.getCurrentContainer()
                    .getComponentInstanceOfType(OrganizationService.class);
        GroupHandler groupHandler = organizationService.getGroupHandler();
        Group group = groupHandler.findGroupById(space.getGroupId());
        group.setLabel(space.getDisplayName());
        groupHandler.saveGroup(group, true);
      } else {
        spaceService.updateSpace(space);
      }

      if (nameChanged) {
        if (renamedNode != null) {
          // update space navigation (change name).
          selectedNode = renamedNode;
          PortalRequestContext prContext = Util.getPortalRequestContext();
          prContext.createURL(NodeURL.TYPE).setNode(selectedNode);
          event.getRequestContext().sendRedirect(Utils.getSpaceURL(selectedNode));
          return;
        }
      } else {
        uiApp.addMessage(
            new ApplicationMessage(
                "UISpaceInfo.msg.update-success", null, ApplicationMessage.INFO));
      }
    }