[jboss-svn-commits] JBL Code SVN: r22716 - in labs/jbossrules/trunk: drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor and 2 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Fri Sep 12 07:31:28 EDT 2008
Author: Rikkola
Date: 2008-09-12 07:31:28 -0400 (Fri, 12 Sep 2008)
New Revision: 22716
Modified:
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/rpc/MetaData.java
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/MetaDataWidget.java
labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/builder/ContentPackageAssembler.java
labs/jbossrules/trunk/drools-repository/src/main/java/org/drools/repository/AssetItem.java
Log:
JBRULES-1720: Need "disable" toggle button for all assets
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/rpc/MetaData.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/rpc/MetaData.java 2008-09-12 11:26:38 UTC (rev 22715)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/rpc/MetaData.java 2008-09-12 11:31:28 UTC (rev 22716)
@@ -1,4 +1,5 @@
package org.drools.guvnor.client.rpc;
+
/*
* Copyright 2005 JBoss Inc
*
@@ -15,8 +16,6 @@
* limitations under the License.
*/
-
-
import java.util.Date;
import com.google.gwt.user.client.rpc.IsSerializable;
@@ -25,39 +24,41 @@
* This is the DTO for a versionable asset's meta data.
* ie basically everything except the payload.
*/
-public class MetaData implements IsSerializable {
+public class MetaData
+ implements
+ IsSerializable {
- public String name = "";
- public String description = "";
-
- public String title = "";
- public String status = "";
+ public String name = "";
+ public String description = "";
- public Date lastModifiedDate;
- public String lastContributor = "";
- public long versionNumber;
+ public String title = "";
+ public String status = "";
- public Date createdDate;
-
- public String packageName = "";
- public String[] categories = new String[0];
-
- public String format = "";
- public String type = "";
- public String creator = "";
- public String externalSource = "";
- public String subject = "";
- public String externalRelation = "";
- public String rights = "";
- public String coverage = "";
- public String publisher = "";
- public String checkinComment = "";
-
-
- public Date dateEffective;
- public Date dateExpired;
-
-
+ public Date lastModifiedDate;
+ public String lastContributor = "";
+ public long versionNumber;
+
+ public Date createdDate;
+
+ public String packageName = "";
+ public String[] categories = new String[0];
+
+ public String format = "";
+ public String type = "";
+ public String creator = "";
+ public String externalSource = "";
+ public String subject = "";
+ public String externalRelation = "";
+ public String rights = "";
+ public String coverage = "";
+ public String publisher = "";
+ public String checkinComment = "";
+
+ public boolean disabled = false;
+
+ public Date dateEffective;
+ public Date dateExpired;
+
/**
* Remove a category.
* @param idx The index of the cat to remove.
@@ -66,32 +67,32 @@
String[] newList = new String[categories.length - 1];
int newIdx = 0;
for ( int i = 0; i < categories.length; i++ ) {
-
- if (i != idx) {
+
+ if ( i != idx ) {
newList[newIdx] = categories[i];
newIdx++;
}
-
+
}
this.categories = newList;
}
-
+
/**
* Add the given cat to the end of the cat list.
*/
public void addCategory(String cat) {
for ( int i = 0; i < this.categories.length; i++ ) {
- if (categories[i].equals( cat )) return;
+ if ( categories[i].equals( cat ) ) return;
}
String[] list = this.categories;
String[] newList = new String[list.length + 1];
-
+
for ( int i = 0; i < list.length; i++ ) {
- newList[i] = list[i];
+ newList[i] = list[i];
}
- newList[list.length] = cat;
-
- this.categories = newList;
+ newList[list.length] = cat;
+
+ this.categories = newList;
}
}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/MetaDataWidget.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/MetaDataWidget.java 2008-09-12 11:26:38 UTC (rev 22715)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/ruleeditor/MetaDataWidget.java 2008-09-12 11:31:28 UTC (rev 22716)
@@ -1,4 +1,5 @@
package org.drools.guvnor.client.ruleeditor;
+
/*
* Copyright 2005 JBoss Inc
*
@@ -15,8 +16,6 @@
* limitations under the License.
*/
-
-
import java.util.Date;
import org.drools.guvnor.client.common.FormStylePopup;
@@ -33,6 +32,7 @@
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.ChangeListener;
+import com.google.gwt.user.client.ui.CheckBox;
import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HorizontalPanel;
@@ -48,35 +48,42 @@
*/
public class MetaDataWidget extends PrettyFormLayout {
-
- private MetaData data;
- private boolean readOnly;
- private String uuid;
- private Command refreshView;
+ private MetaData data;
+ private boolean readOnly;
+ private String uuid;
+ private Command refreshView;
AssetCategoryEditor ed;
- public MetaDataWidget(final MetaData d, boolean readOnly, String uuid, Command refreshView) {
+ public MetaDataWidget(final MetaData d,
+ boolean readOnly,
+ String uuid,
+ Command refreshView) {
- super();
-// layout = new Form(new FormConfig() {
-// {
-// setWidth(250);
-// //setHeader(d.name);
-// setLabelWidth(75);
-// setSurroundWithBox(true);
-// }
-// });
+ super();
+ // layout = new Form(new FormConfig() {
+ // {
+ // setWidth(250);
+ // //setHeader(d.name);
+ // setLabelWidth(75);
+ // setSurroundWithBox(true);
+ // }
+ // });
- if (!readOnly) {
- Image edit = new ImageButton("images/edit.gif", "Rename this asset");
+ if ( !readOnly ) {
+ Image edit = new ImageButton( "images/edit.gif",
+ "Rename this asset" );
edit.addClickListener( new ClickListener() {
public void onClick(Widget w) {
- showRenameAsset(w);
+ showRenameAsset( w );
}
- });
- addHeader( "images/meta_data.png", d.name, edit );
+ } );
+ addHeader( "images/meta_data.png",
+ d.name,
+ edit );
} else {
- addHeader( "images/asset_version.png", d.name, null );
+ addHeader( "images/asset_version.png",
+ d.name,
+ null );
}
this.uuid = uuid;
@@ -84,145 +91,181 @@
this.readOnly = readOnly;
this.refreshView = refreshView;
- loadData(d);
+ loadData( d );
+ }
-
- }
-
-
-
-
-
- private void loadData(MetaData d) {
+ private void loadData(MetaData d) {
this.data = d;
startSection();
- addAttribute("Categories:", categories());
+ addAttribute( "Categories:",
+ categories() );
endSection();
startSection();
- addAttribute("Modified on:", readOnlyDate(data.lastModifiedDate));
- addAttribute("by:", readOnlyText(data.lastContributor));
- addAttribute("Note:", readOnlyText( data.checkinComment ));
- addAttribute("Version:", getVersionNumberLabel());
+ addAttribute( "Modified on:",
+ readOnlyDate( data.lastModifiedDate ) );
+ addAttribute( "by:",
+ readOnlyText( data.lastContributor ) );
+ addAttribute( "Note:",
+ readOnlyText( data.checkinComment ) );
+ addAttribute( "Version:",
+ getVersionNumberLabel() );
- if (!readOnly) {
- addAttribute("Created on:", readOnlyDate( data.createdDate ));
+ if ( !readOnly ) {
+ addAttribute( "Created on:",
+ readOnlyDate( data.createdDate ) );
}
- addAttribute("Created by:", readOnlyText(data.creator));
- addAttribute("Format:", new HTML( "<b>" + data.format + "</b>" ));
+ addAttribute( "Created by:",
+ readOnlyText( data.creator ) );
+ addAttribute( "Format:",
+ new HTML( "<b>" + data.format + "</b>" ) );
endSection();
startSection();
- addAttribute("Package:", packageEditor(data.packageName));
- addAttribute("Subject:", editableText(new FieldBinding() {
- public String getValue() {
- return data.subject;
- }
+ addAttribute( "Package:",
+ packageEditor( data.packageName ) );
- public void setValue(String val) {
- data.subject = val;
- }
- }, "A short description of the subject matter."));
+ /******************************/
+ addAttribute( "Disabled:",
+ editableBoolean( new FieldBooleanBinding() {
+ public boolean getValue() {
+ return data.disabled;
+ }
- addAttribute("Type:", editableText(new FieldBinding() {
- public String getValue() {
- return data.type;
- }
+ public void setValue(boolean val) {
+ data.disabled = val;
+ }
+ },
+ "Disables this asset." ) );
+ /******************************/
- public void setValue(String val) {
- data.type = val;
- }
+ addAttribute( "Subject:",
+ editableText( new FieldBinding() {
+ public String getValue() {
+ return data.subject;
+ }
- }, "This is for classification purposes."));
+ public void setValue(String val) {
+ data.subject = val;
+ }
+ },
+ "A short description of the subject matter." ) );
- addAttribute("External link:", editableText(new FieldBinding() {
- public String getValue() {
- return data.externalRelation;
- }
+ addAttribute( "Type:",
+ editableText( new FieldBinding() {
+ public String getValue() {
+ return data.type;
+ }
- public void setValue(String val) {
- data.externalRelation = val;
- }
+ public void setValue(String val) {
+ data.type = val;
+ }
- }, "This is for relating the asset to an external system."));
+ },
+ "This is for classification purposes." ) );
- addAttribute("Source:", editableText(new FieldBinding() {
- public String getValue() {
- return data.externalSource;
- }
+ addAttribute( "External link:",
+ editableText( new FieldBinding() {
+ public String getValue() {
+ return data.externalRelation;
+ }
- public void setValue(String val) {
- data.externalSource = val;
- }
+ public void setValue(String val) {
+ data.externalRelation = val;
+ }
- }, "A short description or code indicating the source of the rule."));
+ },
+ "This is for relating the asset to an external system." ) );
+ addAttribute( "Source:",
+ editableText( new FieldBinding() {
+ public String getValue() {
+ return data.externalSource;
+ }
+
+ public void setValue(String val) {
+ data.externalSource = val;
+ }
+
+ },
+ "A short description or code indicating the source of the rule." ) );
+
endSection();
startSection();
- if (!readOnly) {
- addRow( new VersionBrowser(this.uuid, this.data, refreshView) );
+ if ( !readOnly ) {
+ addRow( new VersionBrowser( this.uuid,
+ this.data,
+ refreshView ) );
}
endSection();
}
-
-
- private Widget packageEditor(final String packageName) {
- if (this.readOnly || !ExplorerLayoutManager.shouldShow(Capabilities.SHOW_PACKAGE_VIEW)) {
+ private Widget packageEditor(final String packageName) {
+ if ( this.readOnly || !ExplorerLayoutManager.shouldShow( Capabilities.SHOW_PACKAGE_VIEW ) ) {
return readOnlyText( packageName );
} else {
HorizontalPanel horiz = new HorizontalPanel();
horiz.setStyleName( "metadata-Widget" );
horiz.add( readOnlyText( packageName ) );
- Image editPackage = new ImageButton("images/edit.gif");
+ Image editPackage = new ImageButton( "images/edit.gif" );
editPackage.addClickListener( new ClickListener() {
public void onClick(Widget w) {
- showEditPackage(packageName, w);
+ showEditPackage( packageName,
+ w );
}
- });
+ } );
horiz.add( editPackage );
return horiz;
}
}
private void showRenameAsset(Widget source) {
- final FormStylePopup pop = new FormStylePopup("images/package_large.png", "Rename this item");
+ final FormStylePopup pop = new FormStylePopup( "images/package_large.png",
+ "Rename this item" );
final TextBox box = new TextBox();
- pop.addAttribute( "New name", box );
- Button ok = new Button("Rename item");
- pop.addAttribute( "", ok );
+ pop.addAttribute( "New name",
+ box );
+ Button ok = new Button( "Rename item" );
+ pop.addAttribute( "",
+ ok );
ok.addClickListener( new ClickListener() {
public void onClick(Widget w) {
- RepositoryServiceFactory.getService().renameAsset( uuid, box.getText(), new GenericCallback() {
- public void onSuccess(Object data) {
- refreshView.execute();
- Window.alert( "Item has been renamed" );
- pop.hide();
- }
- });
+ RepositoryServiceFactory.getService().renameAsset( uuid,
+ box.getText(),
+ new GenericCallback() {
+ public void onSuccess(Object data) {
+ refreshView.execute();
+ Window.alert( "Item has been renamed" );
+ pop.hide();
+ }
+ } );
}
} );
pop.show();
}
-
- private void showEditPackage(final String pkg, Widget source) {
- final FormStylePopup pop = new FormStylePopup("images/package_large.png", "Move this item to another package");
- pop.addAttribute( "Current package:", new Label(pkg) );
+ private void showEditPackage(final String pkg,
+ Widget source) {
+ final FormStylePopup pop = new FormStylePopup( "images/package_large.png",
+ "Move this item to another package" );
+ pop.addAttribute( "Current package:",
+ new Label( pkg ) );
final RulePackageSelector sel = new RulePackageSelector();
- pop.addAttribute( "New package:", sel );
- Button ok = new Button("Change package");
- pop.addAttribute( "", ok );
+ pop.addAttribute( "New package:",
+ sel );
+ Button ok = new Button( "Change package" );
+ pop.addAttribute( "",
+ ok );
ok.addClickListener( new ClickListener() {
public void onClick(Widget w) {
- if (sel.getSelectedPackage().equals( pkg )) {
+ if ( sel.getSelectedPackage().equals( pkg ) ) {
Window.alert( "You need to pick a different package to move this to." );
return;
}
@@ -237,50 +280,50 @@
} );
-
}
- });
+ } );
pop.show();
}
private Widget getVersionNumberLabel() {
- if (data.versionNumber == 0 ) {
- return new HTML("<i>Not checked in yet</i>");
+ if ( data.versionNumber == 0 ) {
+ return new HTML( "<i>Not checked in yet</i>" );
} else {
- return readOnlyText(Long.toString( data.versionNumber) );
+ return readOnlyText( Long.toString( data.versionNumber ) );
}
}
private Widget readOnlyDate(Date lastModifiedDate) {
- if (lastModifiedDate == null) {
+ if ( lastModifiedDate == null ) {
return null;
} else {
- return new Label(lastModifiedDate.toLocaleString());
+ return new Label( lastModifiedDate.toLocaleString() );
}
}
private Label readOnlyText(String text) {
- Label lbl = new Label(text);
+ Label lbl = new Label( text );
lbl.setWidth( "100%" );
return lbl;
}
private Widget categories() {
- ed = new AssetCategoryEditor(this.data, this.readOnly);
+ ed = new AssetCategoryEditor( this.data,
+ this.readOnly );
return ed;
}
-
/** This binds a field, and returns a text editor for it */
- private Widget editableText(final FieldBinding bind, String toolTip) {
- if (!readOnly) {
+ private Widget editableText(final FieldBinding bind,
+ String toolTip) {
+ if ( !readOnly ) {
final TextBox box = new TextBox();
box.setTitle( toolTip );
box.setText( bind.getValue() );
- box.setVisibleLength(10);
+ box.setVisibleLength( 10 );
ChangeListener listener = new ChangeListener() {
public void onChange(Widget w) {
bind.setValue( box.getText() );
@@ -289,16 +332,55 @@
box.addChangeListener( listener );
return box;
} else {
- return new Label(bind.getValue());
+ return new Label( bind.getValue() );
}
}
+ /**
+ * This binds a field, and returns a check box editor for it.
+ *
+ * @param bind Interface to bind to.
+ * @param toolTip tool tip.
+ * @return
+ */
+ private Widget editableBoolean(final FieldBooleanBinding bind,
+ String toolTip) {
+ if ( !readOnly ) {
+ final CheckBox box = new CheckBox();
+ box.setTitle( toolTip );
+ box.setChecked( bind.getValue() );
+ ClickListener listener = new ClickListener() {
+ public void onClick(Widget w) {
+ boolean b = box.isChecked();
+ bind.setValue( b );
+ }
+ };
+ box.addClickListener( listener );
+ return box;
+ } else {
+ final CheckBox box = new CheckBox();
+
+ box.setChecked( bind.getValue() );
+ box.setEnabled( false );
+
+ return box;
+ }
+ }
+
/** used to bind fields in the meta data DTO to the form */
static interface FieldBinding {
void setValue(String val);
+
String getValue();
}
+ /** used to bind fields in the meta data DTO to the form */
+ static interface FieldBooleanBinding {
+ void setValue(boolean val);
+
+ boolean getValue();
+ }
+
/**
* Return the data if it is to be saved.
*/
@@ -306,8 +388,4 @@
return data;
}
-
-
-
-
}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/builder/ContentPackageAssembler.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/builder/ContentPackageAssembler.java 2008-09-12 11:26:38 UTC (rev 22715)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/builder/ContentPackageAssembler.java 2008-09-12 11:31:28 UTC (rev 22716)
@@ -132,7 +132,7 @@
*/
private void buildAsset(AssetItem asset) {
ContentHandler h = ContentManager.getHandler( asset.getFormat() );
- if (h instanceof IRuleAsset) {
+ if (h instanceof IRuleAsset && !asset.getDisabled()) {
try {
((IRuleAsset) h).compile( builder, asset, new ErrorLogger() );
if (builder.hasErrors()) {
Modified: labs/jbossrules/trunk/drools-repository/src/main/java/org/drools/repository/AssetItem.java
===================================================================
--- labs/jbossrules/trunk/drools-repository/src/main/java/org/drools/repository/AssetItem.java 2008-09-12 11:26:38 UTC (rev 22715)
+++ labs/jbossrules/trunk/drools-repository/src/main/java/org/drools/repository/AssetItem.java 2008-09-12 11:31:28 UTC (rev 22716)
@@ -19,30 +19,30 @@
* @author btruitt
*/
public class AssetItem extends CategorisableItem {
- private Logger log = Logger.getLogger( AssetItem.class );
+ private Logger log = Logger.getLogger( AssetItem.class );
/**
* The name of the rule node type
*/
- public static final String RULE_NODE_TYPE_NAME = "drools:assetNodeType";
+ public static final String RULE_NODE_TYPE_NAME = "drools:assetNodeType";
- public static final String CONTENT_PROPERTY_NAME = "drools:content";
- public static final String CONTENT_PROPERTY_BINARY_NAME = "drools:binaryContent";
+ public static final String CONTENT_PROPERTY_NAME = "drools:content";
+ public static final String CONTENT_PROPERTY_BINARY_NAME = "drools:binaryContent";
public static final String CONTENT_PROPERTY_ATTACHMENT_FILENAME = "drools:attachmentFileName";
/**
* The name of the date effective property on the rule node type
*/
- public static final String DATE_EFFECTIVE_PROPERTY_NAME = "drools:dateEffective";
+ public static final String DATE_EFFECTIVE_PROPERTY_NAME = "drools:dateEffective";
+ public static final String DISABLED_PROPERTY_NAME = "drools:disabled";
+
/**
* The name of the date expired property on the rule node type
*/
- public static final String DATE_EXPIRED_PROPERTY_NAME = "drools:dateExpired";
+ public static final String DATE_EXPIRED_PROPERTY_NAME = "drools:dateExpired";
- public static final String PACKAGE_NAME_PROPERTY = "drools:packageName";
+ public static final String PACKAGE_NAME_PROPERTY = "drools:packageName";
-
-
/**
* Constructs a RuleItem object, setting its node attribute to the specified node.
*
@@ -69,7 +69,8 @@
}
public AssetItem() {
- super(null, null);
+ super( null,
+ null );
}
/**
@@ -78,9 +79,9 @@
*/
public String getContent() throws RulesRepositoryException {
try {
- if (isBinary()) {
- return new String(this.getBinaryContentAsBytes());
- }
+ if ( isBinary() ) {
+ return new String( this.getBinaryContentAsBytes() );
+ }
Node ruleNode = getVersionContentNode();
if ( ruleNode.hasProperty( CONTENT_PROPERTY_NAME ) ) {
Property data = ruleNode.getProperty( CONTENT_PROPERTY_NAME );
@@ -100,36 +101,36 @@
* returns the number of bytes of the content.
*/
public long getContentLength() {
- try {
- Node ruleNode = getVersionContentNode();
- if (ruleNode.hasProperty( CONTENT_PROPERTY_BINARY_NAME )) {
- Property data = ruleNode.getProperty( CONTENT_PROPERTY_BINARY_NAME );
- return data.getLength();
- } else {
- if ( ruleNode.hasProperty( CONTENT_PROPERTY_NAME ) ) {
- Property data = ruleNode.getProperty( CONTENT_PROPERTY_NAME );
- return data.getLength();
- } else {
- return 0;
- }
- }
- } catch (RepositoryException e) {
- log.error(e);
- throw new RulesRepositoryException(e);
- }
+ try {
+ Node ruleNode = getVersionContentNode();
+ if ( ruleNode.hasProperty( CONTENT_PROPERTY_BINARY_NAME ) ) {
+ Property data = ruleNode.getProperty( CONTENT_PROPERTY_BINARY_NAME );
+ return data.getLength();
+ } else {
+ if ( ruleNode.hasProperty( CONTENT_PROPERTY_NAME ) ) {
+ Property data = ruleNode.getProperty( CONTENT_PROPERTY_NAME );
+ return data.getLength();
+ } else {
+ return 0;
+ }
+ }
+ } catch ( RepositoryException e ) {
+ log.error( e );
+ throw new RulesRepositoryException( e );
+ }
}
/**
* True if this is a binary asset (or has binary content).
*/
public boolean isBinary() {
- try {
- Node ruleNode = getVersionContentNode();
- return ruleNode.hasProperty( CONTENT_PROPERTY_BINARY_NAME );
- } catch (RepositoryException e) {
- log.error(e);
- throw new RulesRepositoryException(e);
- }
+ try {
+ Node ruleNode = getVersionContentNode();
+ return ruleNode.hasProperty( CONTENT_PROPERTY_BINARY_NAME );
+ } catch ( RepositoryException e ) {
+ log.error( e );
+ throw new RulesRepositoryException( e );
+ }
}
/**
@@ -173,14 +174,15 @@
// Read in the bytes
int offset = 0;
int numRead = 0;
- while (offset < bytes.length
- && (numRead=in.read(bytes, offset, bytes.length-offset)) >= 0) {
+ while ( offset < bytes.length && (numRead = in.read( bytes,
+ offset,
+ bytes.length - offset )) >= 0 ) {
offset += numRead;
}
// Ensure all the bytes have been read in
- if (offset < bytes.length) {
- throw new RulesRepositoryException("Could not completely read asset "+ getName());
+ if ( offset < bytes.length ) {
+ throw new RulesRepositoryException( "Could not completely read asset " + getName() );
}
// Close the input stream and return bytes
@@ -191,12 +193,11 @@
}
} catch ( Exception e ) {
log.error( e );
- if (e instanceof RuntimeException) throw (RuntimeException) e;
+ if ( e instanceof RuntimeException ) throw (RuntimeException) e;
throw new RulesRepositoryException( e );
}
}
-
/**
* @return the date the rule becomes effective
* @throws RulesRepositoryException
@@ -218,6 +219,26 @@
}
/**
+ * @return if this rule is disabled
+ * @throws RulesRepositoryException
+ */
+ public boolean getDisabled() throws RulesRepositoryException {
+ try {
+ Node ruleNode = getVersionContentNode();
+
+ Property disabled = ruleNode.getProperty( DISABLED_PROPERTY_NAME );
+ return disabled.getBoolean();
+ } catch ( PathNotFoundException e ) {
+ // doesn't have this property
+ return false;
+ } catch ( Exception e ) {
+ log.error( "Caught Exception",
+ e );
+ throw new RulesRepositoryException( e );
+ }
+ }
+
+ /**
* Creates a new version of this object's rule node, updating the effective date for the
* rule node.
*
@@ -238,6 +259,26 @@
}
/**
+ * Creates a new version of this object's rule node, updating the disable value for the
+ * rule node.
+ *
+ * @param disabled is this rule 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 );
+ }
+ }
+
+ /**
* @return the date the rule becomes expired
* @throws RulesRepositoryException
*/
@@ -287,14 +328,15 @@
public AssetItem updateContent(String newRuleContent) throws RulesRepositoryException {
checkout();
try {
- if (this.isBinary()) {
- this.updateBinaryContentAttachment(new ByteArrayInputStream(newRuleContent.getBytes()));
- }
+ 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 );
+ log.error( "Unable to update the asset content",
+ e );
throw new RulesRepositoryException( e );
}
}
@@ -303,13 +345,15 @@
* If the asset is a binary asset, then use this to update the content
* (do NOT use text).
*/
- public AssetItem updateBinaryContentAttachment(InputStream data) {
+ public AssetItem updateBinaryContentAttachment(InputStream data) {
checkout();
try {
- this.node.setProperty( CONTENT_PROPERTY_BINARY_NAME, data );
+ this.node.setProperty( CONTENT_PROPERTY_BINARY_NAME,
+ data );
return this;
- } catch (RepositoryException e ) {
- log.error( "Unable to update the assets binary content", e );
+ } catch ( RepositoryException e ) {
+ log.error( "Unable to update the assets binary content",
+ e );
throw new RulesRepositoryException( e );
}
}
@@ -318,11 +362,10 @@
* Optionally set the filename to be associated with the binary content.
*/
public void updateBinaryContentAttachmentFileName(String name) {
- updateStringProperty( name, CONTENT_PROPERTY_ATTACHMENT_FILENAME );
+ updateStringProperty( name,
+ CONTENT_PROPERTY_ATTACHMENT_FILENAME );
}
-
-
/**
* This updates a user defined property (not one of the intrinsic ones).
*/
@@ -339,7 +382,7 @@
/**
* Nicely formats the information contained by the node that this object encapsulates
*/
- public String toString() {
+ public String toString() {
try {
StringBuffer returnString = new StringBuffer();
returnString.append( "Content of rule item named '" + this.getName() + "':\n" );
@@ -349,7 +392,6 @@
returnString.append( "Archived: " + this.isArchived() + "\n" );
returnString.append( "------\n" );
-
returnString.append( "Date Effective: " + this.getDateEffective() + "\n" );
returnString.append( "Date Expired: " + this.getDateExpired() + "\n" );
returnString.append( "------\n" );
@@ -448,22 +490,23 @@
* @return An iterator over the nodes history.
*/
public AssetHistoryIterator getHistory() {
- return new AssetHistoryIterator(this.rulesRepository, this.node);
+ return new AssetHistoryIterator( this.rulesRepository,
+ this.node );
}
-
/**
* This will get the package an asset item belongs to.
*/
public PackageItem getPackage() {
try {
- if (this.isHistoricalVersion()) {
- throw new UnsupportedOperationException("Unable to get package for versioned asset. Use base revision.");
+ if ( this.isHistoricalVersion() ) {
+ throw new UnsupportedOperationException( "Unable to get package for versioned asset. Use base revision." );
}
- return new PackageItem(this.rulesRepository, this.node.getParent().getParent());
- } catch (RepositoryException e) {
- throw new RulesRepositoryException(e);
+ return new PackageItem( this.rulesRepository,
+ this.node.getParent().getParent() );
+ } catch ( RepositoryException e ) {
+ throw new RulesRepositoryException( e );
}
}
@@ -478,28 +521,25 @@
*/
public static String[] getAssetNameFromFileName(String fileName) {
- String[] r = new String[] {"", ""};
- char[] cs = fileName.toCharArray();
- boolean name = true;
- for (int i = 0; i < cs.length; i++) {
- if (name && cs[i] == '.') {
- String rhs = fileName.substring(i);
- if (rhs.contains("_") || rhs.contains(" ")) {
- r[0] = r[0] + '.'; //its part of the name
- } else {
- name = false;
- }
- } else if (name) {
- r[0] = r[0] + cs[i];
- } else {
- r[1] = r[1] + cs[i];
- }
- }
- return r;
+ String[] r = new String[]{"", ""};
+ char[] cs = fileName.toCharArray();
+ boolean name = true;
+ for ( int i = 0; i < cs.length; i++ ) {
+ if ( name && cs[i] == '.' ) {
+ String rhs = fileName.substring( i );
+ if ( rhs.contains( "_" ) || rhs.contains( " " ) ) {
+ r[0] = r[0] + '.'; //its part of the name
+ } else {
+ name = false;
+ }
+ } else if ( name ) {
+ r[0] = r[0] + cs[i];
+ } else {
+ r[1] = r[1] + cs[i];
+ }
+ }
+ return r;
-
}
-
-
}
\ No newline at end of file
More information about the jboss-svn-commits
mailing list