Package com.dotmarketing.portlets.containers.struts

Examples of com.dotmarketing.portlets.containers.struts.ContainerForm


      PortletConfig config, ActionRequest req, ActionResponse res)
      throws Exception {

    String cmd = req.getParameter(Constants.CMD);
    String referer = req.getParameter("referer");
    ContainerForm fm = (ContainerForm) form;

    // wraps request to get session object
    ActionRequestImpl reqImpl = (ActionRequestImpl) req;
    HttpServletRequest httpReq = reqImpl.getHttpServletRequest();

    if ((referer != null) && (referer.length() != 0)) {
      referer = URLDecoder.decode(referer, "UTF-8");
    }

    Logger.debug(this, "EditContainerAction cmd=" + cmd);

    // if we are poping up the "add variables" page
    if (com.dotmarketing.util.Constants.CONTAINER_ADD_VARIABLE.equals(cmd)) {
      setForward(req, "portlet.ext.containers.add_variables");
      return;
    }

    HibernateUtil.startTransaction();

    User user = _getUser(req);

    try {
      Logger.debug(this, "Calling Retrieve method");
      _retrieveWebAsset(req, res, config, form, user, Container.class,
          WebKeys.CONTAINER_EDIT);

    } catch (Exception ae) {
      _handleException(ae, req);
      return;
    }

    /*
     * We are editing the container or reloading a current one
     */
    if ((cmd != null) && (cmd.equals(Constants.EDIT) || cmd.equals(Constants.UPDATE)) ) {
      try {
        Logger.debug(this, "Calling Edit Method");
        _editWebAsset(req, res, config, form, user);

      } catch (Exception ae) {
        if ((referer != null) && (referer.length() != 0)) {
          if (ae.getMessage().equals(WebKeys.EDIT_ASSET_EXCEPTION)) {
            // The web asset edit threw an exception because it's
            // locked so it should redirect back with message
            java.util.Map<String, String[]> params = new java.util.HashMap<String, String[]>();
            params.put("struts_action",
                new String[] { "/ext/director/direct" });
            params.put("cmd", new String[] { "editContainer" });
            params.put("container", new String[] { req
                .getParameter("inode") });
            params.put("referer", new String[] { URLEncoder.encode(
                referer, "UTF-8") });

            String directorURL = com.dotmarketing.util.PortletURLUtil
                .getActionURL(httpReq, WindowState.MAXIMIZED
                    .toString(), params);

            _sendToReferral(req, res, directorURL);
            return;
          }
        }
        _handleException(ae, req);
        return;
      }
    }

    /*
     * If we are updating the container, copy the information from the
     * struts bean to the hbm inode and run the update action and return to
     * the list
     */
    if ((cmd != null) && cmd.equals(Constants.ADD)) {
      try {
        String note = fm.getNotes();
        if (Validator.validate(req, form, mapping) && note.length()<=255) {

          Logger.debug(this, "Calling Save Method");
          _saveWebAsset(req, res, config, form, user);

View Full Code Here


    // calls edit method from super class that returns parent folder
    super._editWebAsset(req, res, config, form, user, WebKeys.CONTAINER_EDIT);

    // setting parent folder path and inode on the form bean
    ContainerForm cf = (ContainerForm) form;
    ActionRequestImpl reqImpl = (ActionRequestImpl) req;
    HttpServletRequest httpReq = reqImpl.getHttpServletRequest();
    HttpSession session = httpReq.getSession();

    //Setting the default host = the selected crumbtrail host if it is a new container
        String hostId= (String)session.getAttribute(com.dotmarketing.util.WebKeys.CMS_SELECTED_HOST_ID);
        if(!hostId.equals("allHosts") && cf.getHostId() == null) {
          Host crumbHost = hostAPI.find(hostId, user, false);
          if(crumbHost != null && permissionAPI.doesUserHavePermission(crumbHost, PermissionAPI.PERMISSION_CAN_ADD_CHILDREN, user, false))
            cf.setHostId(hostId);
        }

    // This can't be done on the WebAsset so it needs to be done here.
    Container container = (Container) req
        .getAttribute(WebKeys.CONTAINER_EDIT);

        if (UtilMethods.isSet(container.getLuceneQuery())) {
            cf.setDynamic(true);
        }

        //gets the container host
        Host host = hostAPI.findParentHost(container, user, false);
        if(host!= null)
          cf.setHostId(host.getIdentifier());


        // Getting container structures
        cf.setContainerStructures(APILocator.getContainerAPI().getContainerStructures(container));


    //Asset Versions to list in the versions tab
    req.setAttribute(WebKeys.VERSIONS_INODE_EDIT, container);
View Full Code Here

    // wraps request to get session object
    ActionRequestImpl reqImpl = (ActionRequestImpl) req;
    HttpServletRequest httpReq = reqImpl.getHttpServletRequest();

    ContainerForm fm = (ContainerForm) form;

    // gets the new information for the container from the request object
    req.setAttribute(WebKeys.CONTAINER_FORM_EDIT,
        new com.dotmarketing.portlets.containers.model.Container());
    BeanUtils.copyProperties(req.getAttribute(WebKeys.CONTAINER_FORM_EDIT),  form);

    // gets the new information for the container from the request object
    Container container = (Container) req.getAttribute(WebKeys.CONTAINER_FORM_EDIT);

    // gets the current container being edited from the request object
    Container currentContainer = (Container) req.getAttribute(WebKeys.CONTAINER_EDIT);

    //Is a new container?
    boolean isNew = !InodeUtils.isSet(currentContainer.getInode());

    //Getting the container host
        Host host = hostAPI.find(fm.getHostId(), user, false);

    //Checking permissions
    if (!isNew) {
      _checkWritePermissions(currentContainer, user, httpReq);
    } else {
      //If the asset is new checking that the user has permission to add children to the parent host
      if(!permissionAPI.doesUserHavePermission(host, PermissionAPI.PERMISSION_CAN_ADD_CHILDREN, user, false)
          || !permissionAPI.doesUserHavePermissions(PermissionableType.CONTAINERS, PermissionAPI.PERMISSION_EDIT, user)) {
        SessionMessages.add(httpReq, "message", "message.insufficient.permissions.to.save");
        throw new ActionException(WebKeys.USER_PERMISSIONS_EXCEPTION);
      }
    }

    // Current associated templates
    List<Template> currentTemplates = InodeFactory.getChildrenClass(currentContainer, Template.class);

    // gets user id from request for mod user
    String userId = user.getUserId();

    // Associating the current structure
    Structure currentStructure = null;
    if (!InodeUtils.isSet(fm.getStructureInode())) {
      currentStructure = StructureFactory.getDefaultStructure();
    } else {
      currentStructure = StructureCache.getStructureByInode(fm.getStructureInode());
    }

    // it saves or updates the asset
    if (InodeUtils.isSet(currentContainer.getInode())) {
      Identifier identifier = APILocator.getIdentifierAPI().find(currentContainer);
View Full Code Here

TOP

Related Classes of com.dotmarketing.portlets.containers.struts.ContainerForm

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.