public void savePackage(PackageConfigData data) throws SerializationException { log.info("USER:"******" SAVING package [" + data.getName() + "]"); PackageItem item = rulesRepository.loadPackage(data.getName()); // If package is being unarchived. boolean unarchived = (!data.isArchived() && item.isArchived()); Calendar packageLastModified = item.getLastModified(); DroolsHeader.updateDroolsHeader(data.getHeader(), item); updateCategoryRules(data, item); item.updateExternalURI(data.getExternalURI()); item.updateDescription(data.getDescription()); item.archiveItem(data.isArchived()); item.updateBinaryUpToDate(false); if (!data.getFormat().equals("")) { item.updateFormat(data.getFormat()); } RuleBaseCache.getInstance().remove(data.getUuid()); item.checkin(data.getDescription()); // If package is archived, archive all the assets under it if (data.isArchived()) { handleArchivedForSavePackage(data, item); } else if (unarchived) { handleUnarchivedForSavePackage(data, item, packageLastModified); } }
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()); } } }