Package org.drools.guvnor.server.builder

Examples of org.drools.guvnor.server.builder.PackageDRLAssembler


    @Path("{packageName}/source")
    @Produces(MediaType.TEXT_PLAIN)
    public Response getPackageSource(@PathParam("packageName") String packageName) {
        try {
            PackageItem packageItem = repository.loadPackage(packageName);
            PackageDRLAssembler asm = new PackageDRLAssembler(packageItem);
            String drl = asm.getDRL();
            return Response.ok(drl).header("Content-Disposition", "attachment; filename=" + packageName).build();
        } catch (Exception e) {
            //catch RulesRepositoryException and other exceptions. For example when the package does not exists.
            throw new WebApplicationException(e);
        }
View Full Code Here


    @Path("{packageName}/versions/{versionNumber}/source")
    @Produces(MediaType.TEXT_PLAIN)
    public Response getHistoricalPackageSource(@PathParam("packageName") String packageName,
                                               @PathParam("versionNumber") long versionNumber) {
        PackageItem item = repository.loadPackage(packageName, versionNumber);
        PackageDRLAssembler asm = new PackageDRLAssembler(item);
        String drl = asm.getDRL();
        return Response.ok(drl).header("Content-Disposition", "attachment; filename=" + packageName).build();
    }
View Full Code Here

    }

    protected String buildPackageSource(String packageUUID) throws SerializationException {

        PackageItem item = getRulesRepository().loadPackageByUUID( packageUUID );
        PackageDRLAssembler asm = new PackageDRLAssembler( item );
        return asm.getDRL();
    }
View Full Code Here

    protected String[] listRulesInPackage(String packageName) throws SerializationException {
        // load package
        PackageItem item = getRulesRepository().loadPackage( packageName );

        PackageDRLAssembler assembler = createPackageDRLAssembler( item );

        List<String> result = new ArrayList<String>();
        try {

            String drl = assembler.getDRL();
            if ( drl == null || "".equals( drl ) ) {
                return new String[0];
            } else {
                parseRulesToPackageList( assembler,
                        result );
View Full Code Here

        }
        return (String[]) retList.toArray( new String[]{} );
    }

    PackageDRLAssembler createPackageDRLAssembler(final PackageItem packageItem) {
        return new PackageDRLAssembler( packageItem );
    }
View Full Code Here

                                    boolean isLatest,
                                    OutputStream out) throws IOException {
        PackageItem item = null;
        if ( isLatest ) {
            item = repository.loadPackage( packageName );
            PackageDRLAssembler asm = new PackageDRLAssembler( item );
            String drl = asm.getDRL();
            out.write( drl.getBytes() );
            out.flush();
            return packageName + ".drl";
        } else {
            item = repository.loadPackageSnapshot( packageName,
                                                   packageVersion );
            PackageDRLAssembler asm = new PackageDRLAssembler( item );
            String drl = asm.getDRL();
            out.write( drl.getBytes() );
            out.flush();
            return packageName + "_" + URLEncoder.encode( packageVersion,
                                                          "UTF-8" ) + ".drl";
        }
View Full Code Here

                                                      SerializationException {
        RepositoryPackageOperations localRepositoryPackageOperations = initSpyingOnRealRepositoryPackageOperations();
        final String packageName = "packageName";
        PackageItem packageItem = mock( PackageItem.class );
        when( this.rulesRepository.loadPackage( packageName ) ).thenReturn( packageItem );
        PackageDRLAssembler contentPackageAssembler = mock( PackageDRLAssembler.class );
        doReturn( contentPackageAssembler ).when( localRepositoryPackageOperations ).createPackageDRLAssembler(packageItem);
        //doNothing().when( localRepositoryPackageOperations ).parseRulesToPackageList( contentPackageAssembler, new ArrayList<String>() );
        when( contentPackageAssembler.getDRL() ).thenReturn( null );
        assertArrayEquals( localRepositoryPackageOperations.listRulesInPackage( packageName ),
                           new String[]{} );
        verify( localRepositoryPackageOperations,
                never() ).parseRulesToPackageList( Mockito.any( PackageDRLAssembler.class ),
                                                   Mockito.anyList() );
View Full Code Here

                                                           SerializationException {
        RepositoryPackageOperations localRepositoryPackageOperations = initSpyingOnRealRepositoryPackageOperations();
        final String packageName = "packageName";
        PackageItem packageItem = mock( PackageItem.class );
        when( this.rulesRepository.loadPackage( packageName ) ).thenReturn( packageItem );
        PackageDRLAssembler contentPackageAssembler = mock( PackageDRLAssembler.class );
        doReturn( contentPackageAssembler ).when( localRepositoryPackageOperations ).createPackageDRLAssembler( packageItem );
        doNothing().when( localRepositoryPackageOperations ).parseRulesToPackageList( contentPackageAssembler,
                                                                                      new ArrayList<String>() );
        when( contentPackageAssembler.getDRL() ).thenReturn( "DRL" );
        assertArrayEquals( localRepositoryPackageOperations.listRulesInPackage( packageName ),
                           new String[]{} );
        verify( localRepositoryPackageOperations ).parseRulesToPackageList( Mockito.any( PackageDRLAssembler.class ),
                                                                            Mockito.anyList() );
View Full Code Here

            throw new WebApplicationException(Response.status(Response.Status.NOT_FOUND)
                    .entity("Package [" + packageName + "] does not exist").build());
        }
        try {
            PackageItem packageItem = repository.loadPackage(packageName);
            PackageDRLAssembler asm = new PackageDRLAssembler(packageItem);
            String drl = asm.getDRL();
            return Response.ok(drl).header("Content-Disposition", "attachment; filename=" + packageName).build();
        } catch (Exception e) {
            //catch RulesRepositoryException and other exceptions. For example when the package does not exists.
            throw new WebApplicationException(e);
        }
View Full Code Here

    @Path("{packageName}/versions/{versionNumber}/source")
    @Produces(MediaType.TEXT_PLAIN)
    public Response getHistoricalPackageSource(@PathParam("packageName") String packageName,
                                               @PathParam("versionNumber") long versionNumber) {
        PackageItem item = repository.loadPackage(packageName, versionNumber);
        PackageDRLAssembler asm = new PackageDRLAssembler(item);
        String drl = asm.getDRL();
        return Response.ok(drl).header("Content-Disposition", "attachment; filename=" + packageName).build();
    }
View Full Code Here

TOP

Related Classes of org.drools.guvnor.server.builder.PackageDRLAssembler

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.