Package fr.openwide.maven.artifact.notifier.core.business.user.model

Examples of fr.openwide.maven.artifact.notifier.core.business.user.model.User


      private static final long serialVersionUID = 1L;

      @Override
      protected void onSubmit() {
        try {
          User user = userService.getByUserName(userNameModel.getObject());
          if (user != null) {
            if (user.getRemoteIdentifier() == null) {
              userService.passwordResetRequest(user);
              getSession().success(getString("forgottenPassword.success"));
             
              redirect(getApplication().getHomePage());
            } else {
              LOGGER.warn("The account '" + user.getUserName() + "' is not a classic account: its password can't be reset");
              getSession().warn(getString("forgottenPassword.account.remote"));
            }
          } else {
            LOGGER.error("The username '" + userNameModel.getObject() + "' does not match any existing account");
            getSession().error(getString("forgottenPassword.account.notFound"));
View Full Code Here


  }

  @Override
  public void refreshAuditSummaryForCreate(AuditSummary auditSummary) {
    Date now = getNow();
    User author = getAuthor();
   
    // Si un créateur a déjà été spécifié, on ne l'écrase pas
    if (auditSummary.getCreationAuthor() == null) {
      auditSummary.setCreationAuthor(author);
    }
View Full Code Here

  }

  @Override
  public void refreshAuditSummaryForUpdate(AuditSummary auditSummary) {
    Date now = getNow();
    User author = getAuthor();
   
    auditSummary.setLastEditAuthor(author);
    auditSummary.setLastEditDate(now);
  }
View Full Code Here

     
      @Override
      protected void onConfigure() {
        super.onConfigure();
        Artifact artifact = getModelObject();
        User user = MavenArtifactNotifierSession.get().getUser();
        boolean isDeprecated = artifact == null || ArtifactDeprecationStatus.DEPRECATED.equals(artifact.getDeprecationStatus());
       
        setVisible(!isDeprecated && user != null && !userService.isFollowedArtifact(user, artifact));
      }
    };
    follow.add(new AuthenticatedOnlyBehavior());
    add(follow);
   
    // Deprecated
    final IModel<Artifact> relatedArtifactModel = BindingModel.of(getModel(), Binding.artifact().relatedArtifact());
    Link<Void> relatedArtifactLink = ArtifactDescriptionPage.linkDescriptor(relatedArtifactModel).link("deprecated");
    relatedArtifactLink.add(new Behavior() {
      private static final long serialVersionUID = 1L;

      @Override
      public void onConfigure(Component component) {
        super.onConfigure(component);
        Artifact artifact = ArtifactFollowActionsPanel.this.getModelObject();
        User user = MavenArtifactNotifierSession.get().getUser();
        boolean isDeprecated = artifact != null && ArtifactDeprecationStatus.DEPRECATED.equals(artifact.getDeprecationStatus());
       
        component.setVisibilityAllowed(isDeprecated && user != null && !userService.isFollowedArtifact(user, artifact));
        component.setEnabled(relatedArtifactModel.getObject() != null);
      }
    });
    relatedArtifactLink.add(new AuthenticatedOnlyBehavior());
    relatedArtifactLink.add(new AttributeModifier("title", new LoadableDetachableModel<String>() {
      private static final long serialVersionUID = 1L;

      @Override
      protected String load() {
        Artifact relatedArtifact = relatedArtifactModel.getObject();
        StringBuilder sb = new StringBuilder(getString("artifact.description.deprecated"));
        if (relatedArtifact != null) {
          sb.append(" ").append(getString("artifact.deprecation.link.title", relatedArtifactModel));
        }
        return sb.toString();
      }
    }));
    add(relatedArtifactLink);
   
    // Unfollow
    AjaxLink<Artifact> unfollow = new AjaxLink<Artifact>("unfollow", getModel()) {
      private static final long serialVersionUID = 1L;
     
      @Override
      public void onClick(AjaxRequestTarget target) {
        try {
          if (!userService.unfollowArtifact(MavenArtifactNotifierSession.get().getUser(), getModelObject())) {
            getSession().warn(getString("artifact.delete.notFollowed"));
          }
          refresh(target);
        } catch (Exception e) {
          LOGGER.error("Error occured while unfollowing artifact", e);
          getSession().error(getString("common.error.unexpected"));
        }
        FeedbackUtils.refreshFeedback(target, getPage());
      }
     
      @Override
      protected void onConfigure() {
        super.onConfigure();
        Artifact artifact = getModelObject();
        User user = MavenArtifactNotifierSession.get().getUser();
       
        setVisible(user != null && artifact != null && userService.isFollowedArtifact(user, artifact));
      }
    };
    unfollow.add(new AuthenticatedOnlyBehavior());
View Full Code Here

      private static final long serialVersionUID = 1L;
     
      @Override
      protected String load() {
        String userDisplayName = null;
        User user = MavenArtifactNotifierSession.get().getUser();
        if (user != null) {
          userDisplayName = user.getDisplayName();
        }
        return userDisplayName;
      }
    };
    WebMarkupContainer userMenuContainer = new WebMarkupContainer("userMenuContainer", userDisplayNameModel) {
View Full Code Here

    followedArtifactModel = new LoadableDetachableModel<FollowedArtifact>() {
      private static final long serialVersionUID = 1L;

      @Override
      protected FollowedArtifact load() {
        User user = MavenArtifactNotifierSession.get().getUser();
        if (user != null) {
          return userService.getFollowedArtifact(user, getArtifactModel().getObject());
        }
        return null;
      }
    };
   
    addBreadCrumbElement(new BreadCrumbElement(new ResourceModel("dashboard.pageTitle"), DashboardPage.linkDescriptor()));
    addBreadCrumbElement(new BreadCrumbElement(new StringResourceModel("artifact.description.pageTitle", artifactModel),
        ArtifactDescriptionPage.linkDescriptor(artifactModel)));
   
    add(new Label("pageTitle", new StringResourceModel("artifact.description.pageTitle", artifactModel)));
   
    // Follow
    AjaxLink<Artifact> follow = new AjaxLink<Artifact>("follow", artifactModel) {
      private static final long serialVersionUID = 1L;
     
      @Override
      public void onClick(AjaxRequestTarget target) {
        try {
          userService.followArtifact(MavenArtifactNotifierSession.get().getUser(), getModelObject());
          target.add(getPage());
        } catch (AlreadyFollowedArtifactException e) {
          getSession().warn(getString("artifact.follow.alreadyFollower"));
          target.add(getPage());
        } catch (Exception e) {
          LOGGER.error("Error occured while following artifact", e);
          getSession().error(getString("common.error.unexpected"));
        }
        FeedbackUtils.refreshFeedback(target, getPage());
      }
     
      @Override
      protected void onConfigure() {
        super.onConfigure();
        Artifact artifact = getModelObject();
        User user = MavenArtifactNotifierSession.get().getUser();
        boolean isDeprecated = artifact == null || ArtifactDeprecationStatus.DEPRECATED.equals(artifact.getDeprecationStatus());
       
        setVisible(!isDeprecated && user != null && !userService.isFollowedArtifact(user, artifact));
      }
    };
    follow.add(new AuthenticatedOnlyBehavior());
    add(follow);
   
    // Unfollow
    AjaxLink<Artifact> unfollow = new AjaxLink<Artifact>("unfollow", artifactModel) {
      private static final long serialVersionUID = 1L;
     
      @Override
      public void onClick(AjaxRequestTarget target) {
        try {
          if (!userService.unfollowArtifact(MavenArtifactNotifierSession.get().getUser(), getModelObject())) {
            getSession().warn(getString("artifact.delete.notFollowed"));
          }
          target.add(getPage());
        } catch (Exception e) {
          LOGGER.error("Error occured while unfollowing artifact", e);
          getSession().error(getString("common.error.unexpected"));
        }
        FeedbackUtils.refreshFeedback(target, getPage());
      }
     
      @Override
      protected void onConfigure() {
        super.onConfigure();
        Artifact artifact = getModelObject();
        User user = MavenArtifactNotifierSession.get().getUser();
       
        setVisible(user != null && artifact != null && userService.isFollowedArtifact(user, artifact));
      }
    };
    unfollow.add(new AuthenticatedOnlyBehavior());
View Full Code Here

          private static final long serialVersionUID = -5179621361619239269L;
         
          @Override
          public void onClick(AjaxRequestTarget target) {
            try {
              User user = UserArtifactsPanel.this.getModelObject();
              FollowedArtifact followedArtifact = getModelObject();
             
              userService.unfollowArtifact(user, followedArtifact);
              Session.get().success(getString("artifact.delete.success"));
            } catch (Exception e) {
View Full Code Here

         
          @Override
          public void onClick(AjaxRequestTarget target) {
            try {
              UserGroup userGroup = getModelObject();
              User user = UserMembershipsPanel.this.getModelObject();
             
              userGroupService.removeUser(userGroup, user);
              Session.get().success(getString("administration.usergroup.members.delete.success"));
            } catch (Exception e) {
              LOGGER.error("Error occured while removing user from user group", e);
              Session.get().error(getString("administration.usergroup.members.delete.error"));
            }
            target.add(getPage());
            FeedbackUtils.refreshFeedback(target, getPage());
          }
        });
      }
    };
    add(userGroupListView);
   
    add(new WebMarkupContainer("emptyList") {
      private static final long serialVersionUID = -784607577583169098L;
     
      @Override
      public void onConfigure() {
        super.onConfigure();
        setVisible(userGroupListView.size() <= 0);
      }
    });
   
    // Add group form
    IModel<UserGroup> emptyUserGroupModel = new GenericEntityModel<Long, UserGroup>(null);
   
    final UserGroupAutocompleteAjaxComponent userGroupAutocomplete = new UserGroupAutocompleteAjaxComponent(
        "userGroupAutocomplete", emptyUserGroupModel);
    userGroupAutocomplete.setAutoUpdate(true);
   
    final Form<UserGroup> addGroupForm = new Form<UserGroup>("addGroupForm", emptyUserGroupModel);
    addGroupForm.add(userGroupAutocomplete);
    addGroupForm.add(new AjaxSubmitLink("addGroupLink", addGroupForm) {
      private static final long serialVersionUID = 6935376642872117563L;
     
      @Override
      protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
        User user = UserMembershipsPanel.this.getModelObject();
        UserGroup selectedUserGroup = userGroupAutocomplete.getModelObject();
       
        if (selectedUserGroup != null) {
          try {
            userGroupService.addUser(selectedUserGroup, user);
View Full Code Here

    item.add(new ClassAttributeAppender(new LoadableDetachableModel<String>() {
      private static final long serialVersionUID = 1L;
     
      @Override
      protected String load() {
        User user = MavenArtifactNotifierSession.get().getUser();
        boolean isFollowed = user != null && userService.isFollowedArtifactBean(user, item.getModelObject());
        boolean isDeprecated = artifactModel.getObject() != null &&
            ArtifactDeprecationStatus.DEPRECATED.equals(artifactModel.getObject().getDeprecationStatus());
        return isFollowed ? "success" : (isDeprecated ? "warning" : null);
      }
    }));
   
    // GroupId column
    item.add(new Label("groupId", new PropertyModel<ArtifactBean>(item.getModel(), "groupId")));
    item.add(new ExternalLink("groupLink", mavenCentralSearchUrlService.getGroupUrl(artifactBean.getGroupId())));

    // ArtifactId column
    Link<Void> localArtifactLink = ArtifactDescriptionPage.linkDescriptor(artifactModel).link("localArtifactLink");
    // Not done in the onConfigure method because if the model changes the link's PageParameters need to be reconstructed and so does the page.
    localArtifactLink.setEnabled(artifactModel.getObject() != null);
    localArtifactLink.add(new Label("artifactId", new PropertyModel<ArtifactBean>(item.getModel(), "artifactId")));
    item.add(localArtifactLink);
   
    item.add(new ExternalLink("artifactLink", mavenCentralSearchUrlService.getArtifactUrl(artifactBean.getGroupId(), artifactBean.getArtifactId())));
   
    // LastVersion and lastUpdateDate columns
    item.add(new Label("unfollowedArtifactPlaceholder", new ResourceModel("artifact.follow.unfollowedArtifact")) {
      private static final long serialVersionUID = 1L;

      @Override
      protected void onConfigure() {
        super.onConfigure();
        setVisible(artifactModel.getObject() == null);
      }
    });
    item.add(new Label("synchronizationPlannedPlaceholder", new ResourceModel("artifact.follow.synchronizationPlanned")) {
      private static final long serialVersionUID = 1L;

      @Override
      protected void onConfigure() {
        super.onConfigure();
        setVisible(artifactModel.getObject() != null && !artifactLastVersionModel.isLastVersionAvailable());
      }
    });
   
    WebMarkupContainer localContainer = new WebMarkupContainer("followedArtifact") {
      private static final long serialVersionUID = 1L;

      @Override
      protected void onConfigure() {
        super.onConfigure();
        setVisible(artifactLastVersionModel.isLastVersionAvailable());
      }
    };
    localContainer.add(new ArtifactVersionTagPanel("latestVersion", Model.of(artifactLastVersionModel.getLastVersion())));
    localContainer.add(new ExternalLink("versionLink", mavenCentralSearchUrlService.getVersionUrl(artifactBean.getGroupId(),
        artifactBean.getArtifactId(), artifactBean.getLatestVersion())));
    localContainer.add(new DateLabelWithPlaceholder("lastUpdateDate", Model.of(artifactLastVersionModel.getLastVersionUpdateDate()), DatePattern.SHORT_DATE));
    item.add(localContainer);

    // Followers count column
    Label followersCount = new CountLabel("followersCount", "artifact.follow.dataView.followers",
        BindingModel.of(artifactModel, Binding.artifact().followersCount()));
    followersCount.add(new AttributeModifier("class", new LoadableDetachableModel<String>() {
      private static final long serialVersionUID = 1L;

      @Override
      protected String load() {
        if (artifactModel.getObject() != null && artifactModel.getObject().getFollowersCount() > 0) {
          return "badge";
        }
        return null;
      }
    }));
    item.add(followersCount);
   
    // Follow column
    AjaxLink<ArtifactBean> follow = new AjaxLink<ArtifactBean>("follow", item.getModel()) {
      private static final long serialVersionUID = 1L;
     
      @Override
      public void onClick(AjaxRequestTarget target) {
        try {
          userService.followArtifactBean(MavenArtifactNotifierSession.get().getUser(), getModelObject());
          refresh(target, item);
        } catch (AlreadyFollowedArtifactException e) {
          getSession().warn(getString("artifact.follow.alreadyFollower"));
          refresh(target, item);
        } catch (Exception e) {
          LOGGER.error("Error occured while following artifact", e);
          getSession().error(getString("common.error.unexpected"));
        }
        FeedbackUtils.refreshFeedback(target, getPage());
      }
     
      @Override
      protected void onConfigure() {
        super.onConfigure();
        ArtifactBean artifactBean = getModelObject();
        Artifact artifact = artifactModel.getObject();
        User user = MavenArtifactNotifierSession.get().getUser();
        boolean isDeprecated = artifact != null && ArtifactDeprecationStatus.DEPRECATED.equals(artifact.getDeprecationStatus());

        setVisible(!isDeprecated && user != null && artifactBean != null && !userService.isFollowedArtifactBean(user, artifactBean));
      }
    };
    follow.add(new AuthenticatedOnlyBehavior());
    item.add(follow);
   
    final IModel<Artifact> relatedArtifactModel = BindingModel.of(artifactModel, Binding.artifact().relatedArtifact());
    Link<Void> relatedArtifactLink = ArtifactDescriptionPage.linkDescriptor(relatedArtifactModel).link("relatedArtifactLink");
    relatedArtifactLink.add(new Behavior() {
      private static final long serialVersionUID = 1L;

      @Override
      public void onConfigure(Component component) {
        super.onConfigure(component);
        ArtifactBean artifactBean = item.getModelObject();
        Artifact artifact = artifactModel.getObject();
        User user = MavenArtifactNotifierSession.get().getUser();
        boolean isDeprecated = (artifact != null) && ArtifactDeprecationStatus.DEPRECATED.equals(artifact.getDeprecationStatus());
       
        component.setVisibilityAllowed(isDeprecated && user != null && artifactBean != null && !userService.isFollowedArtifactBean(user, artifactBean));
        component.setEnabled(relatedArtifactModel.getObject() != null);
      }
    });
    relatedArtifactLink.add(new AuthenticatedOnlyBehavior());
    relatedArtifactLink.add(new AttributeModifier("title", new LoadableDetachableModel<String>() {
      private static final long serialVersionUID = 1L;

      @Override
      protected String load() {
        Artifact relatedArtifact = relatedArtifactModel.getObject();
        StringBuilder sb = new StringBuilder(getString("artifact.description.deprecated"));
        if (relatedArtifact != null) {
          sb.append(" ").append(getString("artifact.deprecation.link.title", relatedArtifactModel));
        }
        return sb.toString();
      }
    }));
    item.add(relatedArtifactLink);
   
    AjaxLink<Artifact> unfollow = new AjaxLink<Artifact>("unfollow", artifactModel) {
      private static final long serialVersionUID = 1L;
     
      @Override
      public void onClick(AjaxRequestTarget target) {
        try {
          if (!userService.unfollowArtifact(MavenArtifactNotifierSession.get().getUser(), getModelObject())) {
            getSession().warn(getString("artifact.delete.notFollowed"));
          }
          refresh(target, item);
        } catch (Exception e) {
          LOGGER.error("Error occured while unfollowing artifact", e);
          getSession().error(getString("common.error.unexpected"));
        }
        FeedbackUtils.refreshFeedback(target, getPage());
      }
     
      @Override
      protected void onConfigure() {
        super.onConfigure();
        Artifact artifact = getModelObject();
        User user = MavenArtifactNotifierSession.get().getUser();
       
        setVisible(user != null && artifact != null && userService.isFollowedArtifact(user, artifact));
      }
    };
    unfollow.add(new AuthenticatedOnlyBehavior());
View Full Code Here

      Artifact artifact = new Artifact("commons-exec");
      group.addArtifact(artifact);
      artifactService.create(artifact);

      User user = new User();
      user.setUserName("firstname.lastname@test.fr");
      user.setEmail(user.getUserName());
      userService.create(user);
     
      Calendar previousDate = GregorianCalendar.getInstance();
      previousDate.set(GregorianCalendar.DAY_OF_MONTH, -1);
     
      userService.followArtifact(user, artifact);
      user.getFollowedArtifacts().get(0).setLastNotifiedVersionDate(previousDate.getTime());
      artifact.setStatus(ArtifactStatus.INITIALIZED);
     
      ArtifactVersion artifactVersion = new ArtifactVersion("2.0-test", new Date());
      artifactVersionService.create(artifactVersion);
      artifact.addVersion(artifactVersion);
    }
    mavenSynchronizationService.synchronizeAllArtifactsAndNotifyUsers();

    User testUser = userService.getByUserName("firstname.lastname@test.fr");
    assertTrue(!testUser.getFollowedArtifacts().isEmpty());
    assertNotNull(testUser.getFollowedArtifacts().get(0).getLastNotifiedVersionDate());

    assertTrue(!testUser.getNotifications().isEmpty());
    assertEquals("2.0-test", testUser.getNotifications().get(0).getArtifactVersion().getVersion());
  }
View Full Code Here

TOP

Related Classes of fr.openwide.maven.artifact.notifier.core.business.user.model.User

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.