コード例 #1
0
  @Override
  protected Widget createContentWidget(
      final HttpServletRequest request,
      final HttpServletResponse response,
      final HttpContext context)
      throws IOException, PermissionDeniedException, RedirectException, LoginRequiredException {
    logger.trace("printContent");
    final ListWidget widgets = new ListWidget();
    widgets.add(new H1Widget(getTitle()));

    final String content = request.getParameter(PARAMETER_CONTENT);
    final String tag = request.getParameter(PARAMETER_TAG);
    if (content != null && !content.isEmpty() && tag != null && !tag.isEmpty()) {
      widgets.add(new PreWidget(removeTag(content, tag)));
    }

    final FormWidget form = new FormWidget().addMethod(FormMethod.POST);
    form.addFormInputWidget(
        new FormInputTextWidget(PARAMETER_TAG).addLabel("Tag:").addDefaultValue("span"));
    form.addFormInputWidget(new FormInputTextareaWidget(PARAMETER_CONTENT).addLabel("HTML:"));
    form.addFormInputWidget(new FormInputSubmitWidget("remove"));
    widgets.add(form);

    return widgets;
  }
コード例 #2
0
  @Override
  protected Widget createContentWidget(
      final HttpServletRequest request,
      final HttpServletResponse response,
      final HttpContext context)
      throws IOException, PermissionDeniedException, RedirectException, LoginRequiredException {
    try {
      logger.trace("printContent");
      final ListWidget widgets = new ListWidget();
      widgets.add(new H1Widget(getTitle()));

      final String id = request.getParameter(BlogGuiConstants.PARAMETER_BLOG_POST_ID);
      final String title = request.getParameter(BlogGuiConstants.PARAMETER_BLOG_POST_TITLE);
      final String content = request.getParameter(BlogGuiConstants.PARAMETER_BLOG_POST_CONTENT);
      final SessionIdentifier sessionIdentifier =
          authenticationService.createSessionIdentifier(request);
      final BlogPostIdentifier blogPostIdentifier = blogService.createBlogPostIdentifier(id);
      final BlogPost blogPost = blogService.getBlogPost(sessionIdentifier, blogPostIdentifier);
      if (title != null && content != null) {
        try {
          blogService.updateBlogPost(sessionIdentifier, blogPostIdentifier, title, content);
          logger.debug("new BlogPost updated");
          throw new RedirectException(request.getContextPath() + "/" + BlogGuiConstants.NAME);
        } catch (final ValidationException e) {
          widgets.add("update blogPost failed!");
          widgets.add(new ValidationExceptionWidget(e));
        }
      }
      final FormWidget formWidget = new FormWidget().addMethod(FormMethod.POST);
      formWidget.addFormInputWidget(
          new FormInputHiddenWidget(BlogGuiConstants.PARAMETER_BLOG_POST_ID));
      formWidget.addFormInputWidget(
          new FormInputTextWidget(BlogGuiConstants.PARAMETER_BLOG_POST_TITLE)
              .addDefaultValue(blogPost.getTitle())
              .addLabel("Title")
              .addPlaceholder("title..."));
      formWidget.addFormInputWidget(
          new FormInputTextareaWidget(BlogGuiConstants.PARAMETER_BLOG_POST_CONTENT)
              .addDefaultValue(blogPost.getContent())
              .addLabel("Content")
              .addPlaceholder("content..."));
      formWidget.addFormInputWidget(new FormInputSubmitWidget("update"));
      widgets.add(formWidget);
      return widgets;
    } catch (final AuthenticationServiceException e) {
      logger.debug(e.getClass().getName(), e);
      final ExceptionWidget widget = new ExceptionWidget(e);
      return widget;
    } catch (final BlogServiceException e) {
      logger.debug(e.getClass().getName(), e);
      final ExceptionWidget widget = new ExceptionWidget(e);
      return widget;
    } catch (final BlogPostNotFoundException e) {
      logger.debug(e.getClass().getName(), e);
      final ExceptionWidget widget = new ExceptionWidget(e);
      return widget;
    }
  }
コード例 #3
0
  @Override
  protected Widget createContentWidget(
      final HttpServletRequest request,
      final HttpServletResponse response,
      final HttpContext context)
      throws IOException, LoginRequiredException {
    try {
      logger.trace("printContent");
      final ListWidget widgets = new ListWidget();
      widgets.add(new H1Widget(getTitle()));

      final String password_old =
          request.getParameter(AuthenticationGuiConstants.PARAMETER_PASSWORD_OLD);
      final String password_new =
          request.getParameter(AuthenticationGuiConstants.PARAMETER_PASSWORD_NEW);
      final String password_repeat =
          request.getParameter(AuthenticationGuiConstants.PARAMETER_PASSWORD_NEW_REPEAT);

      if (password_old != null && password_new != null && password_repeat != null) {
        final SessionIdentifier sessionIdentifier =
            authenticationService.createSessionIdentifier(request);
        try {
          authenticationService.changePassword(
              sessionIdentifier, password_old, password_new, password_repeat);
          widgets.add("change password successful");
        } catch (final ValidationException e) {
          widgets.add("change password failed!");
          widgets.add(new ValidationExceptionWidget(e));
        }
      }
      final FormWidget form = new FormWidget().addMethod(FormMethod.POST);
      form.addFormInputWidget(
          new FormInputPasswordWidget(AuthenticationGuiConstants.PARAMETER_PASSWORD_OLD)
              .addLabel("Old password")
              .addPlaceholder("Old password..."));
      form.addFormInputWidget(
          new FormInputPasswordWidget(AuthenticationGuiConstants.PARAMETER_PASSWORD_NEW)
              .addLabel("New password")
              .addPlaceholder("New password..."));
      form.addFormInputWidget(
          new FormInputPasswordWidget(AuthenticationGuiConstants.PARAMETER_PASSWORD_NEW_REPEAT)
              .addLabel("New password repeat")
              .addPlaceholder("New password repeat..."));
      form.addFormInputWidget(new FormInputSubmitWidget("change password"));
      widgets.add(form);

      final ListWidget links = new ListWidget();
      links.add(authenticationGuiLinkFactory.userProfile(request));
      widgets.add(links);

      return widgets;
    } catch (final AuthenticationServiceException e) {
      logger.debug(e.getClass().getName(), e);
      final ExceptionWidget widget = new ExceptionWidget(e);
      return widget;
    }
  }
コード例 #4
0
  @Override
  protected Widget createGalleryContentWidget(final HttpServletRequest request)
      throws IOException, PermissionDeniedException, RedirectException, LoginRequiredException {
    try {
      final ListWidget widgets = new ListWidget();
      widgets.add(new H1Widget(getTitle()));
      final String id = request.getParameter(GalleryGuiConstants.PARAMETER_COLLECTION_ID);
      final String name = request.getParameter(GalleryGuiConstants.PARAMETER_COLLECTION_NAME);
      final String referer = request.getParameter(GalleryGuiConstants.PARAMETER_REFERER);
      final String prio = request.getParameter(GalleryGuiConstants.PARAMETER_COLLECTION_PRIO);
      final String shared = request.getParameter(GalleryGuiConstants.PARAMETER_COLLECTION_SHARED);
      final String groupId = request.getParameter(GalleryGuiConstants.PARAMETER_GROUP_ID);

      final SessionIdentifier sessionIdentifier =
          authenticationService.createSessionIdentifier(request);
      final GalleryCollectionIdentifier galleryCollectionIdentifier =
          galleryService.createCollectionIdentifier(id);
      final GalleryCollection galleryCollection =
          galleryService.getCollection(sessionIdentifier, galleryCollectionIdentifier);

      if (name != null && prio != null && groupId != null && shared != null) {
        try {

          final GalleryGroupIdentifier galleryGroupIdentifier =
              galleryService.createGroupIdentifier(groupId);
          updateCollection(
              sessionIdentifier,
              galleryCollectionIdentifier,
              galleryGroupIdentifier,
              name,
              prio,
              shared);

          if (referer != null && referer.length() > 0) {
            throw new RedirectException(referer);
          } else {
            throw new RedirectException(
                galleryGuiLinkFactory.entryListUrl(request, galleryCollectionIdentifier));
          }
        } catch (final ValidationException e) {
          widgets.add("create collection => failed");
          widgets.add(new ValidationExceptionWidget(e));
        }
      }
      final FormWidget formWidget = new FormWidget();
      formWidget.addFormInputWidget(
          new FormInputHiddenWidget(GalleryGuiConstants.PARAMETER_REFERER)
              .addDefaultValue(buildRefererUrl(request)));
      formWidget.addFormInputWidget(
          new FormInputHiddenWidget(GalleryGuiConstants.PARAMETER_COLLECTION_ID)
              .addValue(galleryCollection.getId()));
      formWidget.addFormInputWidget(
          new FormInputHiddenWidget(GalleryGuiConstants.PARAMETER_GROUP_ID)
              .addValue(galleryCollection.getGroupId()));
      formWidget.addFormInputWidget(
          new FormInputTextWidget(GalleryGuiConstants.PARAMETER_COLLECTION_NAME)
              .addLabel("Name...")
              .addDefaultValue(galleryCollection.getName()));
      formWidget.addFormInputWidget(
          new FormInputTextWidget(GalleryGuiConstants.PARAMETER_COLLECTION_PRIO)
              .addLabel("Prio...")
              .addDefaultValue(galleryCollection.getPriority()));
      formWidget.addFormInputWidget(
          new FormInputTextWidget(GalleryGuiConstants.PARAMETER_COLLECTION_SHARED)
              .addLabel("Shared")
              .addPlaceholder("shared...")
              .addDefaultValue(galleryCollection.getShared()));
      formWidget.addFormInputWidget(new FormInputSubmitWidget("update"));
      widgets.add(formWidget);
      return widgets;
    } catch (final GalleryServiceException e) {
      logger.debug(e.getClass().getName(), e);
      return new ExceptionWidget(e);
    } catch (final AuthenticationServiceException e) {
      logger.debug(e.getClass().getName(), e);
      return new ExceptionWidget(e);
    }
  }