[jboss-svn-commits] JBL Code SVN: r29105 - in labs/jbossrules/trunk/drools-repository/src: test/java/org/drools/repository and 1 other directory.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Fri Aug 28 07:11:38 EDT 2009
Author: Rikkola
Date: 2009-08-28 07:11:38 -0400 (Fri, 28 Aug 2009)
New Revision: 29105
Modified:
labs/jbossrules/trunk/drools-repository/src/main/java/org/drools/repository/AssetItem.java
labs/jbossrules/trunk/drools-repository/src/test/java/org/drools/repository/AssetItemTest.java
Log:
JBRULES-2109 : Upload of Resource to Guvnor with multiple "." in file name causes resource type identification issues
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 2009-08-28 10:15:32 UTC (rev 29104)
+++ labs/jbossrules/trunk/drools-repository/src/main/java/org/drools/repository/AssetItem.java 2009-08-28 11:11:38 UTC (rev 29105)
@@ -74,16 +74,14 @@
null );
}
-
-
-
/**
* returns the string contents of the rule node.
* If this is a binary asset, this will return null (use getBinaryContent instead).
*/
public String getContent() throws RulesRepositoryException {
- return getContent(false);
+ return getContent( false );
}
+
/**
* Only for use in the StorageEventManager, for passing the fromRepo parameter
*
@@ -93,8 +91,8 @@
public String getContent(Boolean fromRepo) throws RulesRepositoryException {
try {
- if (StorageEventManager.hasLoadEvent() && !fromRepo) {
- return IOUtils.toString(StorageEventManager.getLoadEvent().loadContent(this));
+ if ( StorageEventManager.hasLoadEvent() && !fromRepo ) {
+ return IOUtils.toString( StorageEventManager.getLoadEvent().loadContent( this ) );
}
if ( isBinary() ) {
@@ -157,15 +155,15 @@
*/
public InputStream getBinaryContentAttachment() {
try {
- if (StorageEventManager.hasLoadEvent()) {
- return StorageEventManager.getLoadEvent().loadContent(this);
+ if ( StorageEventManager.hasLoadEvent() ) {
+ return StorageEventManager.getLoadEvent().loadContent( this );
}
Node ruleNode = getVersionContentNode();
if ( ruleNode.hasProperty( CONTENT_PROPERTY_BINARY_NAME ) ) {
Property data = ruleNode.getProperty( CONTENT_PROPERTY_BINARY_NAME );
return data.getStream();
} else {
- if ( ruleNode.hasProperty(CONTENT_PROPERTY_NAME)) {
+ if ( ruleNode.hasProperty( CONTENT_PROPERTY_NAME ) ) {
Property data = ruleNode.getProperty( CONTENT_PROPERTY_NAME );
return data.getStream();
}
@@ -189,33 +187,33 @@
public byte[] getBinaryContentAsBytes() {
try {
Node ruleNode = getVersionContentNode();
- if (StorageEventManager.hasLoadEvent()) {
- return IOUtils.toByteArray(StorageEventManager.getLoadEvent().loadContent(this));
+ if ( StorageEventManager.hasLoadEvent() ) {
+ return IOUtils.toByteArray( StorageEventManager.getLoadEvent().loadContent( this ) );
}
- if (isBinary()) {
- Property data = ruleNode.getProperty( CONTENT_PROPERTY_BINARY_NAME );
- InputStream in = data.getStream();
+ if ( isBinary() ) {
+ Property data = ruleNode.getProperty( CONTENT_PROPERTY_BINARY_NAME );
+ InputStream in = data.getStream();
- // Create the byte array to hold the data
- byte[] bytes = new byte[(int) data.getLength()];
+ // Create the byte array to hold the data
+ byte[] bytes = new byte[(int) data.getLength()];
- // Read in the bytes
- int offset = 0;
- int numRead = 0;
- while ( offset < bytes.length && (numRead = in.read( bytes,
- offset,
- bytes.length - offset )) >= 0 ) {
- offset += numRead;
- }
+ // Read in the bytes
+ int offset = 0;
+ int numRead = 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() );
- }
+ // Ensure all the bytes have been read in
+ if ( offset < bytes.length ) {
+ throw new RulesRepositoryException( "Could not completely read asset " + getName() );
+ }
- // Close the input stream and return bytes
- in.close();
- return bytes;
+ // Close the input stream and return bytes
+ in.close();
+ return bytes;
} else {
return getContent().getBytes();
}
@@ -501,8 +499,8 @@
*/
public void remove() {
- if (StorageEventManager.hasSaveEvent()) {
- StorageEventManager.getSaveEvent().onAssetDelete(this);
+ if ( StorageEventManager.hasSaveEvent() ) {
+ StorageEventManager.getSaveEvent().onAssetDelete( this );
}
checkIsUpdateable();
@@ -534,7 +532,7 @@
try {
if ( this.isHistoricalVersion() ) {
- return this.rulesRepository.loadPackage(this.getPackageName());
+ return this.rulesRepository.loadPackage( this.getPackageName() );
}
return new PackageItem( this.rulesRepository,
this.node.getParent().getParent() );
@@ -560,7 +558,7 @@
for ( int i = 0; i < cs.length; i++ ) {
if ( name && cs[i] == '.' ) {
String rhs = fileName.substring( i + 1 );
- if ( rhs.contains( "_" ) || rhs.contains( " " ) || rhs.contains( ".jar" ) ) {
+ if ( !rhs.equals( "bpel.jar" ) && (rhs.contains( "_" ) || rhs.contains( " " ) || rhs.contains( ".jar" )) ) {
r[0] = r[0] + '.'; //its part of the name
} else {
name = false;
Modified: labs/jbossrules/trunk/drools-repository/src/test/java/org/drools/repository/AssetItemTest.java
===================================================================
--- labs/jbossrules/trunk/drools-repository/src/test/java/org/drools/repository/AssetItemTest.java 2009-08-28 10:15:32 UTC (rev 29104)
+++ labs/jbossrules/trunk/drools-repository/src/test/java/org/drools/repository/AssetItemTest.java 2009-08-28 11:11:38 UTC (rev 29105)
@@ -162,10 +162,6 @@
assertEquals("foo", asset[0]);
assertEquals("bar", asset[1]);
- asset = AssetItem.getAssetNameFromFileName("foo.bar.xls");
- assertEquals("foo", asset[0]);
- assertEquals("bar.xls", asset[1]);
-
asset = AssetItem.getAssetNameFromFileName("Rule 261.3 Something foo.drl");
assertEquals("Rule 261.3 Something foo", asset[0]);
assertEquals("drl", asset[1]);
@@ -186,6 +182,10 @@
assertEquals("application-model-1.0.0", asset[0]);
assertEquals("jar", asset[1]);
+ asset = AssetItem.getAssetNameFromFileName("foo.bpel.jar");
+ assertEquals("foo", asset[0]);
+ assertEquals("bpel.jar", asset[1]);
+
asset = AssetItem.getAssetNameFromFileName("SubmitApplication.rf");
assertEquals("SubmitApplication", asset[0]);
assertEquals("rf", asset[1]);
More information about the jboss-svn-commits
mailing list