Package org.apache.rave.portal.model

Examples of org.apache.rave.portal.model.WidgetComment


        user.setUsername(VALID_USERNAME);
        user.setEntityId(VALID_USER_ID);
        user2 = new User();
        user2.setUsername(VALID_USERNAME2);
        user2.setEntityId(INVALID_USER_ID);
        widgetComment = new WidgetComment();
        widgetComment.setEntityId(VALID_COMMENT_ID);
        widgetComment.setUser(user);
        grantedAuthoritiesList = new ArrayList<GrantedAuthority>();
        grantedAuthoritiesList.add(new SimpleGrantedAuthority("ROLE_USER"));
    }
View Full Code Here


        EasyMock.<Collection<? extends GrantedAuthority>>expect(mockAuthentication.getAuthorities()).andReturn(grantedAuthoritiesList).anyTimes();
        expect(mockAuthentication.getPrincipal()).andReturn(user).anyTimes();
        replay(mockAuthentication);
       
        WidgetComment localWidgetComment = new WidgetComment();
        User localUser = new User();
        localUser.setEntityId(VALID_USER_ID);
        localWidgetComment.setUser(localUser);
        expect(mockWidgetCommentRepository.get(VALID_COMMENT_ID)).andReturn(localWidgetComment).anyTimes();
        replay(mockWidgetCommentRepository);
       
        assertThat(defaultWidgetCommentPermissionEvaluator.hasPermission(mockAuthentication, localWidgetComment, Permission.CREATE), is(true));
       
View Full Code Here

   
    @RequestMapping(method = RequestMethod.POST, value = "/{widgetId}/comments")
    public void createWidgetComment(@PathVariable long widgetId,
                                 @RequestParam String text,
                                 HttpServletResponse response) {
        WidgetComment widgetComment = new WidgetComment();
        widgetComment.setWidgetId(widgetId);
        widgetComment.setUser(userService.getAuthenticatedUser());
        widgetComment.setText(text);
        widgetComment.setCreatedDate(new Date());
        widgetComment.setLastModifiedDate(new Date());
       
        widgetCommentService.saveWidgetComment(widgetComment);
       
        response.setStatus(HttpStatus.NO_CONTENT.value());
    }
View Full Code Here

    public void updateWidgetComment(@PathVariable long widgetId,
                                    @PathVariable long widgetCommentId,
                                    @RequestParam String text,
                                    HttpServletResponse response) {
       
        WidgetComment widgetComment = widgetCommentService.getWidgetComment(widgetCommentId);
        if (widgetComment == null) {
            widgetComment = new WidgetComment();
            widgetComment.setWidgetId(widgetId);
            widgetComment.setUser(userService.getAuthenticatedUser());
            widgetComment.setCreatedDate(new Date());
            widgetComment.setLastModifiedDate(new Date());
        }
        widgetComment.setText(text);
       
        widgetCommentService.saveWidgetComment(widgetComment);
       
        response.setStatus(HttpStatus.NO_CONTENT.value());
    }
View Full Code Here

    // checks to see if the Authentication object principal is the owner of the supplied widgetComment object
    // if trustedDomainObject is false, pull the entity from the database first to ensure
    // the model object is trusted and hasn't been modified
    private boolean isWidgetCommentOwner(Authentication authentication, WidgetComment widgetComment, List<WidgetComment> trustedPageContainer, boolean trustedDomainObject) {
        WidgetComment trustedWidgetComment = null;
        if (trustedDomainObject) {
            trustedWidgetComment = widgetComment;
        } else {
            trustedWidgetComment = getTrustedWidgetComment(widgetComment.getId(), trustedPageContainer);
        }

        return isWidgetCommentOwnerByUsername(authentication, trustedWidgetComment.getUser().getUsername());
    }
View Full Code Here

    }

    // returns a trusted Page object, either from the PageRepository, or the
    // cached container list
    private WidgetComment getTrustedWidgetComment(long widgetCommentId, List<WidgetComment> trustedWidgetCommentContainer) {
        WidgetComment p = null;
        if (trustedWidgetCommentContainer.isEmpty()) {
            p = widgetCommentRepository.get(widgetCommentId);
            trustedWidgetCommentContainer.add(p);
        } else {
            p = trustedWidgetCommentContainer.get(0);
View Full Code Here

        Date createdDate = new Date();
        Date lastModDate = new Date();
        String text = "my comment";
        User user = new UserImpl(VALID_USER_ID);

        WidgetComment wc = new JpaWidgetComment();
        wc.setCreatedDate(createdDate);
        wc.setWidgetId(VALID_WIDGET_ID);
        wc.setLastModifiedDate(lastModDate);
        wc.setText(text);
        wc.setUser(user);
        assertThat(wc.getId(), is(nullValue()));
        repository.save(wc);
        long newId = wc.getId();
        assertThat(newId > 0, is(true));
        WidgetComment newComment = repository.get(newId);
        assertThat(newComment.getWidgetId(), is(VALID_WIDGET_ID));
        assertThat(newComment.getUser().getId(), is(VALID_USER_ID));
        assertThat(newComment.getText(), is(text));
        assertThat(newComment.getCreatedDate(), is(createdDate));
        assertThat(newComment.getLastModifiedDate(), is(lastModDate));
    }
View Full Code Here

    @Test
    @Transactional(readOnly=false)
    @Rollback(true)
    public void save_existing() {
        final String UPDATED_TEXT = "updated comment";
        WidgetComment widgetComment = repository.get(VALID_WIDGET_COMMENT_ID);
        assertThat(widgetComment.getText(), is(not(UPDATED_TEXT)));
        widgetComment.setText(UPDATED_TEXT);
        repository.save(widgetComment);
        WidgetComment updatedComment = repository.get(VALID_WIDGET_COMMENT_ID);
        assertThat(updatedComment.getText(), is(UPDATED_TEXT));
    }
View Full Code Here

    @Test
    @Transactional(readOnly=false)
    @Rollback(true)
    public void delete_jpaObject() {
        WidgetComment wc = repository.get(VALID_WIDGET_COMMENT_ID);
        assertThat(wc, is(notNullValue()));
        repository.delete(wc);
        wc = repository.get(VALID_WIDGET_COMMENT_ID);
        assertThat(wc, is(nullValue()));
    }
View Full Code Here

    @Test
    @Transactional(readOnly=false)
    @Rollback(true)
    public void delete_implObject() {
        WidgetComment wc = repository.get(VALID_WIDGET_COMMENT_ID);
        assertThat(wc, is(notNullValue()));
        WidgetComment impl = new WidgetCommentImpl(wc.getId());
        repository.delete(impl);
        wc = repository.get(VALID_WIDGET_COMMENT_ID);
        assertThat(wc, is(nullValue()));
    }
View Full Code Here

TOP

Related Classes of org.apache.rave.portal.model.WidgetComment

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.