Package org.jamwiki

Examples of org.jamwiki.WikiMessage


      try {
        content = ParserUtil.parse(parserInput, parserOutput, topic
            .getTopicContent());
      } catch (ParserException e) {
        throw new WikiException(
            new WikiMessage("error.unknown", e.getMessage()), e);
      }
      return content;
      // return topic.getHtmlContent();
    }
    return "";
View Full Code Here


      // older versions of JAMWiki did not have this field, so it may not always
      // be populated as expected
      return;
    }
    if (editType == TopicVersion.EDIT_MOVE) {
      this.setChangeWikiMessage(new WikiMessage("move.editcomment",
          versionParamString.split("\\|")));
    } else if (editType == TopicVersion.EDIT_PERMISSION) {
      this.setChangeWikiMessage(new WikiMessage("manage.message.permissions"));
    }
  }
View Full Code Here

  /**
   *
   */
  private String processLegacyLogin(HttpServletRequest request) throws JspException {
    WikiMessage messageObject = (WikiMessage)request.getAttribute("messageObject");
    if (messageObject == null) {
      return null;
    }
    String message = Utilities.formatMessage(messageObject.getKey(), ServletUtil.retrieveUserLocale(request), messageObject.getParams());
    return formatMessage(message);
  }
View Full Code Here

        for (int i = 0; i < candidateGroups.length; i++) {
          Long groupId = Long.parseLong(candidateGroups[i]);
          List<String> roles = buildRoleArray(0L, groupId, groupRoles);
          WikiBase.getDataHandler().writeRoleMapGroup(groupId, "", roles);
        }
        next.addObject("message", new WikiMessage("roles.message.grouproleupdate"));
      }
      // now do the same for user roles.
      String[] candidateUsers = request.getParameterValues("candidateUser");
      String[] candidateUsernames = request.getParameterValues("candidateUsername");
      String[] userRoles = request.getParameterValues("userRole");
      if (candidateUsers != null) {
        for (int i = 0; i < candidateUsers.length; i++) {
          Long userId = Long.parseLong(candidateUsers[i]);
          String username = candidateUsernames[i];
          List<String> roles = buildRoleArray(userId, 0L, userRoles);
          if (userId == ServletUtil.currentWikiUser().getUserId() && !roles.contains(RoleImpl.ROLE_SYSADMIN)) {
            errors.add(new WikiMessage("roles.message.sysadminremove"));
            roles.add(RoleImpl.ROLE_SYSADMIN.getAuthority());
          }
          WikiBase.getDataHandler().writeRoleMapUser(username, roles);
        }
        next.addObject("message", new WikiMessage("roles.message.userroleupdate"));
      }
    } catch (WikiException e) {
      errors.add(e.getWikiMessage());
    } catch (Exception e) {
      logger.severe("Failure while adding role", e);
      errors.add(new WikiMessage("roles.message.rolefail", e.getMessage()));
    }
    if (!errors.isEmpty()) {
      next.addObject("errors", errors);
    }
    this.view(request, next, pageInfo);
View Full Code Here

        role = new RoleImpl(roleName);
        role.setDescription(request.getParameter("roleDescription"));
        WikiUtil.validateRole(role);
        WikiBase.getDataHandler().writeRole(role, update);
        if (!StringUtils.isBlank(updateRole) && updateRole.equals(role.getAuthority())) {
          next.addObject("message", new WikiMessage("roles.message.roleupdated", role.getAuthority()));
        } else {
          next.addObject("message", new WikiMessage("roles.message.roleadded", role.getAuthority()));
        }
      } catch (WikiException e) {
        next.addObject("message", e.getWikiMessage());
      } catch (Exception e) {
        logger.severe("Failure while adding role", e);
        next.addObject("message", new WikiMessage("roles.message.rolefail", e.getMessage()));
      }
    } else if (!StringUtils.isBlank(updateRole)) {
      // FIXME - use a cached list of roles instead of iterating
      // load details for the selected role
      List<Role> roles = WikiBase.getDataHandler().getAllRoles();
View Full Code Here

        next.addObject("searchRole", searchRole);
      }
      next.addObject("roleMapUsers", roleMapUsers);
    } catch (Exception e) {
      logger.severe("Failure while retrieving role", e);
      next.addObject("message", new WikiMessage("roles.message.rolesearchfail", e.getMessage()));
    }
    this.view(request, next, pageInfo);
  }
View Full Code Here

    next.addObject("roleCount", roles.size());
    List<RoleMap> roleMapGroups = WikiBase.getDataHandler().getRoleMapGroups();
    next.addObject("roleMapGroups", roleMapGroups);
    pageInfo.setAdmin(true);
    pageInfo.setContentJsp(JSP_ADMIN_ROLES);
    pageInfo.setPageTitle(new WikiMessage("roles.title"));
  }
View Full Code Here

   *
   */
  protected ModelAndView handleJAMWikiRequest(HttpServletRequest request, HttpServletResponse response, ModelAndView next, WikiPageInfo pageInfo) throws Exception {
    WikiUserDetails userDetails = ServletUtil.currentUserDetails();
    if (!userDetails.hasRole(RoleImpl.ROLE_MOVE)) {
      WikiMessage messageObject = new WikiMessage("login.message.move");
      return ServletUtil.viewLogin(request, pageInfo, WikiUtil.getTopicFromURI(request), messageObject);
    }
    if (request.getParameter("move") == null) {
      view(request, next, pageInfo);
    } else {
View Full Code Here

   *
   */
  private void move(HttpServletRequest request, ModelAndView next, WikiPageInfo pageInfo) throws Exception {
    String topicName = WikiUtil.getTopicFromRequest(request);
    if (StringUtils.isBlank(topicName)) {
      throw new WikiException(new WikiMessage("common.exception.notopic"));
    }
    WikiMessage pageTitle = new WikiMessage("move.title", topicName);
    pageInfo.setPageTitle(pageTitle);
    pageInfo.setTopicName(topicName);
    String moveDestination = request.getParameter("moveDestination");
    if (!movePage(request, next, pageInfo, topicName, moveDestination)) {
      return;
View Full Code Here

   */
  private boolean movePage(HttpServletRequest request, ModelAndView next, WikiPageInfo pageInfo, String moveFrom, String moveDestination) throws Exception {
    String virtualWiki = pageInfo.getVirtualWikiName();
    Topic fromTopic = WikiBase.getDataHandler().lookupTopic(virtualWiki, moveFrom, false, null);
    if (fromTopic == null) {
      throw new WikiException(new WikiMessage("common.exception.notopic"));
    }
    if (StringUtils.isBlank(moveDestination)) {
      next.addObject("messageObject", new WikiMessage("move.exception.nodestination"));
      this.view(request, next, pageInfo);
      return false;
    }
    WikiLink fromWikiLink = LinkUtil.parseWikiLink(moveFrom);
    WikiLink destinationWikiLink = LinkUtil.parseWikiLink(moveDestination);
    if (!StringUtils.equals(fromWikiLink.getNamespace(), destinationWikiLink.getNamespace())) {
      // do not allow moving into or out of image & category namespace
      if (StringUtils.equals(fromWikiLink.getNamespace(), NamespaceHandler.NAMESPACE_CATEGORY)
          || StringUtils.equals(fromWikiLink.getNamespace(), NamespaceHandler.NAMESPACE_CATEGORY_COMMENTS)
          || StringUtils.equals(destinationWikiLink.getNamespace(), NamespaceHandler.NAMESPACE_CATEGORY)
          || StringUtils.equals(destinationWikiLink.getNamespace(), NamespaceHandler.NAMESPACE_CATEGORY_COMMENTS)
        ) {
        next.addObject("messageObject", new WikiMessage("move.exception.namespacecategory"));
        this.view(request, next, pageInfo);
        return false;
      } else if (StringUtils.equals(fromWikiLink.getNamespace(), NamespaceHandler.NAMESPACE_IMAGE)
          || StringUtils.equals(fromWikiLink.getNamespace(), NamespaceHandler.NAMESPACE_IMAGE_COMMENTS)
          || StringUtils.equals(destinationWikiLink.getNamespace(), NamespaceHandler.NAMESPACE_IMAGE)
          || StringUtils.equals(destinationWikiLink.getNamespace(), NamespaceHandler.NAMESPACE_IMAGE_COMMENTS)
        ) {
        next.addObject("messageObject", new WikiMessage("move.exception.namespaceimage"));
        this.view(request, next, pageInfo);
        return false;
      }
    }
    WikiUserDetails userDetails = ServletUtil.currentUserDetails();
    if (!ServletUtil.isMoveable(virtualWiki, moveFrom, userDetails)) {
      this.view(request, next, pageInfo);
      next.addObject("messageObject", new WikiMessage("move.exception.permission", moveFrom));
      return false;
    }
    if (!WikiBase.getDataHandler().canMoveTopic(fromTopic, moveDestination)) {
      this.view(request, next, pageInfo);
      next.addObject("messageObject", new WikiMessage("move.exception.destinationexists", moveDestination));
      return false;
    }
    String moveComment = request.getParameter("moveComment");
    WikiUser user = ServletUtil.currentWikiUser();
    TopicVersion topicVersion = new TopicVersion(user, ServletUtil.getIpAddress(request), moveComment, fromTopic.getTopicContent(), 0);
View Full Code Here

TOP

Related Classes of org.jamwiki.WikiMessage

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.