/** @deprecated in favour of {@link #loadArchivedAssets(PageRequest)} */ @WebRemote @LoggedIn public TableDataResult loadAssetHistory(String packageUUID, String assetName) throws SerializationException { ModuleItem pi = rulesRepository.loadModuleByUUID(packageUUID); AssetItem assetItem = pi.loadAsset(assetName); serviceSecurity.checkSecurityPackageReadOnlyWithPackageUuid(assetItem.getModule().getUUID()); return repositoryAssetOperations.loadItemHistory(assetItem); }
public void deleteUncheckedRule(String uuid) { AssetItem asset = rulesRepository.loadAssetByUUID(uuid); ModuleItem packageItem = asset.getModule(); packageItem.updateBinaryUpToDate(false); asset.remove(); rulesRepository.save(); push("packageChange", packageItem.getName()); }
public static Asset toAsset(AssetItem a, UriInfo uriInfo) { AssetMetadata metadata = new AssetMetadata(); metadata.setUuid(a.getUUID()); metadata.setCreated(a.getCreatedDate().getTime()); metadata.setDisabled(a.getDisabled()); metadata.setFormat(a.getFormat()); metadata.setNote("<![CDATA[ " + a.getCheckinComment() + " ]]>"); metadata.setCheckInComment(a.getCheckinComment()); metadata.setVersionNumber(a.getVersionNumber()); List<CategoryItem> categories = a.getCategories(); // TODO: Is this a bug since cat's are never assigned to metadata after this? String[] cats = new String[categories.size()]; int counter = 0; for (CategoryItem c : categories) { cats[counter++] = c.getName(); } Asset ret = new Asset(); ret.setTitle(a.getTitle()); ret.setBinaryContentAttachmentFileName(a.getBinaryContentAttachmentFileName()); ret.setPublished(a.getLastModified().getTime()); ret.setAuthor(a.getLastContributor()); ret.setMetadata(metadata); ret.setDescription(a.getDescription()); ret.setRefLink( uriInfo .getBaseUriBuilder() .path("/packages/{packageName}/assets/{assetName}") .build(a.getModule().getName(), a.getName())); ret.setBinaryLink( uriInfo .getBaseUriBuilder() .path("/packages/{packageName}/assets/{assetName}/binary") .build(a.getModule().getName(), a.getName())); ret.setSourceLink( uriInfo .getBaseUriBuilder() .path("/packages/{packageName}/assets/{assetName}/source") .build(a.getModule().getName(), a.getName())); return ret; }
private ModuleItem handlePackageItem(AssetItem item, Asset asset) throws SerializationException { ModuleItem packageItem = item.getModule(); ContentHandler handler = ContentManager.getHandler(asset.getFormat()); handler.retrieveAssetContent(asset, item); asset.setReadonly(asset.getMetaData().isHasSucceedingVersion() || asset.isArchived()); if (packageItem.isSnapshot()) { asset.setReadonly(true); } return packageItem; }
private void archiveOrUnarchiveAsset(String uuid, boolean archive) { AssetItem item = rulesRepository.loadAssetByUUID(uuid); serviceSecurity.checkIsPackageDeveloperOrAnalyst(item); if (item.getModule().isArchived()) { throw new RulesRepositoryException( "The package [" + item.getModuleName() + "] 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); ModuleItem pkg = item.getModule(); pkg.updateBinaryUpToDate(false); RuleBaseCache.getInstance().remove(pkg.getUUID()); if (archive) { item.checkin("archived"); } else { item.checkin("unarchived"); } push("packageChange", pkg.getName()); }
@WebRemote @LoggedIn public void removeAsset(String uuid) { try { AssetItem item = rulesRepository.loadAssetByUUID(uuid); serviceSecurity.checkSecurityIsPackageDeveloperWithPackageUuid(item.getModule().getUUID()); item.remove(); rulesRepository.save(); } catch (RulesRepositoryException e) { log.error("Unable to remove asset.", e); throw e; } }