Changeset 1892


Ignore:
Timestamp:
04/19/12 14:44:19 (12 years ago)
Author:
twagoo
Message:

Added canDelete property to Comment
ComponentRegistryDbImpl? sets property for all returned comments based on current principal
Comment retrieval methods of ComponentRegistry interface now require principal as parameter

Tests modified and extended

Location:
ComponentRegistry/trunk/ComponentRegistry/src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/ComponentRegistry.java

    r1753 r1892  
    151151     * @throws ComponentRegistryException
    152152     */
    153     List<Comment> getCommentsInProfile(String profileId) throws ComponentRegistryException;
     153    List<Comment> getCommentsInProfile(String profileId, Principal principal) throws ComponentRegistryException;
    154154
    155155    /**
     
    160160     * @throws ComponentRegistryException
    161161     */
    162     Comment getSpecifiedCommentInProfile(String profileId, String commentId) throws ComponentRegistryException;
     162    Comment getSpecifiedCommentInProfile(String profileId, String commentId, Principal principal) throws ComponentRegistryException;
    163163
    164164    /**
     
    168168     * @throws ComponentRegistryException
    169169     */
    170     List<Comment> getCommentsInComponent(String componentId) throws ComponentRegistryException;
     170    List<Comment> getCommentsInComponent(String componentId, Principal principal) throws ComponentRegistryException;
    171171
    172172    /**
     
    177177     * @throws ComponentRegistryException
    178178     */
    179     Comment getSpecifiedCommentInComponent(String componentId, String commentId) throws ComponentRegistryException;
     179    Comment getSpecifiedCommentInComponent(String componentId, String commentId, Principal principal) throws ComponentRegistryException;
    180180
    181181    /**
  • ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/impl/database/ComponentRegistryDbImpl.java

    r1870 r1892  
    3535import clarin.cmdi.componentregistry.model.ProfileDescription;
    3636import clarin.cmdi.componentregistry.model.RegistryUser;
     37import java.util.Collection;
     38import java.util.Collections;
    3739
    3840/**
     
    129131
    130132    @Override
    131     public List<Comment> getCommentsInProfile(String profileId) throws ComponentRegistryException {
     133    public List<Comment> getCommentsInProfile(String profileId, Principal principal) throws ComponentRegistryException {
    132134        try {
    133135            if (profileDescriptionDao.isInRegistry(profileId, getUserId())) {
    134                 return commentsDao.getCommentsFromProfile(profileId);
     136                final List<Comment> commentsFromProfile = commentsDao.getCommentsFromProfile(profileId);
     137                setCanDeleteInComments(commentsFromProfile, principal);
     138                return commentsFromProfile;
    135139            } else {
    136140                // Profile does not exist (at least not in this registry)
     
    143147
    144148    @Override
    145     public Comment getSpecifiedCommentInProfile(String profileId, String commentId) throws ComponentRegistryException {
     149    public Comment getSpecifiedCommentInProfile(String profileId, String commentId, Principal principal) throws ComponentRegistryException {
    146150        try {
    147151            Comment comment = commentsDao.getSpecifiedCommentFromProfile(commentId);
     
    149153                    && profileId.equals(comment.getProfileDescriptionId())
    150154                    && profileDescriptionDao.isInRegistry(comment.getProfileDescriptionId(), getUserId())) {
     155                setCanDeleteInComments(Collections.singleton(comment), principal);
    151156                return comment;
    152157            } else {
     
    160165
    161166    @Override
    162     public List<Comment> getCommentsInComponent(String componentId) throws ComponentRegistryException {
     167    public List<Comment> getCommentsInComponent(String componentId, Principal principal) throws ComponentRegistryException {
    163168        try {
    164169            if (componentDescriptionDao.isInRegistry(componentId, getUserId())) {
    165                 return commentsDao.getCommentsFromComponent(componentId);
     170                final List<Comment> commentsFromComponent = commentsDao.getCommentsFromComponent(componentId);
     171                setCanDeleteInComments(commentsFromComponent, principal);
     172                return commentsFromComponent;
    166173            } else {
    167174                // Component does not exist (at least not in this registry)
     
    174181
    175182    @Override
    176     public Comment getSpecifiedCommentInComponent(String componentId, String commentId) throws ComponentRegistryException {
     183    public Comment getSpecifiedCommentInComponent(String componentId, String commentId, Principal principal) throws ComponentRegistryException {
    177184        try {
    178185            Comment comment = commentsDao.getSpecifiedCommentFromComponent(commentId);
     
    180187                    && componentId.equals(comment.getComponentDescriptionId())
    181188                    && componentDescriptionDao.isInRegistry(comment.getComponentDescriptionId(), getUserId())) {
     189                setCanDeleteInComments(Collections.singleton(comment), principal);
    182190                return comment;
    183191            } else {
     
    187195        } catch (DataAccessException ex) {
    188196            throw new ComponentRegistryException("Database access error while trying to get comment from component", ex);
     197        }
     198    }
     199
     200    /**
     201     * Sets the {@link Comment#setCanDelete(boolean) canDelete} property on all comments in the provided collection for the perspective of
     202     * the specified principal.
     203     * Comment owners (determined by {@link Comment#getUserId() }) and admins can delete, others cannot.
     204     *
     205     * @param comments comments to configure
     206     * @param principal user to configure for
     207     * @see Comment#isCanDelete()
     208     */
     209    private void setCanDeleteInComments(Collection<Comment> comments, Principal principal) {
     210        if (principal != null && principal.getName() != null) {
     211            final RegistryUser registryUser = userDao.getByPrincipalName(principal.getName());
     212            final String registryUserId = registryUser.getId().toString();
     213            final boolean isAdmin = configuration.isAdminUser(principal);
     214            for (Comment comment : comments) {
     215                comment.setCanDelete(isAdmin || comment.getUserId().equals(registryUserId));
     216            }
    189217        }
    190218    }
  • ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/model/Comment.java

    r1697 r1892  
    1212/**
    1313 *
    14  * @author jean-charles FerriÚres <jean-charles.ferrieres@mpi.nl>
     14 * @author Jean-Charles FerriÚres <jean-charles.ferrieres@mpi.nl>
     15 * @author Twan Goosen <twan.goosen@mpi.nl>
    1516 */
    1617@XmlRootElement(name = "comment")
     
    2425    private String id;
    2526    private String userName;
     27    private boolean canDelete;
    2628    @XmlTransient // this prevents userId from being serialized to XML and thus exposed (which is useless and undesirable)
    2729    private String userId;
     
    7678
    7779    /**
    78      * 
     80     *
    7981     * @return userName, that is the user's 'real' name, not login name
    8082     */
     
    8890    public void setUserName(String userName) {
    8991        this.userName = userName;
     92    }
     93
     94    /**
     95     * @return whether comment can be deleted
     96     */
     97    public boolean isCanDelete() {
     98        return canDelete;
     99    }
     100
     101    /**
     102     * @param canDelete whether comment can be deleted
     103     */
     104    public void setCanDelete(boolean canDelete) {
     105        this.canDelete = canDelete;
    90106    }
    91107
     
    103119    /*
    104120     * Helper method to set the Date in the same format
    105      * @param time, long that contains the time to be set 
     121     * @param time, long that contains the time to be set
    106122     */
    107123    public static String createNewDate(long time) {
  • ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/rest/ComponentRegistryRestService.java

    r1870 r1892  
    4848@Path("/registry")
    4949public class ComponentRegistryRestService {
    50 
     50   
    5151    @Context
    5252    private UriInfo uriInfo;
     
    6565    @Inject(value = "componentRegistryFactory")
    6666    private ComponentRegistryFactory componentRegistryFactory;
    67 
     67   
    6868    private ComponentRegistry getRegistry(boolean userspace) {
    6969        Principal userPrincipal = security.getUserPrincipal();
     
    7171        return getRegistry(userspace, userCredentials);
    7272    }
    73 
     73   
    7474    private ComponentRegistry getRegistry(boolean userspace, UserCredentials userCredentials) {
    7575        return componentRegistryFactory.getComponentRegistry(userspace, userCredentials);
     
    8888        return principal;
    8989    }
    90 
     90   
    9191    private UserCredentials getUserCredentials(Principal userPrincipal) {
    9292        UserCredentials userCredentials = null;
     
    9696        return userCredentials;
    9797    }
    98 
     98   
    9999    @GET
    100100    @Path("/components")
     
    107107        return components;
    108108    }
    109 
     109   
    110110    @GET
    111111    @Path("/profiles")
     
    114114            @QueryParam(METADATA_EDITOR_PARAM) @DefaultValue("false") boolean metadataEditor) throws ComponentRegistryException {
    115115        long start = System.currentTimeMillis();
    116 
     116       
    117117        List<ProfileDescription> profiles;
    118118        if (metadataEditor) {
     
    121121            profiles = getRegistry(userspace).getProfileDescriptions();
    122122        }
    123 
     123       
    124124        LOG.info("Releasing " + profiles.size() + " registered profiles into the world (" + (System.currentTimeMillis() - start)
    125125                + " millisecs)");
    126126        return profiles;
    127127    }
    128 
     128   
    129129    @GET
    130130    @Path("/components/{componentId}")
     
    140140        }
    141141    }
    142 
     142   
    143143    @GET
    144144    @Path("/components/{componentId}/{rawType}")
     
    157157            if ("xml".equalsIgnoreCase(rawType)) {
    158158                result = new StreamingOutput() {
    159 
     159                   
    160160                    @Override
    161161                    public void write(OutputStream output) throws IOException, WebApplicationException {
     
    170170            } else if ("xsd".equalsIgnoreCase(rawType)) {
    171171                result = new StreamingOutput() {
    172 
     172                   
    173173                    @Override
    174174                    public void write(OutputStream output) throws IOException, WebApplicationException {
     
    179179                            throw new WebApplicationException(e, Response.serverError().status(Status.INTERNAL_SERVER_ERROR).build());
    180180                        }
    181 
     181                       
    182182                    }
    183183                };
     
    192192        }
    193193    }
    194 
     194   
    195195    public ComponentRegistry findRegistry(String id, RegistryClosure<? extends AbstractDescription> clos) throws ComponentRegistryException {
    196196        AbstractDescription desc = null;
     
    209209        return result;
    210210    }
    211 
     211   
    212212    @GET
    213213    @Path("/profiles/{profileId}")
     
    223223        }
    224224    }
    225 
     225   
    226226    @GET
    227227    @Path("/components/usage/{componentId}")
     
    233233            List<ComponentDescription> components = registry.getUsageInComponents(componentId);
    234234            List<ProfileDescription> profiles = registry.getUsageInProfiles(componentId);
    235 
     235           
    236236            LOG.info("Found " + components.size() + " components and " + profiles.size() + " profiles that use component " + componentId
    237237                    + " (" + (System.currentTimeMillis() - start) + " millisecs)");
    238 
     238           
    239239            List<AbstractDescription> usages = new ArrayList<AbstractDescription>(components.size() + profiles.size());
    240240            usages.addAll(components);
    241241            usages.addAll(profiles);
    242 
     242           
    243243            return usages;
    244244        } catch (ComponentRegistryException e) {
     
    247247        }
    248248    }
    249 
     249   
    250250    @GET
    251251    @Path("/profiles/{profileId}/comments")
     
    253253    public List<Comment> getCommentsFromProfile(@PathParam("profileId") String profileId, @QueryParam(USERSPACE_PARAM) @DefaultValue("false") boolean userspace) throws ComponentRegistryException {
    254254        long start = System.currentTimeMillis();
    255         List<Comment> comments = getRegistry(userspace).getCommentsInProfile(profileId);
     255        final Principal principal = security.getUserPrincipal();
     256        List<Comment> comments = getRegistry(userspace).getCommentsInProfile(profileId, principal);
    256257        LOG.info("Releasing " + comments.size() + " registered comments in Profile into the world (" + (System.currentTimeMillis() - start)
    257258                + " millisecs)");
    258259        return comments;
    259260    }
    260 
     261   
    261262    @GET
    262263    @Path("/components/{componentId}/comments")
     
    264265    public List<Comment> getCommentsFromComponent(@PathParam("componentId") String componentId, @QueryParam(USERSPACE_PARAM) @DefaultValue("false") boolean userspace) throws ComponentRegistryException {
    265266        long start = System.currentTimeMillis();
    266         List<Comment> comments = getRegistry(userspace).getCommentsInComponent(componentId);
     267        final Principal principal = security.getUserPrincipal();
     268        List<Comment> comments = getRegistry(userspace).getCommentsInComponent(componentId, principal);
    267269        LOG.info("Releasing " + comments.size() + " registered comments in Component into the world (" + (System.currentTimeMillis() - start)
    268270                + " millisecs)");
    269271        return comments;
    270272    }
    271 
     273   
    272274    @GET
    273275    @Path("/profiles/{profileId}/comments/{commentId}")
     
    275277    public Comment getSpecifiedCommentFromProfile(@PathParam("profileId") String profileId, @PathParam("commentId") String commentId, @QueryParam(USERSPACE_PARAM) @DefaultValue("false") boolean userspace) throws ComponentRegistryException {
    276278        LOG.info(" Comments of component with id" + commentId + " are requested.");
    277         return getRegistry(userspace).getSpecifiedCommentInProfile(profileId, commentId);
    278     }
    279 
     279        final Principal principal = security.getUserPrincipal();
     280        return getRegistry(userspace).getSpecifiedCommentInProfile(profileId, commentId, principal);
     281    }
     282   
    280283    @GET
    281284    @Path("/components/{componentId}/comments/{commentId}")
     
    283286    public Comment getSpecifiedCommentFromComponent(@PathParam("componentId") String componentId, @PathParam("commentId") String commentId, @QueryParam(USERSPACE_PARAM) @DefaultValue("false") boolean userspace) throws ComponentRegistryException {
    284287        LOG.info(" Comments of component with id" + commentId + " are requested.");
    285         return getRegistry(userspace).getSpecifiedCommentInComponent(componentId, commentId);
     288        final Principal principal = security.getUserPrincipal();
     289        return getRegistry(userspace).getSpecifiedCommentInComponent(componentId, commentId, principal);
    286290    }
    287291
     
    305309        }
    306310    }
    307 
     311   
    308312    @POST
    309313    @Path("/profiles/{profileId}/comments/{commentId}")
     
    316320        }
    317321    }
    318 
     322   
    319323    @POST
    320324    @Path("/components/{componentId}/comments/{commentId}")
     
    327331        }
    328332    }
    329 
     333   
    330334    @POST
    331335    @Path("/profiles/{profileId}/publish")
     
    351355        }
    352356    }
    353 
     357   
    354358    @POST
    355359    @Path("/profiles/{profileId}/update")
     
    376380            return Response.status(Status.UNAUTHORIZED).entity(ex.getMessage()).build();
    377381        }
    378 
     382       
    379383    }
    380384
     
    398402        }
    399403    }
    400 
     404   
    401405    @POST
    402406    @Path("/components/{componentId}/publish")
     
    423427        }
    424428    }
    425 
     429   
    426430    @POST
    427431    @Path("/components/{componentId}/update")
     
    448452        }
    449453    }
    450 
     454   
    451455    private void updateDescription(AbstractDescription desc, String name, String description, String domainName, String group) {
    452456        desc.setName(name);
     
    456460        desc.setRegistrationDate(AbstractDescription.createNewDate());
    457461    }
    458 
     462   
    459463    @DELETE
    460464    @Path("/components/{componentId}")
     
    482486        return Response.ok().build();
    483487    }
    484 
     488   
    485489    @DELETE
    486490    @Path("/profiles/{profileId}")
     
    507511        return Response.ok().build();
    508512    }
    509 
     513   
    510514    @DELETE
    511515    @Path("/profiles/{profileId}/comments/{commentId}")
     
    515519            final Principal principal = checkAndGetUserPrincipal();
    516520            final ComponentRegistry registry = getRegistry(userspace);
    517             final Comment comment = registry.getSpecifiedCommentInProfile(profileId, commentId);
     521            final Comment comment = registry.getSpecifiedCommentInProfile(profileId, commentId, principal);
    518522            if (comment != null && profileId.equals(comment.getProfileDescriptionId())) {
    519523                LOG.info("Comment with id: " + commentId + " set for deletion.");
     
    538542        return Response.ok().build();
    539543    }
    540 
     544   
    541545    @DELETE
    542546    @Path("/components/{componentId}/comments/{commentId}")
     
    546550            final Principal principal = checkAndGetUserPrincipal();
    547551            final ComponentRegistry registry = getRegistry(userspace);
    548             final Comment comment = registry.getSpecifiedCommentInComponent(componentId, commentId);
     552            final Comment comment = registry.getSpecifiedCommentInComponent(componentId, commentId, principal);
    549553            if (comment != null && componentId.equals(comment.getComponentDescriptionId())) {
    550554                LOG.info("Comment with id: " + commentId + " set for deletion.");
     
    569573        return Response.ok().build();
    570574    }
    571 
     575   
    572576    @GET
    573577    @Path("/profiles/{profileId}/{rawType}")
     
    584588            checkAndThrowDescription(desc, profileId);
    585589            String fileName = desc.getName() + "." + rawType;
    586 
     590           
    587591            if ("xml".equalsIgnoreCase(rawType)) {
    588592                result = new StreamingOutput() {
    589 
     593                   
    590594                    @Override
    591595                    public void write(OutputStream output) throws IOException, WebApplicationException {
     
    600604            } else if ("xsd".equalsIgnoreCase(rawType)) {
    601605                result = new StreamingOutput() {
    602 
     606                   
    603607                    @Override
    604608                    public void write(OutputStream output) throws IOException, WebApplicationException {
     
    621625        }
    622626    }
    623 
     627   
    624628    private void checkAndThrowDescription(AbstractDescription desc, String id) {
    625629        if (desc == null) {
     
    627631        }
    628632    }
    629 
     633   
    630634    private Response createDownloadResponse(StreamingOutput result, String fileName) {
    631635        //Making response so it triggers browsers native save as dialog.
     
    633637                "attachment; filename=\"" + fileName + "\"").entity(result).build();
    634638        return response;
    635 
    636     }
    637 
     639       
     640    }
     641   
    638642    @POST
    639643    @Path("/profiles")
     
    659663        }
    660664    }
    661 
     665   
    662666    @POST
    663667    @Path("/components")
     
    683687        }
    684688    }
    685 
     689   
    686690    @POST
    687691    @Path("/components/{componentId}/comments")
     
    709713        }
    710714    }
    711 
     715   
    712716    @POST
    713717    @Path("/profiles/{profileId}/comments")
     
    735739        }
    736740    }
    737 
     741   
    738742    @GET
    739743    @Path("/pingSession")
     
    750754        return Response.ok().entity("<session stillActive=\"" + stillActive + "\"/>").build();
    751755    }
    752 
     756   
    753757    private Response register(InputStream input, AbstractDescription desc, UserCredentials userCredentials, boolean userspace,
    754758            RegisterAction action) {
     
    794798        }
    795799    }
    796 
     800   
    797801    private Response registerComment(InputStream input, ComponentRegistry registry, boolean userspace,
    798802            AbstractDescription description, Principal principal, UserCredentials userCredentials) {
     
    814818                    }
    815819                }
    816 
     820               
    817821                int returnCode = registry.registerComment(com, principal.getName());
    818822                if (returnCode == 0) {
     
    840844        }
    841845    }
    842 
     846   
    843847    private ComponentDescription createNewComponentDescription() {
    844848        ComponentDescription desc = ComponentDescription.createNewDescription();
     
    846850        return desc;
    847851    }
    848 
     852   
    849853    private ProfileDescription createNewProfileDescription() {
    850854        ProfileDescription desc = ProfileDescription.createNewDescription();
     
    852856        return desc;
    853857    }
    854 
     858   
    855859    private Comment createNewComment() {
    856860        Comment com = Comment.createANewComment();
    857861        return com;
    858862    }
    859 
     863   
    860864    private String createXlink(String id) {
    861865        URI uri = uriInfo.getRequestUriBuilder().path(id).build();
    862866        return uri.toString();
    863867    }
    864 
     868   
    865869    private void validate(RegisterResponse response, Validator... validators) {
    866870        for (Validator validator : validators) {
     
    872876        }
    873877    }
    874 
     878   
    875879    private void validateComment(CommentResponse response, Validator... validators) {
    876880        for (Validator validator : validators) {
  • ComponentRegistry/trunk/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/impl/database/ComponentRegistryDbImplTest.java

    r1816 r1892  
    11package clarin.cmdi.componentregistry.impl.database;
    2 
    3 import static org.junit.Assert.assertEquals;
    4 import static org.junit.Assert.assertNotNull;
    5 import static org.junit.Assert.assertNull;
    6 import static org.junit.Assert.assertTrue;
    7 import static org.junit.Assert.fail;
    8 
    9 import java.io.ByteArrayOutputStream;
    10 import java.io.OutputStream;
    11 import java.util.Calendar;
    12 
    13 import org.apache.commons.lang.time.DateFormatUtils;
    14 import org.junit.Before;
    15 import org.junit.Test;
    16 import org.junit.runner.RunWith;
    17 import org.springframework.beans.factory.annotation.Autowired;
    18 import org.springframework.jdbc.core.JdbcTemplate;
    19 import org.springframework.test.context.ContextConfiguration;
    20 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
    212
    223import clarin.cmdi.componentregistry.ComponentRegistry;
     
    3314import clarin.cmdi.componentregistry.rest.DummyPrincipal;
    3415import clarin.cmdi.componentregistry.rest.RegistryTestHelper;
     16import java.io.ByteArrayOutputStream;
     17import java.io.OutputStream;
     18import java.util.Calendar;
    3519import java.util.Date;
    3620import java.util.List;
     21import org.apache.commons.lang.time.DateFormatUtils;
     22import org.junit.Before;
     23import org.junit.Test;
     24import org.junit.runner.RunWith;
     25import org.springframework.beans.factory.annotation.Autowired;
     26import org.springframework.jdbc.core.JdbcTemplate;
     27import org.springframework.test.context.ContextConfiguration;
     28import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
     29
     30import static org.junit.Assert.*;
    3731
    3832@RunWith(SpringJUnit4ClassRunner.class)
     
    204198        Comment comment = createComment(description);
    205199        register.registerComment(comment, USER_CREDS.getPrincipalName());
    206         assertEquals(1, register.getCommentsInProfile(description.getId()).size());
     200        assertEquals(1, register.getCommentsInProfile(description.getId(), null).size());
    207201        return comment;
    208202    }
     
    669663        assertEquals(0, description.getCommentsCount());
    670664
    671         List<Comment> comments = register.getCommentsInProfile(description.getId());
     665        List<Comment> comments = register.getCommentsInProfile(description.getId(), null);
    672666        assertEquals(1, comments.size());
    673667
     
    675669        assertEquals("0", comment.getUserId());
    676670        assertEquals(USER_CREDS.getDisplayName(), comment.getUserName());
     671       
     672        // Should not be allowed to delete, not authenticated
     673        assertFalse(comment.isCanDelete());
    677674
    678675        description = register.getProfileDescription(description.getId());
    679676        assertEquals(1, description.getCommentsCount());
     677
     678        // Test if owner can delete
     679        comments = register.getCommentsInProfile(description.getId(), DummyPrincipal.DUMMY_PRINCIPAL);
     680        assertTrue(comments.get(0).isCanDelete());
     681
     682        // Test if admin can delete
     683        userDao.insertUser(createUser(DummyPrincipal.DUMMY_ADMIN_CREDENTIALS));
     684        comments = register.getCommentsInProfile(description.getId(), PRINCIPAL_ADMIN);
     685        assertTrue(comments.get(0).isCanDelete());
    680686    }
    681687
     
    692698        assertEquals(0, description.getCommentsCount());
    693699
    694         List<Comment> comments = register.getCommentsInProfile(description.getId());
     700        List<Comment> comments = register.getCommentsInProfile(description.getId(), null);
    695701        assertEquals(1, comments.size());
    696702
     
    714720        assertNotNull(comment);
    715721
    716         List<Comment> comments = register.getCommentsInProfile(description.getId());
     722        List<Comment> comments = register.getCommentsInProfile(description.getId(), null);
    717723        assertEquals(1, comments.size());
    718724        description = register.getProfileDescription(description.getId());
     
    721727        comment = comments.get(0);
    722728        register.deleteComment(comment.getId(), USER_CREDS.getPrincipal());
    723         comments = register.getCommentsInProfile(description.getId());
     729        comments = register.getCommentsInProfile(description.getId(), null);
    724730        assertEquals(0, comments.size());
    725731        description = register.getProfileDescription(description.getId());
     
    739745        assertNotNull(comment);
    740746
    741         List<Comment> comments = register.getCommentsInProfile(description.getId());
     747        List<Comment> comments = register.getCommentsInProfile(description.getId(), null);
    742748        assertEquals(1, comments.size());
    743749        comment = comments.get(0);
  • ComponentRegistry/trunk/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/model/CommentResponseTest.java

    r1699 r1892  
    1717
    1818    /**
    19      * Test with no validate attribute should return errors
    20      * @throws Exception
     19     * Test with no validate attribute should return errors
     20     *
     21     * @throws Exception
    2122     */
    2223    @Test
     
    4647    /**
    4748     * Test successfully processed
    48      * @throws Exception
     49     *
     50     * @throws Exception
    4951     */
    5052    @Test
     
    6668        expected += "        <id>myId</id>\n";
    6769        expected += "        <userName>J. Unit</userName>\n";
     70        expected += "        <canDelete>false</canDelete>\n";
    6871        expected += "    </comment>\n";
    6972        expected += "</commentResponse>\n";
  • ComponentRegistry/trunk/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/model/CommentTest.java

    r1699 r1892  
    11package clarin.cmdi.componentregistry.model;
    2 
    3 import static org.junit.Assert.assertEquals;
    42
    53import clarin.cmdi.componentregistry.MDMarshaller;
     
    75import java.io.ByteArrayOutputStream;
    86import org.junit.Test;
     7
     8import static org.junit.Assert.assertEquals;
    99
    1010/**
     
    3434        expected += "    <id>1</id>\n";
    3535        expected += "    <userName>J. Unit</userName>\n";
     36        expected += "    <canDelete>false</canDelete>\n";
    3637        expected += "</comment>\n";
    3738        assertEquals(expected, out.toString());
     
    6263        expected += "    <id>1</id>\n";
    6364        expected += "    <userName>J. Unit</userName>\n";
     65        expected += "    <canDelete>false</canDelete>\n";
    6466        expected += "</comment>\n";
    6567        assertEquals(expected, out.toString());
  • ComponentRegistry/trunk/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/rest/DummyPrincipal.java

    r1329 r1892  
    1616        }
    1717    };
     18    public static final UserCredentials DUMMY_ADMIN_CREDENTIALS = new UserCredentials(DUMMY_ADMIN_PRINCIPAL);
    1819    private final String username;
    1920
Note: See TracChangeset for help on using the changeset viewer.