Package org.drools.repository

Examples of org.drools.repository.ModuleItem.loadAsset()


                                                                      "/packages/testSetDavContent/Something.drl" ) );
            assertEquals( EXPECTED_CONTENT1,
                          result );

            ModuleItem pkg = rulesRepository.loadModule( "testSetDavContent" );
            AssetItem asset = pkg.loadAsset( "Something" );
            assertEquals( "drl",
                          asset.getFormat() );
            assertEquals(EXPECTED_CONTENT1,
                    asset.getContent());
            assertEquals( EXPECTED_CONTENT1,
View Full Code Here


                    builder.writePDF(out);

                } else if (helper.isPng()) {
                    ModuleItem pkg = rulesRepository.loadModule(helper.getPackageName());
                    AssetItem asset = pkg.loadAsset(helper.getAssetName());

                    fileName = fileManagerService.loadFileAttachmentByUUID(asset.getUUID(),
                            out);
                } else {
                    if (req.getRequestURI().endsWith("SCENARIOS")) {
View Full Code Here

                        int lastIndexOfSlash = uri.lastIndexOf('/');
                        String assetName = uri.substring(lastIndexOfSlash + 1);
                        fileName = assetName + ".xml";

                        ModuleItem pkg = rulesRepository.loadModule(helper.getPackageName());
                        AssetItem asset = pkg.loadAsset(assetName);
                        out.write(asset.getBinaryContentAsBytes());

                    } else {
                        fileName = fileManagerService.loadBinaryPackage(helper.getPackageName(),
                                helper.getVersion(),
View Full Code Here

            } else {
                //new asset
                ModuleItem pkg = repo.loadModule(bits[1]);
                AssetItem asset;
                if (pkg.containsAsset(a[0])) {
                    asset = pkg.loadAsset(a[0]);
                    if (asset.isArchived()) {
                        asset.archiveItem(false);
                    } else {
                        throw new RulesRepositoryException("The file " + path + " already exists, and was not archived.");
                    }
View Full Code Here

                }
                pkg.updateStringProperty(readContent(in), ModuleItem.HEADER_PROPERTY_NAME);
                pkg.checkin(comment);
                repo.save();
            } else {
                AssetItem as = pkg.loadAsset(a[0]);
                if (lastModified != null && as.getLastModified().after(lastModified)) {
                    throw new RulesRepositoryException("The asset was modified by: " + as.getLastContributor() + ", unable to write changes.");
                }
                if (as.isBinary()) {
                    as.updateBinaryContentAttachment(in);
View Full Code Here

        } else {
            if (resourceFile.indexOf("?version=") > -1) {
                String[] v = resourceFile.split("\\?version\\=");
                String version = v[1];
                String assetName = AssetItem.getAssetNameFromFileName(v[0])[0];
                AssetItem asset = pkg.loadAsset(assetName);
                if (asset.isArchived()) {
                    Text r = new Text();
                    r.data = "";
                    return r;
                }
View Full Code Here

                    r.data = "Unknown version number : " + versionNumber;
                    return r;
                }
            } else {
                 String assetName = AssetItem.getAssetNameFromFileName(resourceFile)[0];
                AssetItem asset = pkg.loadAsset(assetName);
                return buildAssetContentResponse(pkg, asset);
            }

        }
View Full Code Here

        RestAPI api = new RestAPI(repo);
        Thread.sleep(42);
        api.put("packages/testRestPut/asset1.drl", Calendar.getInstance(), new ByteArrayInputStream("qaz".getBytes()), "a new comment");

        AssetItem asset1_ = pkg.loadAsset("asset1");
        assertEquals("qaz", asset1_.getContent());
        assertEquals("a new comment", asset1_.getCheckinComment());
        assertTrue(asset1_.getLastModified().after(cd));

        api.put("packages/testRestPut/asset2.xls", Calendar.getInstance(), new ByteArrayInputStream("def".getBytes()), "a new comment");
View Full Code Here

        assertEquals("qaz", asset1_.getContent());
        assertEquals("a new comment", asset1_.getCheckinComment());
        assertTrue(asset1_.getLastModified().after(cd));

        api.put("packages/testRestPut/asset2.xls", Calendar.getInstance(), new ByteArrayInputStream("def".getBytes()), "a new comment");
        AssetItem asset2_ = pkg.loadAsset("asset2");
        assertEquals("def", new String(asset2_.getBinaryContentAsBytes()));
        assertEquals("a new comment", asset2_.getCheckinComment());
        assertTrue(asset2_.getLastModified().after(cd));

        //now check updating the package header
View Full Code Here

        assertEquals(1, l.size());


        //now test it back from the dead
        api.post("packages/testRestDelete/asset1.drl", new ByteArrayInputStream("123".getBytes()), "new comment");
        AssetItem ass = pkg.loadAsset("asset1");
        assertEquals("123", ass.getContent());
        assertEquals("new comment", ass.getCheckinComment());
        assertFalse(ass.isArchived());
        l = RulesRepositoryTest.iteratorToList(pkg.listAssetsByFormat(new String[] {"drl"}));
        assertEquals(1, l.size());
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.