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); } }
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; } }
public ValidatedResponse validatePackageConfiguration(PackageConfigData data) throws SerializationException { log.info( "USER:"******" validatePackageConfiguration package [" + data.getName() + "]"); RuleBaseCache.getInstance().remove(data.getUuid()); BRMSSuggestionCompletionLoader loader = createBRMSSuggestionCompletionLoader(); loader.getSuggestionEngine(rulesRepository.loadPackage(data.getName()), data.getHeader()); return validateBRMSSuggestionCompletionLoaderResponse(loader); }