public void testIgnoreArchivedItems() throws Exception { RulesRepository repo = getRepo(); PackageItem pkg = repo.createPackage("testIgnoreArchivedItems", ""); AssetItem model = pkg.addAsset("model", "qed"); model.updateFormat(AssetFormats.MODEL); model.updateBinaryContentAttachment(this.getClass().getResourceAsStream("/billasurf.jar")); model.checkin(""); ServiceImplementation.updateDroolsHeader( "import com.billasurf.Board\n global com.billasurf.Person customer", pkg); AssetItem rule1 = pkg.addAsset("rule_1", ""); rule1.updateFormat(AssetFormats.DRL); rule1.updateContent("rule 'rule1' \n when Board() \n then customer.setAge(42); \n end"); rule1.checkin(""); AssetItem rule2 = pkg.addAsset("rule2", ""); rule2.updateFormat(AssetFormats.DRL); rule2.updateContent("agenda-group 'q' \n when \n Boardx() \n then \n System.err.println(42);"); rule2.checkin(""); repo.save(); ContentPackageAssembler asm = new ContentPackageAssembler(pkg); assertTrue(asm.hasErrors()); rule2.archiveItem(true); rule2.checkin(""); assertTrue(rule2.isArchived()); asm = new ContentPackageAssembler(pkg); assertFalse(asm.hasErrors()); }
void handleArchivedForSavePackage(PackageConfigData data, PackageItem item) { for (Iterator<AssetItem> iter = item.getAssets(); iter.hasNext(); ) { AssetItem assetItem = iter.next(); if (!assetItem.isArchived()) { assetItem.archiveItem(true); assetItem.checkin(data.getDescription()); } } }
void handleUnarchivedForSavePackage( PackageConfigData data, PackageItem item, Calendar packageLastModified) { for (Iterator<AssetItem> iter = item.getAssets(); iter.hasNext(); ) { AssetItem assetItem = iter.next(); // Unarchive the assets archived after the package // ( == at the same time that the package was archived) if (assetItem.getLastModified().compareTo(packageLastModified) >= 0) { assetItem.archiveItem(false); assetItem.checkin(data.getDescription()); } } }
private void archiveOrUnarchiveAsset(String uuid, boolean archive) { try { AssetItem item = getRulesRepository().loadAssetByUUID(uuid); serviceSecurity.checkSecurityIsPackageDeveloper(item); if (item.getPackage().isArchived()) { throw new RulesRepositoryException( "The package [" + item.getPackageName() + "] that asset [" + item.getName() + "] belongs to is archived. You need to unarchive it first."); } log.info( "USER:"******" ARCHIVING asset: [" + item.getName() + "] UUID: [" + item.getUUID() + "] "); try { ContentHandler handler = getContentHandler(item); if (handler instanceof ICanHasAttachment) { ((ICanHasAttachment) handler).onAttachmentRemoved(item); } } catch (IOException e) { log.error("Unable to remove asset attachment", e); } item.archiveItem(archive); PackageItem pkg = item.getPackage(); pkg.updateBinaryUpToDate(false); RuleBaseCache.getInstance().remove(pkg.getUUID()); if (archive) { item.checkin("archived"); } else { item.checkin("unarchived"); } push("packageChange", pkg.getName()); } catch (RulesRepositoryException e) { log.error("Unable to get item format.", e); throw e; } }