/** * Creates a new version of this asset node, updating the expired * date for the asset node. * * @param newDateExpired * the new expired date for the rule * @throws RulesRepositoryException */ public void updateDateExpired(Calendar newDateExpired) throws RulesRepositoryException { checkout(); try { if (newDateExpired!=null || this.node.hasProperty(DATE_EXPIRED_PROPERTY_NAME)) { this.node.setProperty(DATE_EXPIRED_PROPERTY_NAME, newDateExpired); } } catch (Exception e) { log.error("Caught Exception", e); throw new RulesRepositoryException(e); } }
/** * Creates a new version of this asset node, updating the expired * date for the asset node. * * @param newDateExpired * the new expired date for the rule * @throws RulesRepositoryException */ public void updateDateExpired(Calendar newDateExpired) throws RulesRepositoryException { checkout(); try { if (newDateExpired!=null || this.node.hasProperty(DATE_EXPIRED_PROPERTY_NAME)) { this.node.setProperty(DATE_EXPIRED_PROPERTY_NAME, newDateExpired); } } catch (Exception e) { log.error("Caught Exception", e); throw new RulesRepositoryException(e); } }
/** * Creates a new version of this asset node, updating the effective * date for the asset node. * * @param newDateEffective * the new effective date for the rule * @throws RulesRepositoryException */ public void updateDateEffective(Calendar newDateEffective) throws RulesRepositoryException { checkIsUpdateable(); checkout(); try { if (newDateEffective!=null || this.node.hasProperty(DATE_EFFECTIVE_PROPERTY_NAME)) { this.node.setProperty(DATE_EFFECTIVE_PROPERTY_NAME, newDateEffective); } } catch (RepositoryException e) { log.error("Caught Exception", e); throw new RulesRepositoryException(e); } }
/** * Creates a new version of this asset node, updating the effective * date for the asset node. * * @param newDateEffective * the new effective date for the rule * @throws RulesRepositoryException */ public void updateDateEffective(Calendar newDateEffective) throws RulesRepositoryException { checkIsUpdateable(); checkout(); try { if (newDateEffective!=null || this.node.hasProperty(DATE_EFFECTIVE_PROPERTY_NAME)) { this.node.setProperty(DATE_EFFECTIVE_PROPERTY_NAME, newDateEffective); } } catch (RepositoryException e) { log.error("Caught Exception", e); throw new RulesRepositoryException(e); } }
/** * Creates a new version of this asset node, updating the disable * value for the asset node. * * @param disabled * is this asset disabled * @throws RulesRepositoryException */ public void updateDisabled(boolean disabled) throws RulesRepositoryException { checkIsUpdateable(); checkout(); try { this.node.setProperty( DISABLED_PROPERTY_NAME, disabled ); } catch ( RepositoryException e ) { log.error( "Caught Exception", e ); throw new RulesRepositoryException( e ); } }
/** * Creates a new version of this asset node, updating the disable * value for the asset node. * * @param disabled * is this asset disabled * @throws RulesRepositoryException */ public void updateDisabled(boolean disabled) throws RulesRepositoryException { checkIsUpdateable(); checkout(); try { this.node.setProperty( DISABLED_PROPERTY_NAME, disabled ); } catch ( RepositoryException e ) { log.error( "Caught Exception", e ); throw new RulesRepositoryException( e ); } }
/** * If the asset is a binary asset, then use this to update the content (do * NOT use text). */ public AssetItem updateBinaryContentAttachment(InputStream data) { checkout(); try { Binary is = this.node.getSession().getValueFactory().createBinary( data ); this.node.setProperty( CONTENT_PROPERTY_BINARY_NAME, is ); return this; } catch ( RepositoryException e ) { log.error( "Unable to update the assets binary content", e ); throw new RulesRepositoryException( e ); } }
/** * If the asset is a binary asset, then use this to update the content (do * NOT use text). */ public AssetItem updateBinaryContentAttachment(InputStream data) { checkout(); try { Binary is = this.node.getSession().getValueFactory().createBinary( data ); this.node.setProperty( CONTENT_PROPERTY_BINARY_NAME, is ); return this; } catch ( RepositoryException e ) { log.error( "Unable to update the assets binary content", e ); throw new RulesRepositoryException( e ); } }
private void checkInAssetIfNecessary(boolean force) { if(!(this instanceof ModuleItem)) { return; } Iterator<AssetItem> assets = ((ModuleItem)this).getAssets(); while(assets.hasNext()) { AssetItem asset = assets.next(); if(force || !assetHasHistory(asset)) { asset.checkout(); asset.checkin("Package[" + this.getTitle() + "] checked in"); } } }
/** * This will update the asset's content (checking it out if it is not * already). This will not save the session or create a new version of the * node (this has to be done seperately, as several properties may change as * part of one edit). This is only used if the asset is a textual asset. For * binary, use the updateBinaryContent method instead. */ public AssetItem updateContent(String newRuleContent) throws RulesRepositoryException { checkout(); try { if ( this.isBinary() ) { this.updateBinaryContentAttachment( new ByteArrayInputStream( newRuleContent.getBytes() ) ); } this.node.setProperty( CONTENT_PROPERTY_NAME, newRuleContent ); return this; } catch ( RepositoryException e ) { log.error( "Unable to update the asset content", e ); throw new RulesRepositoryException( e ); } }
/** * This will update the asset's content (checking it out if it is not * already). This will not save the session or create a new version of the * node (this has to be done seperately, as several properties may change as * part of one edit). This is only used if the asset is a textual asset. For * binary, use the updateBinaryContent method instead. */ public AssetItem updateContent(String newRuleContent) throws RulesRepositoryException { checkout(); try { if ( this.isBinary() ) { this.updateBinaryContentAttachment( new ByteArrayInputStream( newRuleContent.getBytes() ) ); } this.node.setProperty( CONTENT_PROPERTY_NAME, newRuleContent ); return this; } catch ( RepositoryException e ) { log.error( "Unable to update the asset content", e ); throw new RulesRepositoryException( e ); } }
private void checkInAssetIfNecessary(boolean force) { if(!(this instanceof ModuleItem)) { return; } Iterator<AssetItem> assets = ((ModuleItem)this).getAssets(); while(assets.hasNext()) { AssetItem asset = assets.next(); if(force || !assetHasHistory(asset)) { asset.checkout(); asset.checkin("Package[" + this.getTitle() + "] checked in"); } } }
/** * This moves an asset from one module to another, preserving history * etc etc. * * @param newModule The destination module. * @param uuid The UUID of the asset * @param explanation The reason (which will be added as the checkin message). */ public void moveRuleItemModule(String newModule, String uuid, String explanation) { try { AssetItem item = loadAssetByUUID(uuid); String sourcePath = item.node.getPath(); String destPath = loadModule(newModule).node.getPath() + "/" + ModuleItem.ASSET_FOLDER_NAME + "/" + item.getName(); this.session.move(sourcePath, destPath); this.session.save(); item.checkout(); item.node.setProperty(AssetItem.MODULE_NAME_PROPERTY, newModule); item.checkin(explanation); } catch (RepositoryException e) { throw new RulesRepositoryException(e); } }
/** * This moves an asset from one module to another, preserving history * etc etc. * * @param newModule The destination module. * @param uuid The UUID of the asset * @param explanation The reason (which will be added as the checkin message). */ public void moveRuleItemModule(String newModule, String uuid, String explanation) { try { AssetItem item = loadAssetByUUID(uuid); String sourcePath = item.node.getPath(); String destPath = loadModule(newModule).node.getPath() + "/" + ModuleItem.ASSET_FOLDER_NAME + "/" + item.getName(); this.session.move(sourcePath, destPath); this.session.save(); item.checkout(); item.node.setProperty(AssetItem.MODULE_NAME_PROPERTY, newModule); item.checkin(explanation); } catch (RepositoryException e) { throw new RulesRepositoryException(e); } }
public static void ensureMixinType(AssetItem assetItem, String mixin) throws RepositoryException { if (!assetItem.getNode().isNodeType(mixin)) { assetItem.checkout(); assetItem.getNode().addMixin(mixin); assetItem.checkin("add " + mixin); } }
public static void ensureMixinType(AssetItem assetItem, String mixin) throws RepositoryException { if (!assetItem.getNode().isNodeType(mixin)) { assetItem.checkout(); assetItem.getNode().addMixin(mixin); assetItem.checkin("add " + mixin); } }
/** * This will restore the historical version, save, and check it in as a new * version with the given comment. * * @param versionToRestore * @param headVersion * @param comment */ public void restoreHistoricalAsset(AssetItem versionToRestore, AssetItem headVersion, String comment) { headVersion.checkout(); if (versionToRestore.isBinary()) { headVersion.updateBinaryContentAttachment(versionToRestore.getBinaryContentAttachment()); } else { headVersion.updateContent(versionToRestore.getContent()); } headVersion.checkin(comment); }
/** * This will restore the historical version, save, and check it in as a new * version with the given comment. * * @param versionToRestore * @param headVersion * @param comment */ public void restoreHistoricalAsset(AssetItem versionToRestore, AssetItem headVersion, String comment) { headVersion.checkout(); if (versionToRestore.isBinary()) { headVersion.updateBinaryContentAttachment(versionToRestore.getBinaryContentAttachment()); } else { headVersion.updateContent(versionToRestore.getContent()); } headVersion.checkin(comment); }