Package org.apache.rave.portal.model

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


    }

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


        verify(httpServletResponse);
    }

    @Test
    public void getWidgetComment() {
        WidgetComment widgetComment = new WidgetComment();
        widgetComment.setEntityId(2L);
        expect(widgetCommentService.getWidgetComment(2L)).andReturn(widgetComment);
        replay(widgetCommentService);

        WidgetComment foundComment = widgetApi.getWidgetComment(1L, 2L);
        assertEquals(widgetComment.getEntityId(), foundComment.getEntityId());

        verify(widgetCommentService);
    }
View Full Code Here

    }

    @Test
    public void updateNonExistentWidgetComment() {
        String message = "message";
        WidgetComment widgetComment = new WidgetComment();
        widgetComment.setWidgetId(2L);
        widgetComment.setText(message);
        widgetComment.setUser(new User(VALID_USER_ID, "John.Doe"));

        expect(widgetCommentService.getWidgetComment(3L)).andReturn(null);
        widgetCommentService.saveWidgetComment(widgetComment);
        replay(widgetCommentService);
View Full Code Here

    }

    @Test
    public void updateWidgetComment() {
        String message = "updated comment";
        WidgetComment widgetComment = new WidgetComment();
        widgetComment.setEntityId(2L);

        expect(widgetCommentService.getWidgetComment(2L)).andReturn(widgetComment);
        widgetCommentService.saveWidgetComment(widgetComment);
        replay(widgetCommentService);

        HttpServletResponse httpServletResponse = createMock(HttpServletResponse.class);
        httpServletResponse.setStatus(HttpStatus.NO_CONTENT.value());
        replay(httpServletResponse);

        widgetApi.updateWidgetComment(1L, 2L, message, httpServletResponse);

        assertEquals(message, widgetComment.getText());

        verify(widgetCommentService);
        verify(httpServletResponse);
    }
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

        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 GrantedAuthorityImpl("ROLE_USER"));
    }
View Full Code Here

       
        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

   
    // 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.getEntityId(), 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

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.