/** * This will check out the node prior to editing. */ public void checkout() { checkout(this.node); }
/** * get this version number (default is incrementing integer, but you * can provide an implementation of VersionNumberGenerator if needed). */ public long getVersionNumber() { // try { // if ( getVersionContentNode().hasProperty( VERSION_NUMBER_PROPERTY_NAME ) ) { // return getVersionContentNode().getProperty( VERSION_NUMBER_PROPERTY_NAME ).getString(); // } else { // return null; // } // } catch ( RepositoryException e ) { // throw new RulesRepositoryException( e ); // } return getLongProperty( VERSION_NUMBER_PROPERTY_NAME ); }
/** * Return the name of the module. */ public String getName() { return super.getName(); }
public boolean hasNext() { if(this.currentVersionableItem == null) { return false; } if(this.iterationType == ITERATION_TYPE_SUCCESSOR) { return (this.currentVersionableItem.getSucceedingVersion() != null); } else if(this.iterationType == ITERATION_TYPE_PREDECESSOR) { return (this.currentVersionableItem.getPrecedingVersion() != null); } else { //shouldn't reach this block log.error("Reached unexpected path of execution because iterationType is set to: " + this.iterationType); return false; } }
/** * This will save the content (if it hasn't been already) and * then check it in to create a new version. * It will also set the last modified property. */ public void checkin(String comment) { checkIsUpdateable(); checkInAssetIfNecessary(false); try { this.node.setProperty( LAST_MODIFIED_PROPERTY_NAME, Calendar.getInstance() ); this.node.setProperty( CHECKIN_COMMENT, comment ); this.node.setProperty( LAST_CONTRIBUTOR_PROPERTY_NAME, this.node.getSession().getUserID() ); long nextVersion = getVersionNumber() + 1; this.node.setProperty( VERSION_NUMBER_PROPERTY_NAME, nextVersion ); this.node.getSession().save(); getVersionManager(this.node).checkin(this.node.getPath()); if (StorageEventManager.hasSaveEvent()) { if (this instanceof AssetItem) { StorageEventManager.getSaveEvent().onAssetCheckin((AssetItem) this); } } StorageEventManager.doCheckinEvents(this); } catch ( RepositoryException e ) { throw new RulesRepositoryException( "Unable to checkin.", e ); } }
/** * optionally update last updated... */ public void updateStringProperty(String value, String prop, boolean setLastUpdated) { try { checkIsUpdateable(); if (value == null) { return; } this.checkout(); node.setProperty( prop, value ); if (setLastUpdated) { Calendar lastModified = Calendar.getInstance(); this.node.setProperty( LAST_MODIFIED_PROPERTY_NAME, lastModified ); } } catch ( Exception e ) { if ( e instanceof RuntimeException ) { throw (RuntimeException) e; } throw new RulesRepositoryException( e ); } }
public AssetHistoryIterator(RulesRepository rulesRepository, Node head) { this.head = head; this.rulesRepository = rulesRepository; try { this.versionIterator = VersionableItem.getVersionManager(head).getVersionHistory(head.getPath()).getAllVersions(); } catch ( RepositoryException 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"); } } }
/** * Sets this object's rule node's state property to refer to the specified state node * * @param stateName the name of the state to set the rule node to * @throws RulesRepositoryException */ public void updateState(String stateName) throws RulesRepositoryException { try { //now set the state property of the rule checkout(); StateItem stateItem = this.rulesRepository.getState( stateName ); this.updateState( stateItem ); } catch ( Exception e ) { log.error( "Caught exception", e ); throw new RulesRepositoryException( e ); } }
/** * This will return the current state item as a displayable thing. * If there is no state, it will be an empty string. */ public String getStateDescription() { StateItem state = this.getState(); if ( state == null ) { return ""; } else { return state.getName(); } }
/** * When retrieving content, if we are dealing with a version in the history, * we need to get the actual content node to retrieve values. */ public Node getVersionContentNode() throws RepositoryException, PathNotFoundException { if ( this.contentNode == null ) { this.contentNode = getRealContentFromVersion(this.node); } return contentNode; }
/** * This will save the content (if it hasn't been already) and * then check it in to create a new version. * It will also set the last modified property. */ public void checkin(String comment) { checkIsUpdateable(); checkInAssetIfNecessary(false); try { this.node.setProperty( LAST_MODIFIED_PROPERTY_NAME, Calendar.getInstance() ); this.node.setProperty( CHECKIN_COMMENT, comment ); this.node.setProperty( LAST_CONTRIBUTOR_PROPERTY_NAME, this.node.getSession().getUserID() ); long nextVersion = getVersionNumber() + 1; this.node.setProperty( VERSION_NUMBER_PROPERTY_NAME, nextVersion ); this.node.getSession().save(); getVersionManager(this.node).checkin(this.node.getPath()); if (StorageEventManager.hasSaveEvent()) { if (this instanceof AssetItem) { StorageEventManager.getSaveEvent().onAssetCheckin((AssetItem) this); } } StorageEventManager.doCheckinEvents(this); } catch ( RepositoryException e ) { throw new RulesRepositoryException( "Unable to checkin.", e ); } }
/** * optionally update last updated... */ public void updateStringProperty(String value, String prop, boolean setLastUpdated) { try { checkIsUpdateable(); if (value == null) { return; } this.checkout(); node.setProperty( prop, value ); if (setLastUpdated) { Calendar lastModified = Calendar.getInstance(); this.node.setProperty( LAST_MODIFIED_PROPERTY_NAME, lastModified ); } } catch ( Exception e ) { if ( e instanceof RuntimeException ) { throw (RuntimeException) e; } throw new RulesRepositoryException( e ); } }
public ModuleHistoryIterator(RulesRepository rulesRepository, Node head) { this.head = head; this.rulesRepository = rulesRepository; try { this.versionIterator = VersionableItem.getVersionManager(head).getVersionHistory(head.getPath()).getAllVersions(); } catch ( RepositoryException e ) { throw new RulesRepositoryException( e ); } }
public boolean hasNext() { if(this.currentVersionableItem == null) { return false; } if(this.iterationType == ITERATION_TYPE_SUCCESSOR) { return (this.currentVersionableItem.getSucceedingVersion() != null); } else if(this.iterationType == ITERATION_TYPE_PREDECESSOR) { return (this.currentVersionableItem.getPrecedingVersion() != null); } else { //shouldn't reach this block log.error("Reached unexpected path of execution because iterationType is set to: " + this.iterationType); return false; } }
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"); } } }
/** * Sets this object's rule node's state property to refer to the specified state node * * @param stateName the name of the state to set the rule node to * @throws RulesRepositoryException */ public void updateState(String stateName) throws RulesRepositoryException { try { //now set the state property of the rule checkout(); StateItem stateItem = this.rulesRepository.getState( stateName ); this.updateState( stateItem ); } catch ( Exception e ) { log.error( "Caught exception", e ); throw new RulesRepositoryException( e ); } }
/** Compare this rules state with some other state */ public boolean sameState(StateItem other) { StateItem thisState = getState(); if ( thisState == other ) { return true; } else if ( thisState != null ) { return thisState.equals( other ); } else { return false; } }
/** * When retrieving content, if we are dealing with a version in the history, * we need to get the actual content node to retrieve values. */ public Node getVersionContentNode() throws RepositoryException, PathNotFoundException { if ( this.contentNode == null ) { this.contentNode = getRealContentFromVersion(this.node); } return contentNode; }
/** * Sets this object's rule node's state property to refer to the specified StateItem's node * * @param stateItem the StateItem encapsulating the node to refer to from this object's node's state * property * @throws RulesRepositoryException */ public void updateState(StateItem stateItem) throws RulesRepositoryException { checkIsUpdateable(); try { //now set the state property of the rule checkout(); this.node.setProperty( STATE_PROPERTY_NAME, stateItem.getNode() ); } catch ( Exception e ) { log.error( "Caught exception", e ); throw new RulesRepositoryException( e ); } }