Package org.wso2.carbon.registry.core

Examples of org.wso2.carbon.registry.core.Comment


   * @throws RegistryException Registry implementations may handle exceptions and throw
   *                           RegistryException if the exception has to be propagated to the
   *                           client.
   */
  public WSComment WSgetSingleComment(String commentPath) throws RegistryException {
    Comment comment = (Comment) getRootRegistry().get(commentPath);
    return CommonUtil.RegistryCommenttoWSComment(comment);
  }
View Full Code Here


            r1.setDescription("This is a file to be renamed");
            byte[] r1content = "R2 content".getBytes();
            r1.setContent(r1content);
            r1.setMediaType("txt");

            Comment c1 = new Comment();
            c1.setResourcePath(path);
            c1.setText("This is a test comment1");

            Comment c2 = new Comment();
            c2.setResourcePath(path);
            c2.setText("This is a test comment2");

            r1.setProperty("key1", "value1");
            r1.setProperty("key2", "value2");

            registry.put(path, r1);
            registry.addComment(path, c1);
            registry.addComment(path, c2);
            registry.applyTag(path, "tag1");
            registry.applyTag(path, "tag2");
            registry.applyTag(path, "tag3");
            registry.rateResource(path, 4);

            Resource r2 = registry.get(path);

            assertEquals("Properties are not equal", r1.getProperty("key1"), r2.getProperty("key1"));
            assertEquals("Properties are not equal", r1.getProperty("key2"), r2.getProperty("key2"));
            assertEquals("File content is not matching", new String((byte[]) r1.getContent()),
                    new String((byte[]) r2.getContent()));
            assertTrue(c1.getText() + " is not associated for resource" + path,
                    containsComment(commentPath, c1.getText()));
            assertTrue(c2.getText() + " is not associated for resource" + path,
                    containsComment(commentPath, c2.getText()));
            assertTrue("Tag1 is not exist", containsTag(path, "tag1"));
            assertTrue("Tag2 is not exist", containsTag(path, "tag2"));
            assertTrue("Tag3 is not exist", containsTag(path, "tag3"));

            float rating = registry.getAverageRating(path);
            assertEquals("Rating is not mathching", rating, (float) 4.0, (float) 0.01);
            assertEquals("Media type not exist", r1.getMediaType(), r2.getMediaType());
//            assertEquals("Authour name is not exist", r1.getAuthorUserName(), r2.getAuthorUserName());
            assertEquals("Description is not exist", r1.getDescription(), r2.getDescription());

            String new_path_returned;
            new_path_returned = registry.rename(path, new_path);

            assertEquals("New resource path is not equal", new_path, new_path_returned);

            /*get renamed resource details*/

            Resource r1Renamed = registry.get(new_path);

            assertEquals("File content is not matching", new String((byte[]) r2.getContent()),
                    new String((byte[]) r1Renamed.getContent()));
            assertEquals("Properties are not equal", r2.getProperty("key1"),
                    r1Renamed.getProperty("key1"));
            assertEquals("Properties are not equal", r2.getProperty("key2"),
                    r1Renamed.getProperty("key2"));
            assertTrue(c1.getText() + " is not associated for resource" + new_path,
                    containsComment(commentPathNew, c1.getText()));
            assertTrue(c2.getText() + " is not associated for resource" + new_path,
                    containsComment(commentPathNew, c2.getText()));
            assertTrue("Tag1 is not copied", containsTag(new_path, "tag1"));
            assertTrue("Tag2 is not copied", containsTag(new_path, "tag2"));
            assertTrue("Tag3 is not copied", containsTag(new_path, "tag3"));

            float rating1 = registry.getAverageRating(new_path);
View Full Code Here

            String new_path = "/c9111/c1/c3";
            String commentPathNew = new_path + RegistryConstants.URL_SEPARATOR + "comments";
            Resource r1 = registry.newCollection();
            r1.setDescription("This is a file to be renamed");

            Comment c1 = new Comment();
            c1.setResourcePath(path);
            c1.setText("This is first test comment");

            Comment c2 = new Comment();
            c2.setResourcePath(path);
            c2.setText("This is secound test comment");

            r1.setProperty("key1", "value1");
            r1.setProperty("key2", "value2");

            registry.put(path, r1);
            registry.addComment(path, c1);
            registry.addComment(path, c2);
            registry.applyTag(path, "tag1");
            registry.applyTag(path, "tag2");
            registry.applyTag(path, "tag3");
            registry.rateResource(path, 4);

            Resource r2 = registry.get(path);

            assertEquals("Properties are not equal", r1.getProperty("key1"),
                    r2.getProperty("key1"));
            assertEquals("Properties are not equal", r1.getProperty("key2"),
                    r2.getProperty("key2"));
            assertTrue(c1.getText() + " is not associated for resource" + path,
                    containsComment(commentPath, c1.getText()));
            assertTrue(c2.getText() + " is not associated for resource" + path,
                    containsComment(commentPath, c2.getText()));
            assertTrue("Tag1 is not copied", containsTag(path, "tag1"));
            assertTrue("Tag2 is not copied", containsTag(path, "tag2"));
            assertTrue("Tag3 is not copied", containsTag(path, "tag3"));

            float rating = registry.getAverageRating(path);
            assertEquals("Rating is not mathching", rating, (float) 4.0, (float) 0.01);
//            assertEquals("Authour name is not exist", r1.getAuthorUserName(), r2.getAuthorUserName());

            String new_path_returned;
            new_path_returned = registry.rename(path, new_path);

            assertEquals("New resource path is not equal", new_path, new_path_returned);

            /*get renamed resource details*/

            Resource r1Renamed = registry.get(new_path);

            assertEquals("Properties are not equal", r2.getProperty("key1"),
                    r1Renamed.getProperty("key1"));
            assertEquals("Properties are not equal", r2.getProperty("key2"),
                    r1Renamed.getProperty("key2"));
            assertTrue(c1.getText() + " is not associated for resource" + new_path,
                    containsComment(commentPathNew, c1.getText()));
            assertTrue(c2.getText() + " is not associated for resource" + new_path,
                    containsComment(commentPathNew, c2.getText()));
            assertTrue("Tag1 is not copied", containsTag(new_path, "tag1"));
            assertTrue("Tag2 is not copied", containsTag(new_path, "tag2"));
            assertTrue("Tag3 is not copied", containsTag(new_path, "tag3"));

            float rating1 = registry.getAverageRating(new_path);
View Full Code Here

        return CommentBeanPopulator.populate(registry, path);
    }

    public void addComment(String comment, String path, String sessionId) throws RegistryException {
        UserRegistry registry = (UserRegistry) getRootRegistry();
        registry.addComment(path, new Comment(comment));
    }
View Full Code Here

            r1.setDescription("This is a file to be renamed");
            byte[] r1content = "R2 content".getBytes();
            r1.setContent(r1content);
            r1.setMediaType("txt");

            Comment c1 = new Comment();
            c1.setResourcePath(path);
            c1.setText("This is a test comment1");

            Comment c2 = new Comment();
            c2.setResourcePath(path);
            c2.setText("This is a test comment2");

            r1.setProperty("key1", "value1");
            r1.setProperty("key2", "value2");

            registry.put(path, r1);
            registry.addComment(path, c1);
            registry.addComment(path, c2);
            registry.applyTag(path, "tag1");
            registry.applyTag(path, "tag2");
            registry.applyTag(path, "tag3");
            registry.rateResource(path, 4);

            Resource r2 = registry.get(path);

            assertEquals("Properties are not equal", r1.getProperty("key1"), r2.getProperty("key1"));
            assertEquals("Properties are not equal", r1.getProperty("key2"), r2.getProperty("key2"));
            assertEquals("File content is not matching", new String((byte[]) r1.getContent()),
                    new String((byte[]) r2.getContent()));
            assertTrue(c1.getText() + " is not associated for resource" + path,
                    containsComment(commentPath, c1.getText()));
            assertTrue(c2.getText() + " is not associated for resource" + path,
                    containsComment(commentPath, c2.getText()));
            assertTrue("Tag1 is not exist", containsTag(path, "tag1"));
            assertTrue("Tag2 is not exist", containsTag(path, "tag2"));
            assertTrue("Tag3 is not exist", containsTag(path, "tag3"));

            float rating = registry.getAverageRating(path);
            assertEquals("Rating is not mathching", rating, (float) 4.0, (float) 0.01);
            assertEquals("Media type not exist", r1.getMediaType(), r2.getMediaType());
//            assertEquals("Authour name is not exist", r1.getAuthorUserName(), r2.getAuthorUserName());
            assertEquals("Description is not exist", r1.getDescription(), r2.getDescription());

            String new_path_returned;
            new_path_returned = registry.rename(path, new_path);

            assertEquals("New resource path is not equal", new_path, new_path_returned);

            /*get renamed resource details*/

            Resource r1Renamed = registry.get(new_path);

            assertEquals("File content is not matching", new String((byte[]) r2.getContent()),
                    new String((byte[]) r1Renamed.getContent()));
            assertEquals("Properties are not equal", r2.getProperty("key1"),
                    r1Renamed.getProperty("key1"));
            assertEquals("Properties are not equal", r2.getProperty("key2"),
                    r1Renamed.getProperty("key2"));
            assertTrue(c1.getText() + " is not associated for resource" + new_path,
                    containsComment(commentPathNew, c1.getText()));
            assertTrue(c2.getText() + " is not associated for resource" + new_path,
                    containsComment(commentPathNew, c2.getText()));
            assertTrue("Tag1 is not copied", containsTag(new_path, "tag1"));
            assertTrue("Tag2 is not copied", containsTag(new_path, "tag2"));
            assertTrue("Tag3 is not copied", containsTag(new_path, "tag3"));

            float rating1 = registry.getAverageRating(new_path);
View Full Code Here

            String new_path = "/c9111/c1/c3";
            String commentPathNew = new_path + RegistryConstants.URL_SEPARATOR + "comments";
            Resource r1 = registry.newCollection();
            r1.setDescription("This is a file to be renamed");

            Comment c1 = new Comment();
            c1.setResourcePath(path);
            c1.setText("This is first test comment");

            Comment c2 = new Comment();
            c2.setResourcePath(path);
            c2.setText("This is secound test comment");

            r1.setProperty("key1", "value1");
            r1.setProperty("key2", "value2");

            registry.put(path, r1);
            registry.addComment(path, c1);
            registry.addComment(path, c2);
            registry.applyTag(path, "tag1");
            registry.applyTag(path, "tag2");
            registry.applyTag(path, "tag3");
            registry.rateResource(path, 4);

            Resource r2 = registry.get(path);

            assertEquals("Properties are not equal", r1.getProperty("key1"),
                    r2.getProperty("key1"));
            assertEquals("Properties are not equal", r1.getProperty("key2"),
                    r2.getProperty("key2"));
            assertTrue(c1.getText() + " is not associated for resource" + path,
                    containsComment(commentPath, c1.getText()));
            assertTrue(c2.getText() + " is not associated for resource" + path,
                    containsComment(commentPath, c2.getText()));
            assertTrue("Tag1 is not copied", containsTag(path, "tag1"));
            assertTrue("Tag2 is not copied", containsTag(path, "tag2"));
            assertTrue("Tag3 is not copied", containsTag(path, "tag3"));

            float rating = registry.getAverageRating(path);
            assertEquals("Rating is not mathching", rating, (float) 4.0, (float) 0.01);
//            assertEquals("Authour name is not exist", r1.getAuthorUserName(), r2.getAuthorUserName());

            String new_path_returned;
            new_path_returned = registry.rename(path, new_path);

            assertEquals("New resource path is not equal", new_path, new_path_returned);

            /*get renamed resource details*/

            Resource r1Renamed = registry.get(new_path);

            assertEquals("Properties are not equal", r2.getProperty("key1"),
                    r1Renamed.getProperty("key1"));
            assertEquals("Properties are not equal", r2.getProperty("key2"),
                    r1Renamed.getProperty("key2"));
            assertTrue(c1.getText() + " is not associated for resource" + new_path,
                    containsComment(commentPathNew, c1.getText()));
            assertTrue(c2.getText() + " is not associated for resource" + new_path,
                    containsComment(commentPathNew, c2.getText()));
            assertTrue("Tag1 is not copied", containsTag(new_path, "tag1"));
            assertTrue("Tag2 is not copied", containsTag(new_path, "tag2"));
            assertTrue("Tag3 is not copied", containsTag(new_path, "tag3"));

            float rating1 = registry.getAverageRating(new_path);
View Full Code Here

        r1.setContent(r1content);
        registry.put(path, r1);

        String comment1 = "this is qa comment 4";
        String comment2 = "this is qa comment 5";
        Comment c1 = new Comment();
        c1.setResourcePath(path);
        c1.setText("This is default comment");
        c1.setUser("admin1");

        registry.addComment(path, c1);
        registry.addComment(path, new Comment(comment1));
        registry.addComment(path, new Comment(comment2));

        Comment[] comments = registry.getComments(path);

        boolean commentFound = false;
View Full Code Here

        r1.setContent(r1content);
        registry.put("/d1/r3", r1);

        String comment1 = "this is qa comment 4";
        String comment2 = "this is qa comment 5";
        Comment c1 = new Comment();
        c1.setResourcePath("/d1/r3");
        c1.setText("This is default comment");
        c1.setUser("admin");

        registry.addComment("/d1/r3", c1);
        registry.addComment("/d1/r3", new Comment(comment1));
        registry.addComment("/d1/r3", new Comment(comment2));

        Comment[] comments = registry.getComments("/d1/r3");

        boolean commentFound = false;
View Full Code Here

        registry.put("/d11/d12", r1);

        String comment1 = "this is qa comment 1 for collection d12";
        String comment2 = "this is qa comment 2 for collection d12";

        Comment c1 = new Comment();
        c1.setResourcePath("/d11/d12");
        c1.setText("This is default comment for d12");
        c1.setUser("admin");

        try {
            registry.addComment("/d11/d12", c1);
            registry.addComment("/d11/d12", new Comment(comment1));
            registry.addComment("/d11/d12", new Comment(comment2));
        } catch (RegistryException e) {
            fail("Valid commenting for resources scenario failed");
        }

        Comment[] comments = null;

        try {

            comments = registry.getComments("/d11/d12");
        } catch (RegistryException e) {
            fail("Failed to get comments for the resource /d11/d12");
        }

        boolean commentFound = false;

        for (Comment comment : comments) {
            if (comment.getText().equals(comment1)) {
                commentFound = true;

//       //System.out.println(comment.getText());
//       //System.out.println(comment.getResourcePath());
//       //System.out.println(comment.getUser());
//       //System.out.println(comment.getTime());
                //break;
            }

            if (comment.getText().equals(comment2)) {
                commentFound = true;
//                //System.out.println(comment.getText());
//                //System.out.println(comment.getResourcePath());
//                //System.out.println(comment.getUser());
//                //System.out.println(comment.getTime());
                //break;
            }

            if (comment.getText().equals(c1.getText())) {
                commentFound = true;
//                //System.out.println(comment.getText());
//                //System.out.println(comment.getResourcePath());
//                //System.out.println(comment.getUser());
//                //System.out.println(comment.getTime());
View Full Code Here

        String comment1 = "this is qa comment 1 for root";
        String comment2 = "this is qa comment 2 for root";


        Comment c1 = new Comment();
        c1.setResourcePath("/");
        c1.setText("This is default comment for root");
        c1.setUser("admin");

        try {
            registry.addComment("/", c1);
            registry.addComment("/", new Comment(comment1));
            registry.addComment("/", new Comment(comment2));
        } catch (RegistryException e) {
            fail("Valid commenting for resources scenario failed");
        }

        Comment[] comments = null;

        try {

            comments = registry.getComments("/");
        } catch (RegistryException e) {
            fail("Failed to get comments for the resource /");
        }

        boolean commentFound = false;

        for (Comment comment : comments) {
            if (comment.getText().equals(comment1)) {
                commentFound = true;

//                //System.out.println(comment.getText());
//                //System.out.println(comment.getResourcePath());
//                //System.out.println(comment.getUser());
//                //System.out.println(comment.getTime());
//                //System.out.println("\n");
                //break;
            }

            if (comment.getText().equals(comment2)) {
                commentFound = true;
//                //System.out.println(comment.getText());
//                //System.out.println(comment.getResourcePath());
//                //System.out.println(comment.getUser());
//                //System.out.println(comment.getTime());
//                //System.out.println("\n");
                //break;
            }

            if (comment.getText().equals(c1.getText())) {
                commentFound = true;
//                //System.out.println(comment.getText());
//                //System.out.println(comment.getResourcePath());
//                //System.out.println(comment.getUser());
//                //System.out.println(comment.getTime());
View Full Code Here

TOP

Related Classes of org.wso2.carbon.registry.core.Comment

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.