Package org.drools.guvnor.server.jaxrs.jaxb

Examples of org.drools.guvnor.server.jaxrs.jaxb.Category


    public static final QName STATE = new QName(NS, "state");
    public static final QName FORMAT = new QName(NS, "format");
    public static final QName CATEGORIES = new QName(NS, "categories");

    public static Category toCategory(CategoryItem categoryItem, UriInfo uriInfo) {
        Category category = new Category();
        category.setPath(categoryItem.getFullPath());
        category.setRefLink(uriInfo.getBaseUriBuilder()
                .path("/categories/{categoryPath}")
                .build(categoryItem.getFullPath()));
        // TODO https://issues.jboss.org/browse/GUVNOR-1802
//        category.setRefLink(uriInfo.getBaseUriBuilder()
//                .path("categories").segment(categoryItem.getFullPath())
View Full Code Here


        return ret.toString();
    }   

    protected Package createTestPackage(String title) {
        Category c = new Category();
        c.setName("test");

        Package p = new Package();
        PackageMetadata metadata = new PackageMetadata();
        metadata.setCreated(new Date(System.currentTimeMillis()));
        metadata.setUuid(UUID.randomUUID().toString());
View Full Code Here

    public static final QName CATEGORIES = new QName(NS, "categories");
    public static final QName VERSION_NUMBER = new QName(NS, "versionNumber");
    public static final QName CHECKIN_COMMENT = new QName(NS, "checkinComment");

    public static Category toCategory(CategoryItem categoryItem, UriInfo uriInfo) {
        Category category = new Category();
        category.setPath(categoryItem.getFullPath());
        category.setRefLink(uriInfo.getBaseUriBuilder()
                .path("/categories/{categoryPath}")
                .build(categoryItem.getFullPath()));
        // TODO https://issues.jboss.org/browse/GUVNOR-1802
//        category.setRefLink(uriInfo.getBaseUriBuilder()
//                .path("categories").segment(categoryItem.getFullPath())
View Full Code Here

    public static final QName STATE = new QName(NS, "state");
    public static final QName FORMAT = new QName(NS, "format");
    public static final QName CATEGORIES = new QName(NS, "categories");

    public static Category toCategory(CategoryItem categoryItem, UriInfo uriInfo) {
        Category category = new Category();
        category.setPath(categoryItem.getFullPath());
        category.setRefLink(uriInfo.getBaseUriBuilder()
                .path("/categories/{categoryPath}")
                .build(categoryItem.getFullPath()));
        return category;
    }
View Full Code Here

        Map<String, Category> categories = fromXMLToCategoriesMap( outputStream.toString( "UTF-8" ) );

        assertEquals( 1,
                      categories.size() );

        Category category = categories.values().iterator().next();
        assertEquals( "Category 1",
                      category.getPath() );

        //get 'Category 1/Category 1.1/Category 1.1.1'
        client = new AbderaClient( abdera );
        client.addCredentials( baseURL.toExternalForm(),
                               null,
                               null,
                               new org.apache.commons.httpclient.UsernamePasswordCredentials( "admin",
                                                                                              "admin" ) );

        // resp = client.get(new URL(baseURL, "rest/categories/Category%201%2FCategory%201.1%2FCategory%201.1.1").toExternalForm());
        resp = client.get( new URL( baseURL,
                                    "rest/categories/Category%201/Category%201.1/Category%201.1.1" ).toExternalForm() );

        assertEquals( ResponseType.SUCCESS,
                      resp.getType() );
        assertEquals( MediaType.APPLICATION_XML,
                      resp.getContentType().toString() );

        document = resp.getDocument();

        outputStream = new ByteArrayOutputStream();
        document.writeTo( outputStream );
        outputStream.close();

        categories = fromXMLToCategoriesMap( outputStream.toString( "UTF-8" ) );

        assertEquals( 1,
                      categories.size() );
        category = categories.values().iterator().next();

        assertEquals( "Category 1/Category 1.1/Category 1.1.1",
                      category.getPath() );
    }
View Full Code Here

            //convert all catergories and add them to the list
            NodeList categoriesList = doc.getElementsByTagName( "category" );
            for ( int i = 0; i < categoriesList.getLength(); i++ ) {
                Element element = (Element) categoriesList.item( i );
                Category category = new Category();

                NodeList pathNodes = element.getElementsByTagName( "path" );
                if ( pathNodes.getLength() != 1 ) {
                    throw new IllegalStateException( "Malformed category. Expected 1 <path> tag, but found " + pathNodes.getLength() );
                }
                Node pathNode = pathNodes.item( 0 );
                category.setPath( pathNode.getTextContent() );

                NodeList refLinkNodes = element.getElementsByTagName( "refLink" );
                if ( refLinkNodes.getLength() != 1 ) {
                    throw new IllegalStateException( "Malformed category. Expected 1 <refLink> tag, but found " + refLinkNodes.getLength() );
                }
                Node refLinkNode = refLinkNodes.item( 0 );
                try {
                    category.setRefLink( new URI( refLinkNode.getTextContent() ) );
                } catch ( URISyntaxException e ) {
                    throw new RuntimeException( "Error parsing categories xml",
                                                e );
                }

                categories.put( category.getPath(),
                                category );
            }

            return categories;
        } catch ( SAXException ex ) {
View Full Code Here

        Map<String, Category> categories = fromXMLToCategoriesMap( outputStream.toString( "UTF-8" ) );

        assertEquals( 1,
                      categories.size() );

        Category category = categories.values().iterator().next();
        assertEquals( "Category 1",
                      category.getPath() );

        //get 'Category 1/Category 1.1/Category 1.1.1'
        client = new AbderaClient( abdera );
        client.addCredentials( baseURL.toExternalForm(),
                               null,
                               null,
                               new org.apache.commons.httpclient.UsernamePasswordCredentials( "admin",
                                                                                              "admin" ) );

        // resp = client.get(new URL(baseURL, "rest/categories/Category%201%2FCategory%201.1%2FCategory%201.1.1").toExternalForm());
        resp = client.get( new URL( baseURL,
                                    "rest/categories/Category%201/Category%201.1/Category%201.1.1" ).toExternalForm() );

        assertEquals( ResponseType.SUCCESS,
                      resp.getType() );
        assertEquals( MediaType.APPLICATION_XML,
                      resp.getContentType().toString() );

        document = resp.getDocument();

        outputStream = new ByteArrayOutputStream();
        document.writeTo( outputStream );
        outputStream.close();

        categories = fromXMLToCategoriesMap( outputStream.toString( "UTF-8" ) );

        assertEquals( 1,
                      categories.size() );
        category = categories.values().iterator().next();

        assertEquals( "Category 1/Category 1.1/Category 1.1.1",
                      category.getPath() );
    }
View Full Code Here

            //convert all catergories and add them to the list
            NodeList categoriesList = doc.getElementsByTagName( "category" );
            for ( int i = 0; i < categoriesList.getLength(); i++ ) {
                Element element = (Element) categoriesList.item( i );
                Category category = new Category();

                NodeList pathNodes = element.getElementsByTagName( "path" );
                if ( pathNodes.getLength() != 1 ) {
                    throw new IllegalStateException( "Malformed category. Expected 1 <path> tag, but found " + pathNodes.getLength() );
                }
                Node pathNode = pathNodes.item( 0 );
                category.setPath( pathNode.getTextContent() );

                NodeList refLinkNodes = element.getElementsByTagName( "refLink" );
                if ( refLinkNodes.getLength() != 1 ) {
                    throw new IllegalStateException( "Malformed category. Expected 1 <refLink> tag, but found " + refLinkNodes.getLength() );
                }
                Node refLinkNode = refLinkNodes.item( 0 );
                try {
                    category.setRefLink( new URI( refLinkNode.getTextContent() ) );
                } catch ( URISyntaxException e ) {
                    throw new RuntimeException( "Error parsing categories xml",
                                                e );
                }

                categories.put( category.getPath(),
                                category );
            }

            return categories;
        } catch ( SAXException ex ) {
View Full Code Here

        return ret.toString();
    }   

    protected Package createTestPackage(String title) {
        Category c = new Category();
        c.setName("test");

        Package p = new Package();
        PackageMetadata metadata = new PackageMetadata();
        metadata.setCreated(new Date(System.currentTimeMillis()));
        metadata.setUuid(UUID.randomUUID().toString());
View Full Code Here

    public static final QName STATE = new QName(NS, "state");
    public static final QName FORMAT = new QName(NS, "format");
    public static final QName CATEGORIES = new QName(NS, "categories");

    public static Category toCategory(CategoryItem categoryItem, UriInfo uriInfo) {
        Category category = new Category();
        category.setPath(categoryItem.getFullPath());
        category.setRefLink(uriInfo.getBaseUriBuilder()
                .path("/categories/{categoryPath}")
                .build(categoryItem.getFullPath()));
        return category;
    }
View Full Code Here

TOP

Related Classes of org.drools.guvnor.server.jaxrs.jaxb.Category

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.