You can subscribe to this list here.
2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(233) |
Sep
(199) |
Oct
(206) |
Nov
(185) |
Dec
(270) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
(232) |
Feb
(426) |
Mar
(623) |
Apr
(592) |
May
(506) |
Jun
(389) |
Jul
(160) |
Aug
(3) |
Sep
(1) |
Oct
(1) |
Nov
(2) |
Dec
(5) |
2007 |
Jan
(1) |
Feb
(1) |
Mar
(2) |
Apr
(2) |
May
(4) |
Jun
(2) |
Jul
|
Aug
(3) |
Sep
(5) |
Oct
(9) |
Nov
(6) |
Dec
(6) |
2008 |
Jan
(3) |
Feb
|
Mar
(1) |
Apr
(3) |
May
(3) |
Jun
(5) |
Jul
(10) |
Aug
(2) |
Sep
(12) |
Oct
(10) |
Nov
(54) |
Dec
(49) |
2009 |
Jan
(19) |
Feb
(13) |
Mar
(20) |
Apr
(24) |
May
(44) |
Jun
(29) |
Jul
(32) |
Aug
(10) |
Sep
(7) |
Oct
(10) |
Nov
(4) |
Dec
(17) |
2010 |
Jan
(14) |
Feb
(5) |
Mar
(23) |
Apr
(50) |
May
(31) |
Jun
(9) |
Jul
(5) |
Aug
(4) |
Sep
(7) |
Oct
(5) |
Nov
(2) |
Dec
(3) |
2011 |
Jan
(12) |
Feb
(5) |
Mar
(5) |
Apr
(3) |
May
(4) |
Jun
(3) |
Jul
(2) |
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
|
2012 |
Jan
(1) |
Feb
(2) |
Mar
|
Apr
(1) |
May
(1) |
Jun
(2) |
Jul
(4) |
Aug
(1) |
Sep
|
Oct
(1) |
Nov
|
Dec
|
2013 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(2) |
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
2014 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(3) |
Sep
|
Oct
|
Nov
|
Dec
(1) |
2015 |
Jan
|
Feb
|
Mar
(2) |
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2016 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <jbo...@li...> - 2006-05-05 15:02:36
|
Author: adamw Date: 2006-05-05 11:02:20 -0400 (Fri, 05 May 2006) New Revision: 4101 Modified: labs/shotoku/trunk/shotoku-admin/src/java/org/jboss/shotoku/web/admin/UpdateServlet.java labs/shotoku/trunk/shotoku-test/src/java/org/jboss/shotoku/test/embedded/TomekTest.java Log: http://jira.jboss.com/jira/browse/JBSHOTOKU-31 Modified: labs/shotoku/trunk/shotoku-admin/src/java/org/jboss/shotoku/web/admin/UpdateServlet.java =================================================================== --- labs/shotoku/trunk/shotoku-admin/src/java/org/jboss/shotoku/web/admin/UpdateServlet.java 2006-05-05 04:46:43 UTC (rev 4100) +++ labs/shotoku/trunk/shotoku-admin/src/java/org/jboss/shotoku/web/admin/UpdateServlet.java 2006-05-05 15:02:20 UTC (rev 4101) @@ -18,7 +18,6 @@ HttpServletResponse response) throws ServletException, IOException { String data = request.getParameter("data"); - System.out.println("DATA: " + data); if (data == null) { return; } @@ -28,27 +27,26 @@ String id = tokens[0]; long revision = Integer.valueOf(tokens[1]); - tokens = tokens[2].split(":"); - Set<String> toUpdate = new HashSet<String>(); + String[] pathTokens = tokens[2].split(":", -1); + String current = pathTokens[0]; - String current = tokens[0]; - /*toUpdate.add(current); + toUpdate.add(current); - for (String token : tokens) { + for (String token : pathTokens) { + /* + * An empty path will always be the last read token. It can + * also mean that the whole tree needs updating, but in this + * case it will be the first token and added to the set + * earlier. + */ if (!"".equals(token) && !token.startsWith(current)) { current = token; toUpdate.add(token); } } - for (String a : toUpdate) { - System.out.println(a); - } - - System.out.println("Rev: " + revision + ", id: " + id); - - //SvnTools.getService().addPathsToUpdate(id, revision, toUpdate); */ + SvnTools.getService().addPathsToUpdate(id, revision, toUpdate); } catch (Exception e) { // In case of an exception, doing nothing. } Modified: labs/shotoku/trunk/shotoku-test/src/java/org/jboss/shotoku/test/embedded/TomekTest.java =================================================================== --- labs/shotoku/trunk/shotoku-test/src/java/org/jboss/shotoku/test/embedded/TomekTest.java 2006-05-05 04:46:43 UTC (rev 4100) +++ labs/shotoku/trunk/shotoku-test/src/java/org/jboss/shotoku/test/embedded/TomekTest.java 2006-05-05 15:02:20 UTC (rev 4101) @@ -17,10 +17,12 @@ } public static void main(String[] args) { - Set<String> x = TomekTest.getSet("a", "b", "c", "a"); + String[] t = "v".split("v", -1); + System.out.println("T content:"); + for (String x : t) { + System.out.println(x); + } - for (String s : x) { - System.out.println(s); - } + System.out.println("---"); } } |
Author: mic...@jb... Date: 2006-05-04 21:30:58 -0400 (Thu, 04 May 2006) New Revision: 4096 Added: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/PersonInterface.java Modified: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/Person.java labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/IntegrationCases.java labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/integrationtests/literal_with_boolean.drl Log: added interface test Modified: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/Person.java =================================================================== --- labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/Person.java 2006-05-04 22:25:33 UTC (rev 4095) +++ labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/Person.java 2006-05-05 01:30:58 UTC (rev 4096) @@ -21,7 +21,7 @@ -public class Person implements Serializable { +public class Person implements Serializable, PersonInterface { private final String name; private final String likes; private final int age; @@ -49,40 +49,67 @@ this.age = age; } + /* (non-Javadoc) + * @see org.drools.PersonInterface#getStatus() + */ public String getStatus() { return status; } + /* (non-Javadoc) + * @see org.drools.PersonInterface#setStatus(java.lang.String) + */ public void setStatus(String status) { this.status = status; } + /* (non-Javadoc) + * @see org.drools.PersonInterface#getLikes() + */ public String getLikes() { return likes; } + /* (non-Javadoc) + * @see org.drools.PersonInterface#getName() + */ public String getName() { return name; } + /* (non-Javadoc) + * @see org.drools.PersonInterface#getAge() + */ public int getAge() { return this.age; } + /* (non-Javadoc) + * @see org.drools.PersonInterface#isAlive() + */ public boolean isAlive() { return alive; } + /* (non-Javadoc) + * @see org.drools.PersonInterface#setAlive(boolean) + */ public void setAlive(boolean alive) { this.alive = alive; } + /* (non-Javadoc) + * @see org.drools.PersonInterface#getSex() + */ public char getSex() { return sex; } + /* (non-Javadoc) + * @see org.drools.PersonInterface#setSex(char) + */ public void setSex(char sex) { this.sex = sex; } @@ -124,21 +151,33 @@ } + /* (non-Javadoc) + * @see org.drools.PersonInterface#getBigDecimal() + */ public BigDecimal getBigDecimal() { return bigDecimal; } + /* (non-Javadoc) + * @see org.drools.PersonInterface#setBigDecimal(java.math.BigDecimal) + */ public void setBigDecimal(BigDecimal bigDecimal) { this.bigDecimal = bigDecimal; } + /* (non-Javadoc) + * @see org.drools.PersonInterface#getBigInteger() + */ public BigInteger getBigInteger() { return bigInteger; } + /* (non-Javadoc) + * @see org.drools.PersonInterface#setBigInteger(java.math.BigInteger) + */ public void setBigInteger(BigInteger bigInteger) { this.bigInteger = bigInteger; } Added: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/PersonInterface.java =================================================================== --- labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/PersonInterface.java 2006-05-04 22:25:33 UTC (rev 4095) +++ labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/PersonInterface.java 2006-05-05 01:30:58 UTC (rev 4096) @@ -0,0 +1,34 @@ +package org.drools; + +import java.math.BigDecimal; +import java.math.BigInteger; + +public interface PersonInterface { + + public abstract String getStatus(); + + public abstract void setStatus(String status); + + public abstract String getLikes(); + + public abstract String getName(); + + public abstract int getAge(); + + public abstract boolean isAlive(); + + public abstract void setAlive(boolean alive); + + public abstract char getSex(); + + public abstract void setSex(char sex); + + public abstract BigDecimal getBigDecimal(); + + public abstract void setBigDecimal(BigDecimal bigDecimal); + + public abstract BigInteger getBigInteger(); + + public abstract void setBigInteger(BigInteger bigInteger); + +} \ No newline at end of file Property changes on: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/PersonInterface.java ___________________________________________________________________ Name: svn:eol-style + native Modified: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/IntegrationCases.java =================================================================== --- labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/IntegrationCases.java 2006-05-04 22:25:33 UTC (rev 4095) +++ labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/IntegrationCases.java 2006-05-05 01:30:58 UTC (rev 4096) @@ -37,6 +37,7 @@ import org.drools.Cheesery; import org.drools.FactHandle; import org.drools.Person; +import org.drools.PersonInterface; import org.drools.QueryResults; import org.drools.RuleBase; import org.drools.Sensor; @@ -205,7 +206,7 @@ workingMemory.setGlobal( "list", list ); - Person bill = new Person( "bill", + PersonInterface bill = new Person( "bill", null, 12 ); bill.setAlive( true ); @@ -230,7 +231,7 @@ workingMemory.setGlobal( "list", list ); - Person bill = new Person( "bill", + PersonInterface bill = new Person( "bill", null, 12 ); bill.setBigDecimal( new BigDecimal("42") ); @@ -379,11 +380,11 @@ workingMemory.setGlobal( "list", list ); - Person peter = new Person( "peter", + PersonInterface peter = new Person( "peter", null, 12 ); workingMemory.assertObject( peter ); - Person jane = new Person( "jane", + PersonInterface jane = new Person( "jane", null, 10 ); workingMemory.assertObject( jane ); @@ -412,11 +413,11 @@ workingMemory.setGlobal( "list", list ); - Person peter = new Person( "peter", + PersonInterface peter = new Person( "peter", null, 12 ); workingMemory.assertObject( peter ); - Person jane = new Person( "jane", + PersonInterface jane = new Person( "jane", null, 10 ); workingMemory.assertObject( jane ); @@ -489,7 +490,7 @@ 7 ); FactHandle cheddarHandle = workingMemory.assertObject( cheddar ); - Person paul = new Person( "paul", + PersonInterface paul = new Person( "paul", "stilton", 12 ); workingMemory.assertObject( paul ); @@ -515,10 +516,10 @@ ruleBase.addPackage( pkg ); WorkingMemory workingMemory = ruleBase.newWorkingMemory(); - Person p1 = new Person( "michael", + PersonInterface p1 = new Person( "michael", "food", 40 ); - Person p2 = new Person( null, + PersonInterface p2 = new Person( null, "drink", 30 ); workingMemory.assertObject( p1 ); @@ -540,7 +541,7 @@ workingMemory.setGlobal( "messages", foo ); - Person p1 = new Person( null, + PersonInterface p1 = new Person( null, "food", 40 ); @@ -758,7 +759,7 @@ workingMemory.setGlobal( "list", list ); - Person person = new Person( "michael", + PersonInterface person = new Person( "michael", "cheese" ); person.setStatus( "start" ); workingMemory.assertObject( person ); @@ -905,7 +906,7 @@ workingMemory.setGlobal( "list", list ); - Person person = new Person( "Edson", + PersonInterface person = new Person( "Edson", "cheese" ); workingMemory.assertObject( person ); @@ -1277,7 +1278,7 @@ // Adding person in advance. There is no Person() object // type node in memory yet, but the rule engine is supposed // to handle that correctly - Person bob = new Person( "bob", + PersonInterface bob = new Person( "bob", "stilton" ); bob.setStatus( "Not evaluated" ); workingMemory.assertObject( bob ); @@ -1370,7 +1371,7 @@ workingMemory.setGlobal( "list", list ); - Person bob = new Person( "bob", + PersonInterface bob = new Person( "bob", "stilton" ); bob.setStatus( "Not evaluated" ); workingMemory.assertObject( bob ); @@ -1429,10 +1430,10 @@ WorkingMemory workingMemory = ruleBase.newWorkingMemory(); // Adding person with null name and likes attributes - Person bob = new Person( null, + PersonInterface bob = new Person( null, null ); bob.setStatus( "P1" ); - Person pete = new Person( null, + PersonInterface pete = new Person( null, null ); bob.setStatus( "P2" ); workingMemory.assertObject( bob ); Modified: labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/integrationtests/literal_with_boolean.drl =================================================================== --- labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/integrationtests/literal_with_boolean.drl 2006-05-04 22:25:33 UTC (rev 4095) +++ labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/integrationtests/literal_with_boolean.drl 2006-05-05 01:30:58 UTC (rev 4096) @@ -1,7 +1,7 @@ #created on: 27-Mar-2006 package org.drools.test -import org.drools.Person; +import org.drools.PersonInterface; global java.util.List list; @@ -9,7 +9,7 @@ when #conditions - alivePerson : Person(alive == true) + alivePerson : PersonInterface(alive == true) then list.add( alivePerson ); end |
From: <jbo...@li...> - 2006-05-05 05:15:22
|
Author: mic...@jb... Date: 2006-05-05 00:38:51 -0400 (Fri, 05 May 2006) New Revision: 4099 Added: labs/jbossrules/trunk/documentation/manual/en/Chapter-Decision_Tables/actions.png labs/jbossrules/trunk/documentation/manual/en/Chapter-Decision_Tables/lists.png Modified: labs/jbossrules/trunk/documentation/manual/en/Chapter-Decision_Tables/Section-Spreadsheet.xml labs/jbossrules/trunk/documentation/manual/en/Chapter-Decision_Tables/Thumbs.db labs/jbossrules/trunk/documentation/manual/en/master.xml Log: more doco Modified: labs/jbossrules/trunk/documentation/manual/en/Chapter-Decision_Tables/Section-Spreadsheet.xml =================================================================== --- labs/jbossrules/trunk/documentation/manual/en/Chapter-Decision_Tables/Section-Spreadsheet.xml 2006-05-05 04:33:58 UTC (rev 4098) +++ labs/jbossrules/trunk/documentation/manual/en/Chapter-Decision_Tables/Section-Spreadsheet.xml 2006-05-05 04:38:51 UTC (rev 4099) @@ -2,6 +2,10 @@ <section> <title>Decision tables in spreadsheets</title> + <para>Decision tables are a "precise yet compact" (ref. Wikipedia) way of + representing conditional logic, and are well suited to "business" level + rules.</para> + <para>Drools supports managing rules in a Spreadsheet format. Formats supported are Excel, and CSV. Thus you can use a variety of spreadsheet programs (such as Microsoft Excel, OpenOffice.org Calc amongst others). It @@ -50,6 +54,16 @@ </screenshot> <screenshot> + <screeninfo>Can have multiple actions for a rule row</screeninfo> + + <mediaobject> + <imageobject> + <imagedata fileref="actions.png" /> + </imageobject> + </mediaobject> + </screenshot> + + <screenshot> <screeninfo>Using OpenOffice</screeninfo> <mediaobject> @@ -97,14 +111,9 @@ <section> <title>How decision tables work</title> - <para>The spreadsheet looks for the "RuleTable" keyword to indicate the - start of a rule table (both the starting row and column). Other keywords - are also used to define other package level attributes (covered later). It - is important to keep the keywords in the one column. By convention the - second column ("B") is used for this, but it can be any column (convention - is to leave a margin on the left for notes). In the following diagram, C - is actually the column where it starts. Everything to the left of this is - ignored.</para> + <para>The key point to keep in mind is that in a decision table, each row + is a rule, and each column in that row is either a condition or action for + that rule.</para> <screenshot> <screeninfo>Rows and columns</screeninfo> @@ -116,6 +125,15 @@ </mediaobject> </screenshot> + <para>The spreadsheet looks for the "RuleTable" keyword to indicate the + start of a rule table (both the starting row and column). Other keywords + are also used to define other package level attributes (covered later). It + is important to keep the keywords in the one column. By convention the + second column ("B") is used for this, but it can be any column (convention + is to leave a margin on the left for notes). In the following diagram, C + is actually the column where it starts. Everything to the left of this is + ignored.</para> + <para>If we expand the hidden sections, it starts to make more sense how it works. Note the keywords in column C.</para> @@ -277,7 +295,7 @@ <entry>DURATION</entry> <entry>Indicates that this columns values will set the duration - values for the rule row. </entry> + values for the rule row.</entry> <entry>optional</entry> </row> @@ -331,7 +349,6 @@ <entry>N/A</entry> </row> - </tbody> </tgroup> </table> @@ -348,4 +365,111 @@ </screenshot> </section> </section> + + <section> + <title>Creating and integrating Spreadsheet based Decision Tables</title> + + <para>The API to use spreadsheet based decision tables is in the + drools-decisiontables module. There is really only one class to look at: + SpreadsheetCompiler. This class will take spreadsheets in various formats, + and generate rules in DRL (which you can then use in the normal way). Also + note that if you like you can just use the SpreadsheetComiler to generate + partial rule files, and assemble it into a complete rule package after the + fact (this allows to you seperate technical and non technical aspects of + the rules if needed).</para> + + <para>To get started, you can find a sample spreadsheet and base it on + that. Alternatively, if you are using the plug in (Rule Workbench IDE) the + wizard can generate a spreadsheet for you from a template (to edit it you + will need to use an xls compatable spreadsheet editor). <screenshot> + <screeninfo>Wizard in the IDE</screeninfo> + + <mediaobject> + <imageobject> + <imagedata fileref="wizard.png" /> + </imageobject> + </mediaobject> + </screenshot></para> + </section> + + <section> + <title>Managing business rules in decision tables.</title> + + <section> + <title>Workflow and collaboration.</title> + + <para>Spreadsheets are well established business tools (in use for over + 25 years). Decision tables lend themselves to close collaboration + between IT and domain experts, while making the business rules clear to + business analysts, it is an ideal seperation of concerns.</para> + + <para>Typically, the whole process of authoring rules (coming up with a + new decision table) would be something like:</para> + + <orderedlist> + <listitem> + <para>Business analyst takes a template decision table (from a + repository, or from IT)</para> + </listitem> + + <listitem> + <para>Decision table business language descriptions are entered in + the table(s)</para> + </listitem> + + <listitem> + <para>Decision table rules (rows) are entered (roughly)</para> + </listitem> + + <listitem> + <para>Decision table is handed to a technical resource, who maps the + business language (descriptions) to scripts (this may involve + software development of course, if it is a new application or data + model !)</para> + </listitem> + + <listitem> + <para>Technical person hands back and reviews the modifications with + the business analyst.</para> + </listitem> + + <listitem> + <para>The business analyst can continue editing the rule rows as + needed (moving columns around is also fine etc).</para> + </listitem> + + <listitem> + <para>In parallel, the technical person can develop test cases for + the rules (liasing with business analysts) as these test cases can + be used to verify rules and rule changes once the system is + running.</para> + </listitem> + </orderedlist> + </section> + + <section> + <title>Using spreadsheet features</title> + + <para>You can use the features of applications like Excel to provide + assistance in entering data into spreadsheets, such as validating + fields. You can use lists that are stored in other worksheets to provide + valid lists of values for cells, like in the following diagram. + <screenshot> + <screeninfo>Wizard in the IDE</screeninfo> + + <mediaobject> + <imageobject> + <imagedata fileref="lists.png" /> + </imageobject> + </mediaobject> + </screenshot></para> + + <para>Some applications provide a limited ability to keep a history of + changes, but it is recommended that an alternative means of revision + control is also used. So when you are making changes to rules over time, + older versions are archived (many solutions exist for this which are + also open source, such as Subversion). + http://www.drools.org/Business+rules+in+decision+tables+explained</para> + </section> + </section> </section> \ No newline at end of file Modified: labs/jbossrules/trunk/documentation/manual/en/Chapter-Decision_Tables/Thumbs.db =================================================================== (Binary files differ) Added: labs/jbossrules/trunk/documentation/manual/en/Chapter-Decision_Tables/actions.png =================================================================== (Binary files differ) Property changes on: labs/jbossrules/trunk/documentation/manual/en/Chapter-Decision_Tables/actions.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: labs/jbossrules/trunk/documentation/manual/en/Chapter-Decision_Tables/lists.png =================================================================== (Binary files differ) Property changes on: labs/jbossrules/trunk/documentation/manual/en/Chapter-Decision_Tables/lists.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Modified: labs/jbossrules/trunk/documentation/manual/en/master.xml =================================================================== --- labs/jbossrules/trunk/documentation/manual/en/master.xml 2006-05-05 04:33:58 UTC (rev 4098) +++ labs/jbossrules/trunk/documentation/manual/en/master.xml 2006-05-05 04:38:51 UTC (rev 4099) @@ -52,20 +52,6 @@ <title>Reference Manual</title> <chapter> - <title>Installation and Setup</title> - - <xi:include href="Chapter-Install/Section-Install.xml" /> - - <xi:include href="Chapter-Install/Section-Setup.xml" /> - - <xi:include href="Chapter-Install/Section-Checkout.xml" /> - - <xi:include href="Chapter-Install/Section-Maven_build.xml" /> - - <xi:include href="Chapter-Install/Section-Eclipse.xml" /> - </chapter> - - <chapter> <title>The Rule Engine</title> <xi:include href="Chapter-Rule_Engine/Section-What_is_a_Rule_Engine.xml" /> @@ -86,6 +72,20 @@ </chapter> <chapter> + <title>Installation and Setup</title> + + <xi:include href="Chapter-Install/Section-Install.xml" /> + + <xi:include href="Chapter-Install/Section-Setup.xml" /> + + <xi:include href="Chapter-Install/Section-Checkout.xml" /> + + <xi:include href="Chapter-Install/Section-Maven_build.xml" /> + + <xi:include href="Chapter-Install/Section-Eclipse.xml" /> + </chapter> + + <chapter> <title>The Rule Language</title> <xi:include href="Chapter-Rule_Language/Section-Overview.xml" /> |
From: <jbo...@li...> - 2006-05-05 05:15:21
|
Author: mic...@jb... Date: 2006-05-05 00:33:58 -0400 (Fri, 05 May 2006) New Revision: 4098 Modified: labs/jbossrules/trunk/documentation/manual/en/Chapter-Rule_Engine/Section-Leaps_Algorithm.xml Log: some minor editing Modified: labs/jbossrules/trunk/documentation/manual/en/Chapter-Rule_Engine/Section-Leaps_Algorithm.xml =================================================================== --- labs/jbossrules/trunk/documentation/manual/en/Chapter-Rule_Engine/Section-Leaps_Algorithm.xml 2006-05-05 03:17:34 UTC (rev 4097) +++ labs/jbossrules/trunk/documentation/manual/en/Chapter-Rule_Engine/Section-Leaps_Algorithm.xml 2006-05-05 04:33:58 UTC (rev 4098) @@ -2,11 +2,11 @@ <section> <title>Leaps Algorithm</title> - <para>Leaps algorithm for production systems uses "lazy" approach to - condition evaluations. Modification of this algorithm, implemented as part - of Drools v3, makes attempt to take the best features of both Leaps and Rete + <para>Leaps algorithm for production systems uses a "lazy" approach to + condition evaluations. A modified version of this algorithm, implemented as part + of Drools v3, attempts to take the best features of both Leaps and Rete approaches in processing facts in the working memory. Leaps is not being - described here in details but only relevant sections to described how + described here in detail but only some relevant sections to described how current implementation deviates from "classical" leaps algorithm.</para> <para>The "classical" Leaps approach puts all incoming (asserted) facts on |
From: <jbo...@li...> - 2006-05-05 05:15:20
|
Author: mic...@jb... Date: 2006-05-05 00:46:43 -0400 (Fri, 05 May 2006) New Revision: 4100 Modified: labs/jbossrules/trunk/documentation/manual/en/Chapter-Decision_Tables/Section-Spreadsheet.xml Log: Modified: labs/jbossrules/trunk/documentation/manual/en/Chapter-Decision_Tables/Section-Spreadsheet.xml =================================================================== --- labs/jbossrules/trunk/documentation/manual/en/Chapter-Decision_Tables/Section-Spreadsheet.xml 2006-05-05 04:38:51 UTC (rev 4099) +++ labs/jbossrules/trunk/documentation/manual/en/Chapter-Decision_Tables/Section-Spreadsheet.xml 2006-05-05 04:46:43 UTC (rev 4100) @@ -35,6 +35,8 @@ like excel or open office). They are ideal in the sense that you can control what "parameters" of rules can be edited, without exposing the rules directly.</para> + + <para>Decision tables also provide a degree of insulation from the underlying object model.</para> </section> <section> |
From: <jbo...@li...> - 2006-05-04 22:25:59
|
Author: szimano Date: 2006-05-04 18:25:33 -0400 (Thu, 04 May 2006) New Revision: 4095 Added: labs/jbosslabs/branches/Labs-Portal-2.0-ComTheme/forge/portal-extensions/jbosswiki/wiki-common/src/etc/countryCodes.dtd labs/jbosslabs/branches/Labs-Portal-2.0-ComTheme/forge/portal-extensions/jbosswiki/wiki-common/src/etc/wikiTypes.dtd labs/jbosslabs/branches/Labs-Portal-2.0-ComTheme/forge/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/FileAttachmentDataSource.java labs/jbosslabs/branches/Labs-Portal-2.0-ComTheme/forge/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/FileDSCommons.java labs/jbosslabs/branches/Labs-Portal-2.0-ComTheme/forge/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/FileMediaDataSource.java labs/jbosslabs/branches/Labs-Portal-2.0-ComTheme/forge/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/FileWikiPageDictionary.java Removed: labs/jbosslabs/branches/Labs-Portal-2.0-ComTheme/forge/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/FileDataSource.java Modified: labs/jbosslabs/branches/Labs-Portal-2.0-ComTheme/forge/portal-extensions/jbosswiki/forge-wiki/src/java/org/jboss/wiki/WikiPortlet.java labs/jbosslabs/branches/Labs-Portal-2.0-ComTheme/forge/portal-extensions/jbosswiki/forge-wiki/src/java/org/jboss/wiki/fileaccess/WikiFileAccessFilter.java labs/jbosslabs/branches/Labs-Portal-2.0-ComTheme/forge/portal-extensions/jbosswiki/forge-wiki/src/web/WEB-INF/jsp/Edit.jsp labs/jbosslabs/branches/Labs-Portal-2.0-ComTheme/forge/portal-extensions/jbosswiki/forge-wiki/src/web/WEB-INF/jsp/PageInfo.jsp labs/jbosslabs/branches/Labs-Portal-2.0-ComTheme/forge/portal-extensions/jbosswiki/forge-wiki/src/web/WEB-INF/jsp/Wiki.jsp labs/jbosslabs/branches/Labs-Portal-2.0-ComTheme/forge/portal-extensions/jbosswiki/wiki-common/project.xml labs/jbosslabs/branches/Labs-Portal-2.0-ComTheme/forge/portal-extensions/jbosswiki/wiki-common/src/etc/CountryCodes.xml labs/jbosslabs/branches/Labs-Portal-2.0-ComTheme/forge/portal-extensions/jbosswiki/wiki-common/src/etc/JBossWiki.properties labs/jbosslabs/branches/Labs-Portal-2.0-ComTheme/forge/portal-extensions/jbosswiki/wiki-common/src/etc/WikiTypes.xml labs/jbosslabs/branches/Labs-Portal-2.0-ComTheme/forge/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/RenamePageWatcher.java labs/jbosslabs/branches/Labs-Portal-2.0-ComTheme/forge/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/WikiEngine.java labs/jbosslabs/branches/Labs-Portal-2.0-ComTheme/forge/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/WikiInsidePlugin.java labs/jbosslabs/branches/Labs-Portal-2.0-ComTheme/forge/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/WikiPlugin.java labs/jbosslabs/branches/Labs-Portal-2.0-ComTheme/forge/portal-extensions/jbosswiki/wiki-test/project.properties labs/jbosslabs/branches/Labs-Portal-2.0-ComTheme/forge/portal-extensions/jbosswiki/wiki-test/project.xml Log: MERGED: -r 3348:4094 https://svn.labs.jboss.org/labs/jbosslabs/trunk/portal-extensions/jbosswiki . Modified: labs/jbosslabs/branches/Labs-Portal-2.0-ComTheme/forge/portal-extensions/jbosswiki/forge-wiki/src/java/org/jboss/wiki/WikiPortlet.java =================================================================== --- labs/jbosslabs/branches/Labs-Portal-2.0-ComTheme/forge/portal-extensions/jbosswiki/forge-wiki/src/java/org/jboss/wiki/WikiPortlet.java 2006-05-04 18:16:20 UTC (rev 4094) +++ labs/jbosslabs/branches/Labs-Portal-2.0-ComTheme/forge/portal-extensions/jbosswiki/forge-wiki/src/java/org/jboss/wiki/WikiPortlet.java 2006-05-04 22:25:33 UTC (rev 4095) @@ -23,22 +23,29 @@ import java.io.File; import java.io.FileInputStream; +import java.io.UnsupportedEncodingException; import java.util.Date; +import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; -import javax.portlet.*; +import javax.portlet.ActionRequest; +import javax.portlet.ActionResponse; +import javax.portlet.GenericPortlet; +import javax.portlet.PortletException; +import javax.portlet.RenderRequest; +import javax.portlet.RenderResponse; +import org.apache.commons.fileupload.FileItem; +import org.apache.commons.fileupload.FileUploadException; +import org.apache.commons.fileupload.PortletDiskFileUpload; import org.jboss.logging.Logger; import org.jboss.wiki.exceptions.EditSessionExpired; import org.jboss.wiki.exceptions.EditingNotAllowedException; import org.jboss.wiki.exceptions.WikiManagementNotFoundException; import org.jboss.wiki.exceptions.WikiSaveException; import org.jboss.wiki.management.WikiServiceMenagement; -import org.apache.commons.fileupload.PortletDiskFileUpload; -import org.apache.commons.fileupload.FileUploadException; -import org.apache.commons.fileupload.FileItem; /** * The WikiPortlet. @@ -76,8 +83,35 @@ } } + private Map<String, String> convertParameters(ActionRequest rReq) { + Map<String, String> convertedParameters = new HashMap<String, String>(); + + Map paramMap = rReq.getParameterMap(); + + for (Object key : paramMap.keySet()) { + try { + if (rReq.getParameter("editAction") != null) { + convertedParameters.put((String) key, new String(rReq + .getParameter((String) key).getBytes("ISO-8859-1"), + "UTF-8")); + } else { + convertedParameters.put((String) key, rReq + .getParameter((String) key)); + } + } catch (UnsupportedEncodingException e) { + log.error(e); + convertedParameters.put((String) key, (String) paramMap + .get(key)); + } + } + + return convertedParameters; + } + public void processAction(ActionRequest rReq, ActionResponse rResp) { + Map<String, String> convertedParameters = convertParameters(rReq); + Credentials credentials = wikiEngine.getCredentialsInstance(rReq); // wikiContext is null - to get refernece to actual page @@ -145,9 +179,9 @@ log.info("serverFileName : " + tempDir + "/" + serverFileName + " filename: " + fileName); - WikiPage pageWithAtt = wikiEngine.getByName(rReq - .getParameter("page"), null, (String) rReq - .getParameter("language")); + WikiPage pageWithAtt = wikiEngine.getByName( + convertedParameters.get("page"), null, + (String) convertedParameters.get("language")); FileInputStream fis = new FileInputStream(serverFile); @@ -169,9 +203,10 @@ } } - if (rReq.getParameter("page") != null - && (rReq.getParameter("page").length() > 0)) { - StringBuffer sBuf = new StringBuffer(rReq.getParameter("page")); + if (convertedParameters.get("page") != null + && (convertedParameters.get("page").length() > 0)) { + StringBuffer sBuf = new StringBuffer(convertedParameters + .get("page")); if (Character.isLowerCase(sBuf.charAt(0))) { // change first letter to upper if it isn't @@ -194,10 +229,10 @@ } - if (rReq.getParameter("searchQuery") != null) { - Map<String, Integer> pages = wikiEngine.findPages(rReq - .getParameter("searchQuery"), (String) rReq - .getParameter("language")); + if (convertedParameters.get("searchQuery") != null) { + Map<String, Integer> pages = wikiEngine.findPages( + convertedParameters.get("searchQuery"), + (String) convertedParameters.get("language")); rReq.getPortletSession().setAttribute("findResult", pages); @@ -207,63 +242,66 @@ int i = 1; - while (rReq.getParameter("var" + i) != null) { + while (convertedParameters.get("var" + i) != null) { rReq.getPortletSession().setAttribute("var" + i, - rReq.getParameter("var" + i)); + convertedParameters.get("var" + i)); i++; } - if (rReq.getParameter("action") != null) { - rResp.setRenderParameter("action", rReq.getParameter("action")); + if (convertedParameters.get("action") != null) { + rResp.setRenderParameter("action", convertedParameters + .get("action")); } - if (rReq.getParameter("type") != null) { - rResp.setRenderParameter("type", rReq.getParameter("type")); + if (convertedParameters.get("type") != null) { + rResp.setRenderParameter("type", convertedParameters.get("type")); } - if (rReq.getParameter("version") != null) { + if (convertedParameters.get("version") != null) { log.info("[process action]Getting page " - + rReq.getParameter("page") + " at version " - + rReq.getParameter("version")); - rResp.setRenderParameter("version", rReq.getParameter("version")); + + convertedParameters.get("page") + " at version " + + convertedParameters.get("version")); + rResp.setRenderParameter("version", convertedParameters + .get("version")); } - if (rReq.getParameter("language") != null) { - rResp.setRenderParameter("language", (String) rReq - .getParameter("language")); + if (convertedParameters.get("language") != null) { + rResp.setRenderParameter("language", (String) convertedParameters + .get("language")); } else { rResp.setRenderParameter("language", wikiEngine.defaultLangugeCode); } - if (rReq.getParameter("editAction") != null) { + if (convertedParameters.get("editAction") != null) { log.debug("EDITING PAGE"); + String editedPageName = convertedParameters.get("editedPage"); + // unlock page - WikiPage edPage = wikiEngine.getByName((String) rReq - .getParameter("editedPage"), wikiContext, (String) rReq - .getParameter("language")); + WikiPage edPage = wikiEngine.getByName(editedPageName, wikiContext, + (String) convertedParameters.get("language")); if (edPage != null) { // it may be null if the page isn't saved // yet - edPage.unlock(credentials, Integer.valueOf((String) rReq - .getParameter("editSessionId"))); + edPage.unlock(credentials, Integer + .valueOf((String) convertedParameters + .get("editSessionId"))); } // saving, previewing or canceling - if (rReq.getParameter("editAction").equals("Save")) { + if (convertedParameters.get("editAction").equals("Save")) { // save the page if (edPage == null) { - edPage = new WikiPage(rReq.getParameter("editedPage"), - credentials, "", 0, 0, new Date(), wikiEngine, - true, true, null, null, 0, (String) rReq - .getParameter("language")); + edPage = new WikiPage(editedPageName, credentials, "", 0, + 0, new Date(), wikiEngine, true, true, null, null, + 0, (String) convertedParameters.get("language")); } // set new content - edPage.setContent(rReq.getParameter("wikiContent")); + edPage.setContent(convertedParameters.get("wikiContent")); // set author name for new version edPage.setLastAuthor(credentials); @@ -276,9 +314,10 @@ // save the page try { - edPage.save(credentials, Integer.valueOf((String) rReq - .getParameter("editSessionId")), (String) rReq - .getParameter("language")); + edPage.save(credentials, Integer + .valueOf((String) convertedParameters + .get("editSessionId")), + (String) convertedParameters.get("language")); } catch (NumberFormatException e) { log.error(e); } catch (EditSessionExpired e) { @@ -577,7 +616,7 @@ if (javax.portlet.WindowState.NORMAL.equals(rReq.getWindowState()) || javax.portlet.WindowState.MAXIMIZED.equals(rReq .getWindowState())) { - rRes.setContentType("text/html"); + rRes.setContentType("text/html; charset=UTF-8"); javax.portlet.PortletRequestDispatcher pRD = this .getPortletContext().getRequestDispatcher( jspPath + page); Modified: labs/jbosslabs/branches/Labs-Portal-2.0-ComTheme/forge/portal-extensions/jbosswiki/forge-wiki/src/java/org/jboss/wiki/fileaccess/WikiFileAccessFilter.java =================================================================== --- labs/jbosslabs/branches/Labs-Portal-2.0-ComTheme/forge/portal-extensions/jbosswiki/forge-wiki/src/java/org/jboss/wiki/fileaccess/WikiFileAccessFilter.java 2006-05-04 18:16:20 UTC (rev 4094) +++ labs/jbosslabs/branches/Labs-Portal-2.0-ComTheme/forge/portal-extensions/jbosswiki/forge-wiki/src/java/org/jboss/wiki/fileaccess/WikiFileAccessFilter.java 2006-05-04 22:25:33 UTC (rev 4095) @@ -25,6 +25,8 @@ import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; +import java.net.URLDecoder; +import java.net.URLEncoder; import java.util.Properties; import javax.activation.MimetypesFileTypeMap; @@ -40,7 +42,7 @@ import javax.servlet.http.HttpServletResponse; import org.jboss.logging.Logger; -import org.jboss.wiki.FileDataSource; +import org.jboss.wiki.FileMediaDataSource; import org.jboss.wiki.ServletWikiSession; import org.jboss.wiki.SimpleCredentials; import org.jboss.wiki.WikiAttachment; @@ -53,8 +55,6 @@ import org.jboss.wiki.exceptions.WikiManagementNotFoundException; import org.jboss.wiki.management.WikiServiceMenagement; -// import org.jboss.forge.common.content.ContentManager; -// import org.jboss.forge.common.ForgeHelper; /** * A filter that enables to download files form the jspwiki structure + @@ -110,7 +110,7 @@ Properties props = new Properties(); try { - props.load(FileDataSource.class + props.load(FileMediaDataSource.class .getResourceAsStream("filedatasource.properties")); // get the path to attachment property @@ -148,8 +148,10 @@ + request.getServerPort()); wikiSession.setAttribute("hostURL", hostURL); - String requestURI = httpRequest.getRequestURI(); + String requestURI = URLDecoder.decode(httpRequest.getRequestURI(), + "UTF-8"); + // get off "/wiki/" from the begining requestURI = requestURI.substring("/wiki/".length()); @@ -188,31 +190,36 @@ } // check if user is browsing different then default language - if (wikiEngine.getUsedLanguageCodes().containsKey(tokens[0].toUpperCase())) { + if (wikiEngine.getUsedLanguageCodes().containsKey( + tokens[0].toUpperCase())) { langCode = tokens[0].toUpperCase(); // redo tokens but without language - if (requestURI.startsWith(tokens[0]+ "/")) { - requestURI = requestURI.substring((tokens[0] + "/").length()); - } - else { + if (requestURI.startsWith(tokens[0] + "/")) { + requestURI = requestURI.substring((tokens[0] + "/") + .length()); + } else { requestURI = requestURI.substring((tokens[0]).length()); } - + tokens = requestURI.split("[/]"); - + if ((tokens.length == 1) && (tokens[0].equals(""))) { // show Main page - as there is no place to go specified :) - httpResponse.sendRedirect(hostURL + wikiHome + "&language=" + langCode); + httpResponse.sendRedirect(hostURL + wikiHome + "&language=" + + langCode); return; } } - + // check if all tokens are UpperCase (meanins they are all wiki // pages) boolean isAllUpperCase = true; for (int i = 0; i < tokens.length; i++) - if (!Character.isUpperCase(tokens[i].charAt(0))) { + // uppercase or UTF character + if (!(Character.isUpperCase(tokens[i].charAt(0)) || (tokens[i] + .charAt(0) > 127 && Character.isLetter(tokens[i] + .charAt(0))))) { isAllUpperCase = false; break; } @@ -221,14 +228,16 @@ String pageName = ""; for (int i = 0; i < tokens.length; i++) { - pageName += "/" + tokens[i]; + pageName += "/" + URLEncoder.encode(tokens[i], "UTF-8"); } - if (Character.isUpperCase(tokens[tokens.length - 1].charAt(0))) { + if (Character.isUpperCase(tokens[tokens.length - 1].charAt(0)) + || (tokens[tokens.length - 1].charAt(0) > 127 && Character + .isLetter(tokens[tokens.length - 1].charAt(0)))) { httpResponse.sendRedirect(hostURL + wikiHome + "&page=" + pageName.substring(1) + ((version != -1) ? "&version=" + version : "") - + "&language="+langCode); + + "&language=" + langCode); } else { PrintWriter out = httpResponse.getWriter(); httpResponse.setContentType("text/html"); @@ -297,17 +306,16 @@ httpResponse.setContentLength(page.getPageContent() .length()); - + httpResponse.getWriter().print(page.getPageContent()); httpResponse.getWriter().flush(); } else { // show error response httpResponse.setContentType("text/html"); - httpResponse - .getWriter() - .println( - "<html><body><h3>ERROR</h3><br />\nThere is no such wikiType: "+wikiTypeName+"</body></html>"); + httpResponse.getWriter().println( + "<html><body><h3>ERROR</h3><br />\nThere is no such wikiType: " + + wikiTypeName + "</body></html>"); } } else { httpResponse.setContentType("text/html"); Modified: labs/jbosslabs/branches/Labs-Portal-2.0-ComTheme/forge/portal-extensions/jbosswiki/forge-wiki/src/web/WEB-INF/jsp/Edit.jsp =================================================================== --- labs/jbosslabs/branches/Labs-Portal-2.0-ComTheme/forge/portal-extensions/jbosswiki/forge-wiki/src/web/WEB-INF/jsp/Edit.jsp 2006-05-04 18:16:20 UTC (rev 4094) +++ labs/jbosslabs/branches/Labs-Portal-2.0-ComTheme/forge/portal-extensions/jbosswiki/forge-wiki/src/web/WEB-INF/jsp/Edit.jsp 2006-05-04 22:25:33 UTC (rev 4095) @@ -3,7 +3,7 @@ Distributable under LGPL license. See terms of license at gnu.org. --> - +<%@ page language="java" extends="org.jboss.portal.core.servlet.jsp.PortalJsp" pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%> <%@ page isELIgnored ="false" %> <% Modified: labs/jbosslabs/branches/Labs-Portal-2.0-ComTheme/forge/portal-extensions/jbosswiki/forge-wiki/src/web/WEB-INF/jsp/PageInfo.jsp =================================================================== --- labs/jbosslabs/branches/Labs-Portal-2.0-ComTheme/forge/portal-extensions/jbosswiki/forge-wiki/src/web/WEB-INF/jsp/PageInfo.jsp 2006-05-04 18:16:20 UTC (rev 4094) +++ labs/jbosslabs/branches/Labs-Portal-2.0-ComTheme/forge/portal-extensions/jbosswiki/forge-wiki/src/web/WEB-INF/jsp/PageInfo.jsp 2006-05-04 22:25:33 UTC (rev 4095) @@ -3,7 +3,7 @@ Distributable under LGPL license. See terms of license at gnu.org. --> - +<%@ page language="java" extends="org.jboss.portal.core.servlet.jsp.PortalJsp" contentType="text/html; charset=UTF-8"%> <%@ page isELIgnored ="false" %> <% Modified: labs/jbosslabs/branches/Labs-Portal-2.0-ComTheme/forge/portal-extensions/jbosswiki/forge-wiki/src/web/WEB-INF/jsp/Wiki.jsp =================================================================== --- labs/jbosslabs/branches/Labs-Portal-2.0-ComTheme/forge/portal-extensions/jbosswiki/forge-wiki/src/web/WEB-INF/jsp/Wiki.jsp 2006-05-04 18:16:20 UTC (rev 4094) +++ labs/jbosslabs/branches/Labs-Portal-2.0-ComTheme/forge/portal-extensions/jbosswiki/forge-wiki/src/web/WEB-INF/jsp/Wiki.jsp 2006-05-04 22:25:33 UTC (rev 4095) @@ -3,6 +3,7 @@ Distributable under LGPL license. See terms of license at gnu.org. --> +<%@ page language="java" extends="org.jboss.portal.core.servlet.jsp.PortalJsp" contentType="text/html; charset=UTF-8"%> <%@ page isELIgnored ="false" %> <% Modified: labs/jbosslabs/branches/Labs-Portal-2.0-ComTheme/forge/portal-extensions/jbosswiki/wiki-common/project.xml =================================================================== --- labs/jbosslabs/branches/Labs-Portal-2.0-ComTheme/forge/portal-extensions/jbosswiki/wiki-common/project.xml 2006-05-04 18:16:20 UTC (rev 4094) +++ labs/jbosslabs/branches/Labs-Portal-2.0-ComTheme/forge/portal-extensions/jbosswiki/wiki-common/project.xml 2006-05-04 22:25:33 UTC (rev 4095) @@ -9,6 +9,7 @@ <extend>../common.xml</extend> <id>wiki-common</id> <name>Wiki common</name> + <currentVersion>1.0</currentVersion> <build> <!-- <unitTestSourceDirectory>./src/test/java</unitTestSourceDirectory> Modified: labs/jbosslabs/branches/Labs-Portal-2.0-ComTheme/forge/portal-extensions/jbosswiki/wiki-common/src/etc/CountryCodes.xml =================================================================== --- labs/jbosslabs/branches/Labs-Portal-2.0-ComTheme/forge/portal-extensions/jbosswiki/wiki-common/src/etc/CountryCodes.xml 2006-05-04 18:16:20 UTC (rev 4094) +++ labs/jbosslabs/branches/Labs-Portal-2.0-ComTheme/forge/portal-extensions/jbosswiki/wiki-common/src/etc/CountryCodes.xml 2006-05-04 22:25:33 UTC (rev 4095) @@ -1,3 +1,5 @@ +<?xml version="1.0" encoding="UTF-8"?> + <countries> <country> <description>Afar</description> Modified: labs/jbosslabs/branches/Labs-Portal-2.0-ComTheme/forge/portal-extensions/jbosswiki/wiki-common/src/etc/JBossWiki.properties =================================================================== --- labs/jbosslabs/branches/Labs-Portal-2.0-ComTheme/forge/portal-extensions/jbosswiki/wiki-common/src/etc/JBossWiki.properties 2006-05-04 18:16:20 UTC (rev 4094) +++ labs/jbosslabs/branches/Labs-Portal-2.0-ComTheme/forge/portal-extensions/jbosswiki/wiki-common/src/etc/JBossWiki.properties 2006-05-04 22:25:33 UTC (rev 4095) @@ -12,15 +12,15 @@ credentialsClass=org.jboss.wiki.JBossPortalCredentials #mediaDataSourceClass class to use for mediaDataSource -mediaDataSourceClass=org.jboss.wiki.FileDataSource +mediaDataSourceClass=org.jboss.wiki.FileMediaDataSource #mediaDataSourceClass=org.jboss.wiki.ShotokuMediaDataSource #attachmentDataSourceClass class to use for AttachmentDataSource -attachmentDataSourceClass=org.jboss.wiki.FileDataSource +attachmentDataSourceClass=org.jboss.wiki.FileAttachmentDataSource #attachmentDataSourceClass=org.jboss.wiki.ShotokuAttachmentDataSource #wikiPageDictionaryClass class to use for WikiPageDictionary -wikiPageDictionaryClass=org.jboss.wiki.FileDataSource +wikiPageDictionaryClass=org.jboss.wiki.FileWikiPageDictionary #wikiPageDictionaryClass=org.jboss.wiki.ShotokuWikiPageDictionary #defaultLanguageCode - country letter of the default code language Modified: labs/jbosslabs/branches/Labs-Portal-2.0-ComTheme/forge/portal-extensions/jbosswiki/wiki-common/src/etc/WikiTypes.xml =================================================================== --- labs/jbosslabs/branches/Labs-Portal-2.0-ComTheme/forge/portal-extensions/jbosswiki/wiki-common/src/etc/WikiTypes.xml 2006-05-04 18:16:20 UTC (rev 4094) +++ labs/jbosslabs/branches/Labs-Portal-2.0-ComTheme/forge/portal-extensions/jbosswiki/wiki-common/src/etc/WikiTypes.xml 2006-05-04 22:25:33 UTC (rev 4095) @@ -1,3 +1,4 @@ +<?xml version="1.0" encoding="UTF-8"?> <!-- JBoss, the OpenSource J2EE webOS Distributable under LGPL license. @@ -3,5 +4,4 @@ See terms of license at gnu.org. --> - <wikiTypes> <wikiType> Copied: labs/jbosslabs/branches/Labs-Portal-2.0-ComTheme/forge/portal-extensions/jbosswiki/wiki-common/src/etc/countryCodes.dtd (from rev 4094, labs/jbosslabs/trunk/portal-extensions/jbosswiki/wiki-common/src/etc/countryCodes.dtd) Copied: labs/jbosslabs/branches/Labs-Portal-2.0-ComTheme/forge/portal-extensions/jbosswiki/wiki-common/src/etc/wikiTypes.dtd (from rev 4094, labs/jbosslabs/trunk/portal-extensions/jbosswiki/wiki-common/src/etc/wikiTypes.dtd) Copied: labs/jbosslabs/branches/Labs-Portal-2.0-ComTheme/forge/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/FileAttachmentDataSource.java (from rev 4094, labs/jbosslabs/trunk/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/FileAttachmentDataSource.java) Copied: labs/jbosslabs/branches/Labs-Portal-2.0-ComTheme/forge/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/FileDSCommons.java (from rev 4094, labs/jbosslabs/trunk/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/FileDSCommons.java) Deleted: labs/jbosslabs/branches/Labs-Portal-2.0-ComTheme/forge/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/FileDataSource.java =================================================================== --- labs/jbosslabs/branches/Labs-Portal-2.0-ComTheme/forge/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/FileDataSource.java 2006-05-04 18:16:20 UTC (rev 4094) +++ labs/jbosslabs/branches/Labs-Portal-2.0-ComTheme/forge/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/FileDataSource.java 2006-05-04 22:25:33 UTC (rev 4095) @@ -1,1400 +0,0 @@ -/* - * JBoss, Home of Professional Open Source - * Copyright 2005, JBoss Inc., and individual contributors as indicated - * by the @authors tag. See the copyright.txt in the distribution for a - * full listing of individual contributors. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.jboss.wiki; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.Date; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Properties; -import java.util.Set; -import java.util.TreeMap; -import java.util.TreeSet; - -import org.jboss.logging.Logger; -import org.jboss.wiki.exceptions.DataSourceException; -import org.jboss.wiki.exceptions.PageRenamingException; -import org.jboss.wiki.exceptions.WikiSaveException; - -/** - * <p> - * </p> - * - */ -public class FileDataSource implements MediaDataSource, AttachmentDataSource, - WikiPageDictionary { - - /** - * <p> - * Represents ... - * </p> - * - */ - private final static String SAVE_COMMENT = "Saved by FileDataSource of JBoss Wiki"; - - private final static String OTHER_LANG_DIR = "LANG/"; - - private final static String LANG_FILE = "languages.properties"; - - public static final String propFileName = "filedatasource.properties"; - - public static final String propModFileName = "fileMod.properties"; - - public String pathToMediaTrash; - - public String pathToAttTrash; - - private String pathToMedia; - - private String pathToAttachments; - - private boolean lock = false; - - // private Properties fileDSProps; - - private final int BUF_SIZE = 32768; - - private Properties pageModProps; - - private Properties pageDictionary; - - private Properties pageRevDictionary; - - private File modFile; - - private File pageDictionaryFile; - - private WikiEngine wikiEngine; - - private Logger log; - - private String langCode = null; - - public void setWikiEngine(WikiEngine wikiEngine) { - this.wikiEngine = wikiEngine; - - if (langCode == null) - langCode = wikiEngine.defaultLangugeCode; - } - - public FileDataSource() { - init(""); - } - - private void init(String prefix) { - log = Logger.getLogger(FileDataSource.class); - - log.info("Looking for props file !"); - - Properties fileDSProps = new Properties(); - - try { - - fileDSProps.load(FileDataSource.class - .getResourceAsStream(propFileName)); - - } catch (IOException ioe) { - log.error("Can't load the file " + propFileName + "\n", ioe); - } - - loadProperties(fileDSProps, prefix); - - File mainWikiDir = new File(pathToMedia); - File attWikiDir = new File(pathToAttachments); - - if (!mainWikiDir.exists()) - mainWikiDir.mkdirs(); - - if (!attWikiDir.exists()) - attWikiDir.mkdirs(); - - pageModProps = new Properties(); - modFile = new File(pathToMedia + "/" + propModFileName); - - FileInputStream fis = null; - - try { - if (!modFile.exists()) { - modFile.createNewFile(); - } - - fis = new FileInputStream(modFile); - - pageModProps.load(fis); - - } catch (IOException ioe) { - log.error("Can't load the file " + propModFileName + "\n", ioe); - } finally { - try { - fis.close(); - } catch (IOException ioe) { - log.error("Can't close input stream \n", ioe); - } - } - - // create trash directory for deleted pages if it doesn't exists - - pathToMediaTrash = pathToMedia + "/" + MediaDataSource.mediaTrashName; - - File pathToTrashFile = new File(pathToMediaTrash + "/OLD"); - - if (!pathToTrashFile.exists()) { - pathToTrashFile.mkdirs(); - } - - // create trash directory for deleted attachments if it doesn't exists - - pathToAttTrash = pathToMedia + "/" + AttachmentDataSource.attTrashName; - - File pathToAttachmentsFile = new File(pathToAttTrash); - - if (!pathToAttachmentsFile.exists()) { - pathToAttachmentsFile.mkdirs(); - } - - // load dictionary props - pageDictionary = new Properties(); - pageRevDictionary = new Properties(); - - // TODO Do not load dictionary YET ! - - pageDictionaryFile = new File(pathToMedia + "/dictionary.properties"); - - if (!pageDictionaryFile.exists()) { - try { - pageDictionaryFile.createNewFile(); - } catch (IOException e) { - log.error("Cannot create dictionary file: ", e); - } - } else { - // there is dictionary file. Load props from it - FileInputStream is; - try { - is = new FileInputStream(pageDictionaryFile); - - try { - pageDictionary.load(is); - } catch (IOException e) { - e.printStackTrace(); - } - - try { - is.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } catch (FileNotFoundException e) { - e.printStackTrace(); - } - - } - - // create pageRevDictionary - to make it work faster - - Set<Object> keys = pageDictionary.keySet(); - - for (Object key : keys) { - pageRevDictionary.setProperty(pageDictionary - .getProperty((String) key), (String) key); - } - } - - public void loadProperties(Properties fileDSProps, String prefix) { - if (fileDSProps.getProperty("pathToMedia") != null) { - pathToMedia = fileDSProps.getProperty("pathToMedia") - + (prefix.length() > 0 ? "/" + prefix : ""); - log.info("Path to media is: " + pathToMedia); - pathToAttachments = fileDSProps.getProperty("pathToAttachements") - + (prefix.length() > 0 ? "/" + prefix : ""); - log.info("Path to attachements is: " + pathToAttachments); - } else { - System.err - .println("Your properties file lacks of pathToMedia property. It will not run properly ! Please update " - + propFileName); - } - } - - public void preSave() throws WikiSaveException { - // do nothing - } - - public void savePage(String uid, WikiPage page) throws WikiSaveException { - - if (pageExists(uid)) { // page exists on - // harddisk - add new - // version - Properties pageProps = getPageProps(uid); - - pageProps.setProperty(page.getLastVersion() + ".author", page - .getLastAuthor().getName()); - - try { - pageProps.store(new FileOutputStream(new File(pathToMedia - + "/OLD/" + uid + "/page.properties")), - "Saved by FileDataSource of JBoss Wiki"); - } catch (Exception e) { - throw new WikiSaveException(e); - } - - log.info("Opening files"); - File pageFile = new File(pathToMedia + "/OLD/" + uid + "/" - + (page.getLastVersion() - 1) + ".txt"); - File pageOldFile = new File(pathToMedia + "/" + uid + ".txt"); - - FileOutputStream pageFileWriter; - FileInputStream pageFileReader; - - try { - pageFileWriter = new FileOutputStream(pageFile); - pageFileReader = new FileInputStream(pageOldFile); - - int b; - - while ((b = pageFileReader.read()) != -1) { - pageFileWriter.write(b); - } - - pageFile.setLastModified(pageOldFile.lastModified()); - - pageFileWriter.close(); - - pageOldFile.delete(); - - pageFileWriter = new FileOutputStream(pageOldFile); - - String pageContent = page.getContent(); - - for (int i = 0; i < pageContent.length(); i++) { - pageFileWriter.write((int) pageContent.charAt(i)); - } - - pageFileWriter.close(); - } catch (FileNotFoundException fnfe) { - throw new WikiSaveException(fnfe); - } catch (IOException ioe) { - throw new WikiSaveException(ioe); - } - - } else { // there is no page on disk. We have to create new one. - - try { - - // create needed dirs - File newPageFile = new File(pathToMedia + "/OLD/" + uid); - newPageFile.mkdirs(); - - // write the page - newPageFile = new File(pathToMedia + "/OLD/" + uid - + "/page.properties"); - - FileOutputStream pageWriter = new FileOutputStream(newPageFile); - - Properties properties = new Properties(); - properties.setProperty(page.getLastVersion() + ".author", page - .getLastAuthor().getName()); - - properties.store(pageWriter, SAVE_COMMENT); - - pageWriter.close(); - - String pageDirName = pathToMedia; - String[] pageNames = uid.split("/"); - - for (int i = 0; i < pageNames.length - 1; i++) { - pageDirName += "/" + pageNames[i]; - } - - File pageDir = new File(pageDirName); - - pageDir.mkdirs(); - - pageWriter = new FileOutputStream(new File(pathToMedia + "/" - + uid + ".txt")); - - String pageContent = page.getContent(); - - for (int i = 0; i < pageContent.length(); i++) { - pageWriter.write((int) pageContent.charAt(i)); - } - - pageWriter.close(); - - } catch (Exception e) { - throw new WikiSaveException(e); - } - } - - } - - public void postSave() throws WikiSaveException { - // do nothing - } - - public boolean preGet() { - return true; - } - - public Properties getPageProps(String pageName) { - Properties pageProps = new Properties(); - - try { - FileInputStream fpi = new FileInputStream(new File(pathToMedia - + "/OLD/" + pageName + "/page.properties")); - pageProps.load(fpi); - fpi.close(); - } catch (IOException ioe) { - // There is no prop file for some reson - create one. - - File pagePropsFile = new File(pathToMedia + "/OLD/" + pageName); - - // create dirs - pagePropsFile.mkdirs(); - - // create file - pagePropsFile = new File(pathToMedia + "/OLD/" + pageName - + "/page.properties"); - - try { - pagePropsFile.createNewFile(); - - if (pageExists(pageName)) { - // if page exists it looks like there is lack of the props - // structure - FileOutputStream fpo = new FileOutputStream(pagePropsFile); - - pageProps.setProperty("1.author", "unknown"); - pageProps.store(fpo, SAVE_COMMENT); - fpo.close(); - } - - } catch (IOException e) { - log.error( - "Cannot create page props file for page: " + pageName, - e); - } - return pageProps; - } - - return pageProps; - } - - public Properties getAttProps(String pageName, String attName, - boolean createProps) { - Properties attProps = new Properties(); - - File propFile = new File(pathToAttachments + "/" + pageName + "-att/" - + attName + "-dir/"); - - if (!propFile.exists()) { - - if (createProps) { - // create dirs for this property file - propFile.mkdirs(); - } else { - return null; - } - } - - propFile = new File(pathToAttachments + "/" + pageName + "-att/" - + attName + "-dir/attachment.properties"); - - try { - attProps.load(new FileInputStream(propFile)); - } catch (IOException ioe) { - System.err - .println("Cannot read attachment.properties for attachement: " - + pathToAttachments - + "/" - + pageName - + "-att/" - + attName + "-dir/attachment.properties\n" + ioe); - } - - return attProps; - } - - public void saveAttProps(Properties props, String pageName, String attName) { - try { - props.store(new FileOutputStream(new File(pathToAttachments + "/" - + pageName + "-att/" + attName - + "-dir/attachment.properties")), SAVE_COMMENT); - } catch (Exception ioe) { - System.err - .println("Cannot store attchement.properties for attachement: " - + pathToAttachments - + "/" - + pageName - + "-att/" - + attName + "-dir/attachments.properties\n" + ioe); - } - - } - - public void saveRolesSet(String uid, Set<String> roles, int action) - throws DataSourceException { - File rolesFile; - try { - rolesFile = getRolesFile(uid, action); - - if (rolesFile == null) - throw new DataSourceException("Wrong action number"); - - } catch (IOException e) { - throw new DataSourceException(e); - } - - FileOutputStream fos = null; - try { - fos = new FileOutputStream(rolesFile); - - Properties roleProps = new Properties(); - - int i = 1; - - for (String roleName : roles) { - roleProps.setProperty("Role." + i++, roleName); - } - - roleProps.store(fos, SAVE_COMMENT); - - fos.close(); - } catch (FileNotFoundException e) { - throw new DataSourceException(e); - } catch (IOException e) { - try { - fos.close(); - } catch (IOException e1) { - throw new DataSourceException(e); - } - throw new DataSourceException(e); - } - - } - - private File getRolesFile(String uid, int action) throws IOException { - String fileName = (action == MediaDataSource.EDITABLE) ? "editRoles" - : (action == MediaDataSource.VIEWABLE) ? "viewRoles" : null; - - if (fileName == null) - return null; - - File rolesFile = new File(pathToMedia + "/OLD/" + uid + "/" + fileName - + ".properties"); - - if (!rolesFile.exists()) { - rolesFile.createNewFile(); - } - - return rolesFile; - } - - private Set<String> getRoles(String uid, int action) throws IOException { - Set<String> set = new TreeSet<String>(); - - File rolesFile = getRolesFile(uid, action); - - if (rolesFile == null) - return null; - - FileInputStream rolesFileIs = new FileInputStream(rolesFile); - - Properties roleProps = new Properties(); - - roleProps.load(rolesFileIs); - - int i = 1; - - while (roleProps.getProperty("Role." + i) != null) { - set.add(roleProps.getProperty("Role." + i)); - i++; - } - - rolesFileIs.close(); - - return set; - } - - public WikiPage getPage(String pageName) { - // log.info("[WIKI:FileDataSource]: Getting new page: " + - // pageName); - - WikiPage page = null; - - File pageFile = new File(pathToMedia + "/" + pageName + ".txt"); - - if (pageFile.exists()) { - - Properties pageProps = getPageProps(pageName); - - if (pageProps != null) { - - int i = 1; - - // get the author of the latest version of page - while (pageProps.getProperty(String.valueOf(i + 1) + ".author") != null) { - i++; - } - - Credentials author = new SimpleCredentials(pageProps - .getProperty(String.valueOf(i) + ".author")); - - StringBuilder pageContent = new StringBuilder(); - - try { - FileInputStream input = new FileInputStream(pageFile); - - int nextChr = input.read(); - - while (nextChr != -1) { - pageContent.append((char) nextChr); - nextChr = input.read(); - } - } catch (IOException ioe) { - log.error(ioe); - } - - Set<String> viewRoles = null; - Set<String> editRoles = null; - - try { - editRoles = (getRoles(pageName, EDITABLE)); - } catch (IOException e) { - log.error("Couldn't read edit roles for page: " + pageName, - e); - } - try { - viewRoles = (getRoles(pageName, VIEWABLE)); - } catch (IOException e) { - log.error("Couldn't read view roles for page: " + pageName, - e); - } - - int pageMods = getPageMod(pageName); - - page = new WikiPage(pageName, author, pageContent.toString(), - i, i, new Date(pageFile.lastModified()), wikiEngine, - (pageMods & VIEWABLE) == VIEWABLE, - (pageMods & EDITABLE) == EDITABLE, editRoles, - viewRoles, pageFile.length(), langCode); - } - } - - // get Metadata props. - if (page != null) // page exists at all - page.setMetaDataProps(getMetadataProps(pageName)); - - return page; - - } - - public boolean postGet() { - return true; - } - - public WikiPage getPage(String pageName, String languageCode) { - if (languageCode != null) { - log - .info("As for now, languages aren't supported in the wiki. Please do not use language codes"); - } - return getPage(pageName); - } - - public WikiPage getPageAtVersion(WikiPage originPage, String uid, - boolean loadContent, int version) { - - /* - * Calendar cal = Calendar.getInstance(); cal.setTime(new Date()); long - * oldMilis = cal.getTimeInMillis(); - */ - - WikiPage page = null; - - try { - page = (WikiPage) originPage.clone(); - } catch (CloneNotSupportedException e) { - log.error(e); - } - - if (page != null) { - if (page.getLastVersion() < version) { - log.info("There is no version " + version + " of page " - + page.getName()); - return null; - } - - getContentAtVersion(page, uid, loadContent, version); - - page.setLastAuthor(getAuthorAtVersion(uid, version)); - - page.setVersion(version); - - page.setEditDate(getDateAtVersion(uid, version)); - - } - - /* - * cal.setTime(new Date()); - * - * log.info("PAGE "+page.getName()+" loaded in: "+(cal.getTimeInMillis() - - * oldMilis)); - */ - return page; - } - - public void getContentAtVersion(WikiPage page, String uid, - boolean loadContent, int version) { - StringBuilder ret = null; - - File pageFile = new File(pathToMedia + "/OLD/" + uid + "/" + version - + ".txt"); - - if (loadContent) { - try { - FileInputStream input = new FileInputStream(pageFile); - - int nextChr = input.read(); - - ret = new StringBuilder(); - - while (nextChr != -1) { - ret.append((char) nextChr); - nextChr = input.read(); - } - - page.setContent(ret.toString()); - page.setLength(ret.length()); - - } catch (IOException ioe) { - log.error(ioe); - } - } else { - page.setLength(pageFile.length()); - page.setContent(null); - } - - } - - public Date getDateAtVersion(String pageName, int version) { - Date ret = null; - - File pageFile = new File(pathToMedia + "/OLD/" + pageName + "/" - + version + ".txt"); - - ret = new Date(pageFile.lastModified()); - - return ret; - } - - public Credentials getAuthorAtVersion(String pageName, int version) { - return new SimpleCredentials(getPageProps(pageName).getProperty( - version + ".author")); - } - - public boolean pageExists(String pageName) { - - File pageFile = new File(pathToMedia + "/" + pageName + ".txt"); - - if (pageFile.exists()) { - return true; - } else { - return false; - } - } - - public void addAttachment(InputStream attFile, String attName, String uid, - String user) { - String pageName = uid; - Properties attProps = getAttProps(pageName, attName, true); - - int lastVersion = 1; - - if (attProps.size() > 0) { - // find last version of this file - while (attProps.getProperty(lastVersion + ".author") != null) { - lastVersion++; - } - } - - String[] extension = attName.split("\\."); - String fileName = pathToAttachments - + "/" - + pageName - + "-att/" - + attName - + "-dir/" - + lastVersion - + "." - + ((attName.indexOf('.') != -1) ? extension[extension.length - 1] - : "bin"); - - InputStream oldFile = null; - FileOutputStream newFile = null; - - try { - newFile = new FileOutputStream(new File(fileName)); - oldFile = attFile; - } catch (FileNotFoundException e) { - log.error(e); - } - - // writing old file to new one - try { - byte[] buffer = new byte[BUF_SIZE]; - int read; - while ((read = oldFile.read(buffer)) != -1) - newFile.write(buffer, 0, read); - } catch (Exception e2) { - // Nothing that we can really do. Just send an incomplete - // file. - } finally { - try { - newFile.close(); - oldFile.close(); - } catch (IOException e) { - log.error(e); - } - } - - attProps.setProperty(lastVersion + ".author", user); - - saveAttProps(attProps, pageName, attName); - } - - public Set<String> getAttachmentsSet(String uid) { - Set<String> attSet = new HashSet<String>(); - - File attDir = new File(pathToAttachments + "/" + uid + "-att"); - - if (attDir.exists() && (attDir.listFiles().length > 0)) { - File[] attachements = attDir.listFiles(); - - for (int i = 0; i < attachements.length; i++) { - if ((attachements[i].isDirectory()) - && (attachements[i].getName().endsWith("-dir"))) { - - String[] tokens = attachements[i].getName().split("/"); - attSet.add(tokens[tokens.length - 1].substring(0, - tokens[tokens.length - 1].length() - 4)); - - } - } - } else { - // page has no attachements - return null; - } - - return attSet; - } - - public Set<String> getAllPageNames() { - Set<String> attSet = new HashSet<String>(); - - getPageNamesFor("", attSet); - - return attSet; - } - - private void getPageNamesFor(String directory, Set<String> attSet) { - File attDir = new File(pathToMedia + "/" + directory); - - File[] pageFiles = attDir.listFiles(); - - for (int i = 0; i < pageFiles.length; i++) { - if ((pageFiles[i].isFile()) - && (pageFiles[i].getName().endsWith(".txt"))) { - // String[] tokens = pageFiles[i].getName().split("/"); - attSet.add((directory + "/" + pageFiles[i].getName().substring( - 0, pageFiles[i].getName().length() - ".txt".length())) - .substring(1)); - } - } - - for (int i = 0; i < pageFiles.length; i++) { - if ((pageFiles[i].isDirectory()) - && (!pageFiles[i].getName().endsWith("-att"))) { - - // do not take dirs from OLD, .svn and trash folders - if ((!pageFiles[i].getAbsolutePath().equals( - pathToMedia + "/OLD")) - && (!pageFiles[i].getAbsolutePath().equals( - pathToMedia + "/.svn")) - && (!pageFiles[i].getAbsolutePath().equals( - pathToMedia + "/" - + MediaDataSource.mediaTrashName)) - && (!pageFiles[i].getAbsolutePath().equals( - pathToMedia + "/" - + AttachmentDataSource.attTrashName)) - && (!pageFiles[i].getAbsolutePath().equals( - pathToMedia + "/" - + OTHER_LANG_DIR.substring(0, OTHER_LANG_DIR.length()-1)))) { - // get names for subpages - getPageNamesFor(directory + "/" + pageFiles[i].getName(), - attSet); - } - } - } - } - - public WikiAttachment getAttachment(String pageName, String attachementName) { - return getAttachment(pageName, attachementName, - getLastAttachmentVersion(pageName, attachementName)); - } - - public WikiAttachment getAttachment(String pageName, - String attachementName, int version) { - - String[] tokens = attachementName.split("\\."); - - Properties props = getAttProps(pageName, attachementName, false); - - if (props == null) { - return null; - } - - String user = props.getProperty(version + ".author"); - - File file = new File( - pathToAttachments - + "/" - + pageName - + "-att/" - + attachementName - + "-dir/" - + version - + "." - + ((attachementName.indexOf(".") != -1) ? tokens[tokens.length - 1] - : "bin")); - - FileInputStream fis; - try { - fis = new FileInputStream(file); - return new WikiAttachment(attachementName, new Date(file - .lastModified()), user, file.length(), fis, version); - } catch (FileNotFoundException e) { - e.printStackTrace(); - return null; - } - - } - - public int getLastAttachmentVersion(String pageName, String attachementName) { - - Properties props = getAttProps(pageName, attachementName, false); - - if (props == null) - return -1; - - // looking for the newest version - int version = 1; - - while (props.getProperty((version + 1) + ".author") != null) { - version++; - } - - return version; - } - - public long getAttachmentSize(String pageName, String attachementName, - int version) { - String[] tokens = attachementName.split("\\."); - - File file = new File( - pathToAttachments - + "/" - + pageName - + "-att/" - + attachementName - + "-dir/" - + version - + "." - + ((attachementName.indexOf(".") != -1) ? tokens[tokens.length - 1] - : "bin")); - - return file.length(); - } - - public Set<String> getPagesFor(String pageName) { - Set<String> pages = new TreeSet<String>(); - - File pageDir = new File(pathToMedia + "/" + pageName); - - if ((pageDir.exists()) && (pageDir.isDirectory())) { - getPagesInside(pageDir, pages, pageName); - } - - return pages; - } - - private void getPagesInside(File pageDir, Set<String> pages, String prefix) { - File[] subFiles = pageDir.listFiles(); - - for (int i = 0; i < subFiles.length; i++) { - if ((subFiles[i].isFile()) - && (subFiles[i].getName().endsWith(".txt"))) { - pages.add(prefix - + "/" - + subFiles[i].getName().substring( - 0, - subFiles[i].getName().length() - - ".txt".length())); - } else if (subFiles[i].isDirectory()) { - getPagesInside(subFiles[i], pages, prefix + "/" - + subFiles[i].getName()); - } - } - } - - public int getPageMod(String pageName) { - if (pageModProps.getProperty(pageName) == null) { - return (EDITABLE + VIEWABLE); - } else { - return Integer.valueOf(pageModProps.getProperty(pageName)); - } - } - - public synchronized void setPageMod(String pageName, int mods) { - - if (mods != (EDITABLE + VIEWABLE)) { - pageModProps.setProperty(pageName, String.valueOf(mods)); - } else { - pageModProps.remove(pageName); - } - - FileOutputStream fos = null; - - try { - fos = new FileOutputStream(modFile); - pageModProps.store(fos, SAVE_COMMENT); - } catch (IOException ioe) { - log.error("Couldn't store mod props: ", ioe); - } finally { - try { - fos.close(); - } catch (IOException ioe) { - log.error("Can't close input stream \n", ioe); - } - } - } - - public synchronized boolean deletePage(String pageName) { - - if (pageExists(pageName)) { - // moving page file - String pageFileName = pathToMedia + "/" + pageName + ".txt"; - String pageFileTrashNameBase = pathToMediaTrash + "/" + pageName - + ".txt"; - String pageFileTrashName = pageFileTrashNameBase; - - File pageFile = new File(pageFileName); - File pageTrashFile = new File(pageFileTrashName); - - // create dirs to trash - File trashFileDir = new File(pathToMediaTrash + "/" + pageName); - if (!trashFileDir.exists()) { - trashFileDir.mkdirs(); - } - - // look if page is already in trash (add i-bak) - int i = 0; - - if (pageTrashFile.exists()) { - while (pageTrashFile.exists()) { - pageFileTrashName = pageFileTrashNameBase + "-" + (i++) - + "-bak"; - pageTrashFile = new File(pageFileTrashName); - } - - } - - if (!pageFile.renameTo(pageTrashFile)) { - log.error("[FileDataSource]: Problems with moving " - + pageFileName + " to " + pageFileTrashName); - return false; - } - - // moving history directory - - String historyDirName = pathToMedia + "/OLD/" + pageName; - String historyTrashDirNameBase = pathToMediaTrash + "/OLD/" - + pageName; - String historyTrashDirName = historyTrashDirNameBase; - - // create dirs to trash (history) - trashFileDir = new File(pathToMediaTrash + "/OLD/" + pageName); - if (!trashFileDir.exists()) { - trashFileDir.mkdirs(); - } - - pageFile = new File(historyDirName); - pageTrashFile = new File(historyTrashDirName); - - // look if history dir is already in trash (add i-bak) - i = 0; - - if (pageTrashFile.exists()) { - while (pageTrashFile.exists()) { - historyTrashDirName = historyTrashDirNameBase + "-" + (i++) - + "-bak"; - pageTrashFile = new File(historyTrashDirName); - } - - } - - if (!pageFile.renameTo(pageTrashFile)) { - log.error("[FileDataSource]: Problems with moving " - + historyDirName + " to " + historyTrashDirName); - - // return back the page history - pageFile = new File(pageFileName); - pageTrashFile = new File(pageFileTrashName); - - if (!pageTrashFile.renameTo(pageFile)) { - System.err - .println("[FileDataSource]: ERROR. I've tried moving previously moved page file from the trash, but there was some problem. This is not good and there is nothing i can do about it. The error ocured while moving " - + pageFileTrashName + " to " + pageFileName); - } - - return false; - } - - return true; - } else { - // no such page - log.error("There is now such page: " + pageName); - return false; - } - } - - public synchronized boolean deleteAttachment(String pageName, - String attachmentName) { - - String attName = pathToAttachments + "/" + pageName + "-att/" - + attachmentName + "-dir"; - String attTrashNameBase = pathToAttTrash + "/" + pageName + "-att/" - + attachmentName + "-dir"; - String attTrashName = attTrashNameBase; - - // create dirs to trash - File trashFileDir = new File(pathToAttTrash + "/" + pageName + "-att/"); - if (!trashFileDir.exists()) { - trashFileDir.mkdirs(); - } - - // moving file directory - File attFile = new File(attName); - - if (attFile.exists()) { - - // look if att dir is already in trash (add i-bak) - File attTrashFile = new File(attTrashName); - - int i = 0; - - if (attTrashFile.exists()) { - while (attTrashFile.exists()) { - attTrashName = attTrashNameBase + "-" + (i++) + "-bak"; - attTrashFile = new File(attTrashName); - } - - } - - if (!attFile.renameTo(attTrashFile)) { - log.error("[ATTACHMENT DS]:Problems with moving " + attName - + " to " + attTrashName); - return false; - } - - return true; - } else { - log.error("Page " + pageName + " has no " + attachmentName - + " attachmnet"); - return false; - } - } - - public synchronized boolean deleteAttachments(String pageName) { - String attName = pathToAttachments + "/" + pageName + "-att"; - String attTrashNameBase = pathToAttTrash + "/" + pageName + "-att"; - String attTrashName = attTrashNameBase; - - // create dirs to trash - File trashFileDir = new File(pathToAttTrash + "/" + pageName); - if (!trashFileDir.exists()) { - trashFileDir.mkdirs(); - } - - // moving file directory - File attFile = new File(attName); - - if (attFile.exists()) { - // look if att dir is already in trash (add i-bak) - File attTrashFile = new File(attTrashName); - - int i = 0; - - if (attTrashFile.exists()) { - while (attTrashFile.exists()) { - attTrashName = attTrashNameBase + "-" + (i++) + "-bak"; - attTrashFile = new File(attTrashName); - } - - } - - if (!attFile.renameTo(new File(attTrashName))) { - log.error("[ATTACHMENT DS]:Problems with moving " + attName - + " to " + attTrashName); - return false; - } - - return true; - } else { - log.error("Page " + pageName + " has no attachmnets"); - return false; - } - } - - public String getRealName(String uid) { - while (lock) - ; // wait till unlocked (dictionary is changing) - - return (pageDictionary.getProperty(uid) != null) ? pageDictionary - .getProperty(uid) : uid; - } - - public String getUid(String realName) { - while (lock) - ; // wait till unlocked (dictionary is changing) - - return (pageRevDictionary.getProperty(realName) != null) ? pageRevDictionary - .getProperty(realName) - : realName; - } - - public synchronized void rename(String uid, String newName) - throws PageRenamingException { - - lock = true; - - pageDictionary.setProperty(uid, newName); - pageRevDictionary.setProperty(newName, uid); - - saveDictionary(); - - log.info("Renamed (uid) " + uid + " to " + newName); - - lock = false; - } - - private void saveDictionary() { - // synchronize dictionary with file on disk - FileOutputStream fos; - try { - fos = new FileOutputStream(pageDictionaryFile); - - try { - pageDictionary.store(fos, SAVE_COMMENT); - } catch (IOException e) { - e.printStackTrace(); - } - - try { - fos.close(); - } catch (IOException e) { - e.printStackTrace(); - } - - } catch (FileNotFoundException e) { - e.printStackTrace(); - } - } - - public boolean uidInDictionary(String uid) { - return pageDictionary.contains(uid); - } - - public boolean realNameInDictionary(String realName) { - return pageRevDictionary.contains(realName); - } - - public synchronized void removeDictForPage(String uid) - throws PageRenamingException { - if (!pageDictionary.containsKey(uid)) { - throw new PageRenamingException( - "There is no dictionary entry for uid: " + uid); - } - - String realName = pageDictionary.getProperty(uid); - - // remove all dict entries - pageDictionary.remove(uid); - pageRevDictionary.remove(realName); - - saveDictionary(); - } - - public Properties getMetadataProps(String uid) { - - if (!pageExists(uid)) { - // don't get matedata props for nonexisting page - return new Properties(); - } - - File propsFile = new File(pathToMedia + "/OLD/" + uid - + "/metadata.properties"); - - if (!propsFile.exists()) { - - // create file if it doesn't exist yet - try { - propsFile.createNewFile(); - } catch (IOException e) { - log.error(e); - } - } - - Properties props = new Properties(); - FileInputStream fis = null; - - try { - fis = new FileInputStream(propsFile); - } catch (FileNotFoundException e1) { - log.error(e1); - } - - try { - props.load(fis); - } catch (IOException e) { - log.error(e); - } - - try { - fis.close(); - } catch (IOException e) { - log.error(e); - } - - return props; - } - - public void saveMetadataProps(String uid, Properties props) { - getMetadataProps(uid); // this will create file if needed. - - File propsFile = new File(pathToMedia + "/OLD/" + uid - + "/metadata.properties"); - - FileOutputStream fos = null; - - try { - fos = new FileOutputStream(propsFile); - } catch (FileNotFoundException e) { - log.error(e); - } - - try { - props.store(fos, SAVE_COMMENT); - } catch (IOException e) { - log.error(e); - } - - try { - fos.close(); - } catch (IOException e) { - log.error(e); - } - } - - public void setLanguageCode(String langCode) { - init(OTHER_LANG_DIR + langCode); - - this.langCode = langCode; - } - - public Map<String, String> getAvailableLanguages() { - Properties props = new Properties(); - - Map<String, String> map = new TreeMap<String, String>(); - - map.put(wikiEngine.defaultLangugeCode, wikiEngine.getAllLanguageCodes() - .get(wikiEngine.defaultLangugeCode)); - - try { - File f = new File(pathToMedia + "/" + LANG_FILE); - - if (!f.exists()) { - f.createNewFile(); - } - - FileInputStream fis = new FileInputStream(f); - - props.load(fis); - - HashMap mapd = new HashMap(props); - - map.putAll((Map<String, String>) mapd); - } catch (IOException e) { - log.error("Couldn't load properties with language list", e); - } - - return map; - } - - public void addLangCode(String langCode, String langDesc) { - Properties props = new Properties(); - - props.putAll(getAvailableLanguages()); - - props.put(langCode, langDesc); - - try { - File f = new File(pathToMedia + "/" + LANG_FILE); - - FileOutputStream fos = new FileOutputStream(f); - - props.store(fos, SAVE_COMMENT); - } catch (IOException e) { - log.error("Couldn't save properties with language list", e); - } - - } - - public String getLangCode() { - return langCode; - } - - public Map<String, String> getRenameMapings() { - Map<String,String> map = new HashMap<String, String>(); - - for (Object uid : pageDictionary.keySet()) { - map.put((String)uid, pageDictionary.getProperty((String)uid)); - } - - return map; - } - -} Copied: labs/jbosslabs/branches/Labs-Portal-2.0-ComTheme/forge/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/FileMediaDataSource.java (from rev 4094, labs/jbosslabs/trunk/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/FileMediaDataSource.java) Copied: labs/jbosslabs/branches/Labs-Portal-2.0-ComTheme/forge/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/FileWikiPageDictionary.java (from rev 4094, labs/jbosslabs/trunk/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/FileWikiPageDictionary.java) Modified: labs/jbosslabs/branches/Labs-Portal-2.0-ComTheme/forge/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/RenamePageWatcher.java =================================================================== --- labs/jbosslabs/branches/Labs-Portal-2.0-ComTheme/forge/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/RenamePageWatcher.java 2006-05-04 18:16:20 UTC (rev 4094) +++ labs/jbosslabs/branches/Labs-Portal-2.0-ComTheme/forge/porta... [truncated message content] |
Author: soh...@jb... Date: 2006-05-04 14:16:20 -0400 (Thu, 04 May 2006) New Revision: 4094 Modified: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/Constants.java labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/ForumsJSFPortlet.java labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/ReplyTopic.java labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/forums-config.xml labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/topics/viewtopic_body.xhtml Log: quoting in reply topic usecase integrated Modified: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/Constants.java =================================================================== --- labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/Constants.java 2006-05-04 16:52:14 UTC (rev 4093) +++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/Constants.java 2006-05-04 18:16:20 UTC (rev 4094) @@ -46,7 +46,9 @@ public static final String p_poll_title = "POLL_TITLE"; public static final String p_poll_delete = "POLL_DELETE"; public static final String p_attachment = "ATTACHMENT"; - //------------------------------------------------------------------------------------------------------------------------------- + //other constants------------------------------------------------------------------------------------------------------------------------------- + public static final String QUOTE = "quote"; + /** * DOCUMENT_ME */ Modified: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/ForumsJSFPortlet.java =================================================================== --- labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/ForumsJSFPortlet.java 2006-05-04 16:52:14 UTC (rev 4093) +++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/ForumsJSFPortlet.java 2006-05-04 18:16:20 UTC (rev 4094) @@ -62,7 +62,7 @@ String attachment = ForumUtil.getParameter(request,Constants.p_attachment); String topicId = ForumUtil.getParameter(request,Constants.p_topicId); String postId = ForumUtil.getParameter(request,Constants.p_postId); - String userId = ForumUtil.getParameter(request,Constants.p_userId); + String userId = ForumUtil.getParameter(request,Constants.p_userId); if(categoryId!=null && categoryId.trim().length()>0) { response.setRenderParameter(Constants.p_categoryId,categoryId); @@ -98,6 +98,6 @@ if(postId!=null && postId.trim().length()>0) { response.setRenderParameter(Constants.p_postId,postId); - } + } } } Modified: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/ReplyTopic.java =================================================================== --- labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/ReplyTopic.java 2006-05-04 16:52:14 UTC (rev 4093) +++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/ReplyTopic.java 2006-05-04 18:16:20 UTC (rev 4094) @@ -86,13 +86,18 @@ //grab the forum where this topic will be added if(forumId!=-1) { + Topic topic = this.getForumsModule().findTopicById(new Integer(topicId)); + //re-initialize this controller to add a reply post in a topic //to the specified forum this.cleanup(); //set the selected forum's id and topic's id this.forumId = forumId; - this.topicId = topicId; + this.topicId = topicId; + + //set the subject information + this.subject = "Re: " + topic.getSubject(); } navState = Constants.START_REPLY; @@ -102,7 +107,34 @@ JSFUtil.handleException(e); } return navState; - } + } + + /** + * + * + */ + public String startQuote() + { + String navState = this.start(); + try + { + String p = ForumUtil.getParameter(Constants.p_postId); + if(p!=null && p.trim().length()>0) + { + postId = Integer.parseInt(p); + } + + //setup the quote information + Post post = this.getForumsModule().findPostById(new Integer(postId)); + Poster poster = PortalUtil.getPoster(); + this.message = "["+Constants.QUOTE+"="+poster.getUser().getUserName()+"]"+post.getMessage().getText()+"[/"+Constants.QUOTE+"]"; + } + catch(Exception e) + { + JSFUtil.handleException(e); + } + return navState; + } //--------execute------------------------------------------------------------------------------------------------------------- /** * Modified: labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/forums-config.xml =================================================================== --- labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/forums-config.xml 2006-05-04 16:52:14 UTC (rev 4093) +++ labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/forums-config.xml 2006-05-04 18:16:20 UTC (rev 4094) @@ -13,7 +13,7 @@ <view-handler>com.sun.facelets.FaceletPortletViewHandler</view-handler--> <!-- standalone facelets integration --> - <!--view-handler>com.sun.facelets.FaceletViewHandler</view-handler--> + <view-handler>com.sun.facelets.FaceletViewHandler</view-handler> <!-- internationalization --> <locale-config> Modified: labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/topics/viewtopic_body.xhtml =================================================================== --- labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/topics/viewtopic_body.xhtml 2006-05-04 16:52:14 UTC (rev 4093) +++ labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/topics/viewtopic_body.xhtml 2006-05-04 18:16:20 UTC (rev 4094) @@ -219,6 +219,17 @@ is only for unit testing the edit post usecase --> <td valign="top" nowrap=""> + <!-- add the quote link --> + <h:commandLink action="#{replyTopic.startQuote}" style="text-decoration: none;"> + <f:param name="f" value="#{topic.topic.forum.id}"/> + <f:param name="t" value="#{topic.topic.id}"/> + <f:param name="p" value="#{postrow.id}"/> + <f:verbatim> + <img border="0" + src="#{forums:themeURL('resourceReplyLockedURL')}" + alt="${resource.Topic_locked}" /> + </f:verbatim> + </h:commandLink> <!-- add the edit post link --> <h:commandLink action="#{editPost.start}" style="text-decoration: none;"> <f:param name="p" value="#{postrow.id}"/> |
Author: adamw Date: 2006-05-04 12:52:14 -0400 (Thu, 04 May 2006) New Revision: 4093 Modified: labs/shotoku/trunk/shotoku-admin/src/java/org/jboss/shotoku/web/admin/UpdateServlet.java labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/ContentManager.java labs/shotoku/trunk/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnTools.java labs/shotoku/trunk/shotoku-svn/src/java/org/jboss/shotoku/svn/service/SvnRepository.java labs/shotoku/trunk/shotoku-svn/src/java/org/jboss/shotoku/svn/service/SvnServiceImpl.java Log: http://jira.jboss.com/jira/browse/JBSHOTOKU-31 Modified: labs/shotoku/trunk/shotoku-admin/src/java/org/jboss/shotoku/web/admin/UpdateServlet.java =================================================================== --- labs/shotoku/trunk/shotoku-admin/src/java/org/jboss/shotoku/web/admin/UpdateServlet.java 2006-05-04 16:52:03 UTC (rev 4092) +++ labs/shotoku/trunk/shotoku-admin/src/java/org/jboss/shotoku/web/admin/UpdateServlet.java 2006-05-04 16:52:14 UTC (rev 4093) @@ -18,6 +18,7 @@ HttpServletResponse response) throws ServletException, IOException { String data = request.getParameter("data"); + System.out.println("DATA: " + data); if (data == null) { return; } @@ -32,7 +33,7 @@ Set<String> toUpdate = new HashSet<String>(); String current = tokens[0]; - toUpdate.add(current); + /*toUpdate.add(current); for (String token : tokens) { if (!"".equals(token) && !token.startsWith(current)) { @@ -47,7 +48,7 @@ System.out.println("Rev: " + revision + ", id: " + id); - SvnTools.getService().addPathsToUpdate(id, revision, toUpdate); + //SvnTools.getService().addPathsToUpdate(id, revision, toUpdate); */ } catch (Exception e) { // In case of an exception, doing nothing. } Modified: labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/ContentManager.java =================================================================== --- labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/ContentManager.java 2006-05-04 16:52:03 UTC (rev 4092) +++ labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/ContentManager.java 2006-05-04 16:52:14 UTC (rev 4093) @@ -562,10 +562,10 @@ implClass.getConstructor(String.class, String.class, Configuration.class), conf)); - Set<String> implIds = implementationsIds.get(id); + Set<String> implIds = implementationsIds.get(implementation); if (implIds == null) { implIds = new HashSet<String>(); - implementationsIds.put(id, implIds); + implementationsIds.put(implementation, implIds); } implIds.add(id); Modified: labs/shotoku/trunk/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnTools.java =================================================================== --- labs/shotoku/trunk/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnTools.java 2006-05-04 16:52:03 UTC (rev 4092) +++ labs/shotoku/trunk/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnTools.java 2006-05-04 16:52:14 UTC (rev 4093) @@ -58,6 +58,7 @@ public static final String PROPERTY_URL = "url"; public static final String PROPERTY_PASSWORD = "password"; public static final String PROPERTY_LOCALPATH = "localpath"; + public static final String PROPERTY_FULLUPDATE = "fullupdate"; /* * Names of internal shotoku properties. Modified: labs/shotoku/trunk/shotoku-svn/src/java/org/jboss/shotoku/svn/service/SvnRepository.java =================================================================== --- labs/shotoku/trunk/shotoku-svn/src/java/org/jboss/shotoku/svn/service/SvnRepository.java 2006-05-04 16:52:03 UTC (rev 4092) +++ labs/shotoku/trunk/shotoku-svn/src/java/org/jboss/shotoku/svn/service/SvnRepository.java 2006-05-04 16:52:14 UTC (rev 4093) @@ -65,6 +65,15 @@ private ConcurrentSet<String> frozenModifiedTrees; private ConcurrentSet<String> frozenDeletedResources; + /** + * Number of updates after which a full WC update is done. + */ + private int fullUpdate; + /** + * Number of updates since last full WC update. + */ + private int updateCounter; + private Set<Pair<Long, Set<String>>> toUpdate; /** @@ -78,25 +87,22 @@ private ContentManager cm; public SvnRepository(String id, String username, String password, - String url, String localpath) { + String url, String localpath, int fullUpdate) { log.info("Creating new Subversion Repository: id: "+id+ ", username: "+username+ ", passwd: "+password+ ", url: "+url+ ", localpath: "+localpath); ISVNOptions options = SVNWCUtil.createDefaultOptions(true); - log.info(" Creating new SVNClientManager..."); ourClientManager = SVNClientManager.newInstance(options, username, password); - log.info(" SVNClientManager created."); try { repository = SVNRepositoryFactory.create(SVNURL.parseURIEncoded( url)); - log.info(" SVNRepositoryFactory.create() call successful. Setting AuthenticationManager..."); + log.info(" SVNRepositoryFactory.create() call successful."); repository.setAuthenticationManager( SVNWCUtil.createDefaultAuthenticationManager(username, password)); - log.info(" AuthenticationManager set using given username and passwd."); } catch (SVNException e) { log.warn("Error while creating SVNRepository.", e); } @@ -106,6 +112,9 @@ this.url = url; this.id = id; + this.fullUpdate = fullUpdate; + updateCounter = 0; + wc = new File(localpath); modifiedTrees = new ConcurrentHashSet<String>(); @@ -151,9 +160,41 @@ * Updates the local working copy. */ public void update() { - update(false, true); + updateCounter++; + if (updateCounter == fullUpdate) { + // Everything will be updated anyway. + toUpdate.clear(); + update(false, true); + + updateCounter = 0; + } else { + // Only updating the "toUpdate" resources. + updateToUpdate(); + } } + private void updateToUpdate() { + SVNUpdateClient updateClient = ourClientManager.getUpdateClient(); + updateClient.setIgnoreExternals(false); + + for (Iterator<Pair<Long, Set<String>>> iter = toUpdate.iterator(); iter.hasNext();) { + Pair<Long, Set<String>> updateData = iter.next(); + // Only updating if the data is newer then the current one in the wc. + if (updateData.getFirst() > lastRevision) { + for (String path : updateData.getSecond()) { + File wcPath = new File(wc.getPath() + File.separator + path); + try { + updateClient.doUpdate(wcPath, SVNRevision.HEAD, true); + } catch (SVNException e) { + log.warn("Error updating a modified path: " + path + ".", e); + } + } + } + + iter.remove(); + } + } + /** * Updates the repository. If it fails, and <code>tryCheckout</code> is * set to true, a checkout is attempted; if it set to false, and @@ -200,8 +241,6 @@ // Doing the actual update. try { - SVNURL repositoryURL = SVNURL.parseURIEncoded(url); - SVNUpdateClient updateClient = ourClientManager.getUpdateClient(); updateClient.setIgnoreExternals(false); try { @@ -213,6 +252,8 @@ lastRevision = updateClient.doUpdate(wc, SVNRevision.HEAD, true); } catch (SVNException e) { + SVNURL repositoryURL = SVNURL.parseURIEncoded(url); + if (tryCheckout) { updateClient.doCheckout(repositoryURL, wc, SVNRevision.HEAD, SVNRevision.HEAD, true); Modified: labs/shotoku/trunk/shotoku-svn/src/java/org/jboss/shotoku/svn/service/SvnServiceImpl.java =================================================================== --- labs/shotoku/trunk/shotoku-svn/src/java/org/jboss/shotoku/svn/service/SvnServiceImpl.java 2006-05-04 16:52:03 UTC (rev 4092) +++ labs/shotoku/trunk/shotoku-svn/src/java/org/jboss/shotoku/svn/service/SvnServiceImpl.java 2006-05-04 16:52:14 UTC (rev 4093) @@ -175,7 +175,8 @@ conf.getString(SvnTools.PROPERTY_USERNAME), conf.getString(SvnTools.PROPERTY_PASSWORD), conf.getString(SvnTools.PROPERTY_URL), - conf.getString(SvnTools.PROPERTY_LOCALPATH)); + conf.getString(SvnTools.PROPERTY_LOCALPATH), + conf.getInt(SvnTools.PROPERTY_FULLUPDATE, 1)); repositories.put(id, repo); |
From: <jbo...@li...> - 2006-05-04 16:52:08
|
Author: adamw Date: 2006-05-04 12:52:03 -0400 (Thu, 04 May 2006) New Revision: 4092 Modified: labs/shotoku/trunk/shotoku-svn/hooks/shotoku-update.sh Log: http://jira.jboss.com/jira/browse/JBSHOTOKU-31 Modified: labs/shotoku/trunk/shotoku-svn/hooks/shotoku-update.sh =================================================================== --- labs/shotoku/trunk/shotoku-svn/hooks/shotoku-update.sh 2006-05-04 16:26:15 UTC (rev 4091) +++ labs/shotoku/trunk/shotoku-svn/hooks/shotoku-update.sh 2006-05-04 16:52:03 UTC (rev 4092) @@ -6,6 +6,7 @@ USERNAME="ShotokuUpdate" PASSWORD="ShotokuUpdate" REMOTE="http://192.168.1.102:8080/shotoku-admin/update" +REPO_PREFIX="private/adamw/test/" # ------------- REPOS="$1" @@ -14,8 +15,14 @@ SVNLOOK=svnlook -POST_DATA="data=default#$REV#"`$SVNLOOK dirs-changed $OPTS $REPOS | tr [:space:] :` +PREFIX_LEN=`echo "$REPO_PREFIX" | wc -m` +SVNLOOK_DATA=`$SVNLOOK dirs-changed $OPTS $REPOS | grep "^$REPO_PREFIX" | cut -b $PREFIX_LEN- | sort | uniq | tr [:space:] :` -wget -O - --http-user=$USERNAME --http-password=$PASSWORD --post-data="$POST_DATA" $REMOTE >/dev/null +if [ -n "$SVNLOOK_DATA" ] +then + POST_DATA="data=priv#$REV#$SVNLOOK_DATA" + wget -O - --http-user=$USERNAME --http-password=$PASSWORD --post-data="$POST_DATA" $REMOTE >/dev/null +fi + exit 0 |
From: <jbo...@li...> - 2006-05-04 16:26:30
|
Author: adamw Date: 2006-05-04 12:26:15 -0400 (Thu, 04 May 2006) New Revision: 4091 Modified: labs/jbosslabs/trunk/portal-extensions/binaries/maven-repo-addons/jboss/jars/portal-bridge-lib.jar labs/jbosslabs/trunk/portal-extensions/binaries/maven-repo-addons/jboss/jars/portal-common-lib.jar labs/jbosslabs/trunk/portal-extensions/binaries/maven-repo-addons/jboss/jars/portal-core-lib.jar labs/jbosslabs/trunk/portal-extensions/binaries/maven-repo-addons/jboss/jars/portal-faces-lib.jar labs/jbosslabs/trunk/portal-extensions/binaries/maven-repo-addons/jboss/jars/portal-format-lib.jar labs/jbosslabs/trunk/portal-extensions/binaries/maven-repo-addons/jboss/jars/portal-portlet-lib.jar labs/jbosslabs/trunk/portal-extensions/binaries/maven-repo-addons/jboss/jars/portal-security-lib.jar labs/jbosslabs/trunk/portal-extensions/binaries/maven-repo-addons/jboss/jars/portal-server-lib.jar labs/jbosslabs/trunk/portal-extensions/binaries/maven-repo-addons/jboss/jars/portal-theme-lib.jar labs/jbosslabs/trunk/portal-extensions/binaries/maven-repo-addons/jboss/jars/portlet-api-lib.jar labs/jbosslabs/trunk/portal-extensions/counters-ejb3/ labs/jbosslabs/trunk/portal-extensions/maven.xml Log: Portal 2.2.1 Modified: labs/jbosslabs/trunk/portal-extensions/binaries/maven-repo-addons/jboss/jars/portal-bridge-lib.jar =================================================================== (Binary files differ) Modified: labs/jbosslabs/trunk/portal-extensions/binaries/maven-repo-addons/jboss/jars/portal-common-lib.jar =================================================================== (Binary files differ) Modified: labs/jbosslabs/trunk/portal-extensions/binaries/maven-repo-addons/jboss/jars/portal-core-lib.jar =================================================================== (Binary files differ) Modified: labs/jbosslabs/trunk/portal-extensions/binaries/maven-repo-addons/jboss/jars/portal-faces-lib.jar =================================================================== (Binary files differ) Modified: labs/jbosslabs/trunk/portal-extensions/binaries/maven-repo-addons/jboss/jars/portal-format-lib.jar =================================================================== (Binary files differ) Modified: labs/jbosslabs/trunk/portal-extensions/binaries/maven-repo-addons/jboss/jars/portal-portlet-lib.jar =================================================================== (Binary files differ) Modified: labs/jbosslabs/trunk/portal-extensions/binaries/maven-repo-addons/jboss/jars/portal-security-lib.jar =================================================================== (Binary files differ) Modified: labs/jbosslabs/trunk/portal-extensions/binaries/maven-repo-addons/jboss/jars/portal-server-lib.jar =================================================================== (Binary files differ) Modified: labs/jbosslabs/trunk/portal-extensions/binaries/maven-repo-addons/jboss/jars/portal-theme-lib.jar =================================================================== (Binary files differ) Modified: labs/jbosslabs/trunk/portal-extensions/binaries/maven-repo-addons/jboss/jars/portlet-api-lib.jar =================================================================== (Binary files differ) Property changes on: labs/jbosslabs/trunk/portal-extensions/counters-ejb3 ___________________________________________________________________ Name: svn:ignore + target Modified: labs/jbosslabs/trunk/portal-extensions/maven.xml =================================================================== --- labs/jbosslabs/trunk/portal-extensions/maven.xml 2006-05-04 16:22:27 UTC (rev 4090) +++ labs/jbosslabs/trunk/portal-extensions/maven.xml 2006-05-04 16:26:15 UTC (rev 4091) @@ -120,11 +120,10 @@ Before installing, building and deploying JBoss Labs please create and/ or modify the following files: (for all that are not created there's a template .sample file) 1. build.properties -2. forge-common/src/etc/org/jboss/forge/common/forge.properties -3. forge-login/to-copy/portal-login-ds.xml -4. federation-register/src/web/WEB-INF/faces-config (only for the JOSF portal). -5. jbosswiki/wiki-common/src/etc/org/jboss/wiki/filedatasource.properties -6. shotoku/shotoku-base/src/etc/shotoku.properties +2. forge-login/to-copy/portal-login-ds.xml +3. federation-register/src/web/WEB-INF/faces-config (only for the JOSF portal). +4. jbosswiki/wiki-common/src/etc/org/jboss/wiki/filedatasource.properties +5. shotoku/shotoku-base/src/etc/shotoku.properties Available goals: - help - prints this info |
Author: adamw Date: 2006-05-04 12:22:27 -0400 (Thu, 04 May 2006) New Revision: 4090 Modified: labs/jbosslabs/trunk/portal-extensions/configuration/to-copy/jboss-portal.sar/META-INF/jboss-service.xml labs/jbosslabs/trunk/portal-extensions/configuration/to-copy/jboss-portal.sar/portal-server.war/WEB-INF/web.xml labs/jbosslabs/trunk/portal-extensions/portal-binaries/to-copy/jboss-portal.sar/META-INF/MANIFEST.MF labs/jbosslabs/trunk/portal-extensions/portal-binaries/to-copy/jboss-portal.sar/lib/portal-bridge-lib.jar labs/jbosslabs/trunk/portal-extensions/portal-binaries/to-copy/jboss-portal.sar/lib/portal-common-lib.jar labs/jbosslabs/trunk/portal-extensions/portal-binaries/to-copy/jboss-portal.sar/lib/portal-core-lib.jar labs/jbosslabs/trunk/portal-extensions/portal-binaries/to-copy/jboss-portal.sar/lib/portal-faces-lib.jar labs/jbosslabs/trunk/portal-extensions/portal-binaries/to-copy/jboss-portal.sar/lib/portal-format-lib.jar labs/jbosslabs/trunk/portal-extensions/portal-binaries/to-copy/jboss-portal.sar/lib/portal-portlet-lib.jar labs/jbosslabs/trunk/portal-extensions/portal-binaries/to-copy/jboss-portal.sar/lib/portal-security-lib.jar labs/jbosslabs/trunk/portal-extensions/portal-binaries/to-copy/jboss-portal.sar/lib/portal-server-lib.jar labs/jbosslabs/trunk/portal-extensions/portal-binaries/to-copy/jboss-portal.sar/lib/portal-theme-lib.jar labs/jbosslabs/trunk/portal-extensions/portal-binaries/to-copy/jboss-portal.sar/lib/portlet-api-lib.jar labs/jbosslabs/trunk/portal-extensions/portal-binaries/to-copy/jboss-portal.sar/portal-cms.sar/META-INF/MANIFEST.MF labs/jbosslabs/trunk/portal-extensions/portal-binaries/to-copy/jboss-portal.sar/portal-cms.sar/portal-cms-lib.jar labs/jbosslabs/trunk/portal-extensions/portal-binaries/to-copy/jboss-portal.sar/portal-cms.war/META-INF/MANIFEST.MF labs/jbosslabs/trunk/portal-extensions/portal-binaries/to-copy/jboss-portal.sar/portal-core.war/META-INF/MANIFEST.MF labs/jbosslabs/trunk/portal-extensions/portal-binaries/to-copy/jboss-portal.sar/portal-samples.war/META-INF/MANIFEST.MF labs/jbosslabs/trunk/portal-extensions/portal-binaries/to-copy/jboss-portal.sar/portal-server.war/META-INF/MANIFEST.MF Log: Portal 2.2.1 Modified: labs/jbosslabs/trunk/portal-extensions/configuration/to-copy/jboss-portal.sar/META-INF/jboss-service.xml =================================================================== --- labs/jbosslabs/trunk/portal-extensions/configuration/to-copy/jboss-portal.sar/META-INF/jboss-service.xml 2006-05-04 14:05:38 UTC (rev 4089) +++ labs/jbosslabs/trunk/portal-extensions/configuration/to-copy/jboss-portal.sar/META-INF/jboss-service.xml 2006-05-04 16:22:27 UTC (rev 4090) @@ -1,719 +1,719 @@ -<?xml version="1.0" encoding="UTF-8"?> -<server> - - <!-- Server configuration service --> - <mbean - code="org.jboss.portal.server.config.ServerConfigService" - name="portal:service=ServerConfig" - xmbean-dd="org/jboss/portal/server/config/ServerConfigService.xml"> - <attribute name="ConfigLocation">conf/config.xml</attribute> - </mbean> - - <!-- Jacc policy configuration --> - <mbean - code="org.jboss.portal.security.impl.jacc.PortalJaccPolicy" - name="jboss.security:service=JaccPolicyProvider" - xmbean-dd="org/jboss/portal/security/impl/jacc/PortalJaccPolicy.xml"> - <attribute name="ExternalPermissionTypes"> - org.jboss.portal.core.security.PortalObjectPermission, - org.jboss.portal.core.security.InstancePermission, - org.jboss.portal.core.security.ComponentPermission - </attribute> - </mbean> - - <!-- Security provider --> - <!-- todo when the xmbean loading is fixed in JBoss move the xmbean descriptor to a resource file : http://jira.jboss.com/jira/browse/JBAS-2501 --> - <mbean - code="org.jboss.portal.security.impl.jacc.JBossSecurityProviderImpl" - name="portal:service=SecurityProvider" - xmbean-dd=""> - <xmbean> - <descriptors> - <injection id="MBeanServerType" setMethod="setMBeanServer"/> - <injection id="ObjectNameType" setMethod="setObjectName"/> - </descriptors> - <attribute access="read-write" getMethod="getPolicyName" setMethod="setPolicyName"> - <description>The policy provider MBean name</description> - <name>PolicyName</name> - <type>javax.management.ObjectName</type> - </attribute> - <attribute access="read-write" getMethod="getPolicyAttributeName" setMethod="setPolicyAttributeName"> - <description>The Policy attribute name on the PolicyName MBean</description> - <name>PolicyAttributeName</name> - <type>java.lang.String</type> - </attribute> - <attribute access="read-write" getMethod="getConfig" setMethod="setConfig"> - <description>The Server Config</description> - <name>ConfigName</name> - <type>javax.management.ObjectName</type> - </attribute> - <attribute access="read-write" getMethod="getServerConfig"> - <description>(no description)</description> - <name>ServerConfig</name> - <type>org.jboss.portal.server.config.ServerConfig</type> - <descriptors> - <persistence/> - </descriptors> - </attribute> - <attribute access="read-write" getMethod="getPolicy"> - <description>(no description)</description> - <name>Policy</name> - <type>java.security.Policy</type> - <descriptors> - <persistence/> - </descriptors> - </attribute> - <operation impact="ACTION_INFO"> - <description>(no description)</description> - <name>inService</name> - <parameter> - <description>(no description)</description> - <name>policyContextID</name> - <type>java.lang.String</type> - </parameter> - <return-type>boolean</return-type> - <descriptors> - </descriptors> - </operation> - <operation impact="ACTION_INFO"> - <description>(no description)</description> - <name>getPolicyConfiguration</name> - <parameter> - <description>(no description)</description> - <name>policyContextID</name> - <type>java.lang.String</type> - </parameter> - <parameter> - <description>(no description)</description> - <name>remove</name> - <type>boolean</type> - </parameter> - <return-type>javax.security.jacc.PolicyConfiguration</return-type> - <descriptors> - </descriptors> - </operation> - <operation> - <name>start</name> - </operation> - <operation> - <name>stop</name> - </operation> - </xmbean> - <attribute name="PolicyName">jboss.security:service=JaccPolicyProvider</attribute> - <attribute name="PolicyAttributeName">PolicyProxy</attribute> - <attribute name="ConfigName">portal:service=ServerConfig</attribute> - </mbean> - <mbean - code="org.jboss.portal.security.impl.jacc.PortalPolicyServiceImpl" - name="portal:service=PolicyService" - xmbean-dd="org/jboss/portal/security/impl/jacc/PortalPolicyServiceImpl.xml"> - <depends optional-attribute-name="SecurityProvider" proxy-type="attribute">portal:service=SecurityProvider</depends> - </mbean> - <mbean - code="org.jboss.portal.security.impl.jacc.JaccPortalPolicyConfigurator" - name="portal:policy=JaccPortalPolicyConfigurator" - xmbean-dd="org/jboss/portal/security/impl/jacc/JaccPortalPolicyConfigurator.xml"> - <depends optional-attribute-name="JBossSecurityProvider" proxy-type="attribute">portal:service=SecurityProvider</depends> - <depends optional-attribute-name="PermissionFactory" proxy-type="attribute">portal:service=PortalPermissionFactory</depends> - </mbean> - - <!-- Persistent cache for portal objeccts and instances security stores --> - <mbean - code="org.jboss.cache.TreeCache" - name="portal:service=TreeCache,type=persistent"> - <depends>jboss.jca:service=DataSourceBinding,name=PortalDS</depends> - <attribute name="TransactionManagerLookupClass">org.jboss.cache.JBossTransactionManagerLookup</attribute> - <attribute name="IsolationLevel">REPEATABLE_READ</attribute> - <!-- Set to REPL_SYNC in clustered mode, otherwise LOCAL --> - <attribute name="CacheMode">LOCAL</attribute> - <attribute name="ClusterName">portal.security</attribute> - <attribute name="FetchStateOnStartup">true</attribute> - <attribute name="CacheLoaderClass">org.jboss.portal.core.security.store.HibernateCacheLoader</attribute> - <attribute name="CacheLoaderConfig">config.location=conf/hibernate/security/hibernate.cfg.xml</attribute> - <attribute name="CacheLoaderShared">true</attribute> - <attribute name="CacheLoaderFetchTransientState">false</attribute> - <attribute name="CacheLoaderFetchPersistentState">true</attribute> - <attribute name="CacheLoaderPreload">/</attribute> - </mbean> - <mbean - code="org.jboss.portal.security.impl.store.JBossTreeCacheProvider" - name="portal:service=TreeCacheProvider,type=persistent" - xmbean-dd="org/jboss/portal/security/impl/store/JBossTreeCacheProvider.xml"> - <depends optional-attribute-name="CacheName">portal:service=TreeCache,type=persistent</depends> - </mbean> - - <!-- Transient cache for component security store --> - <mbean - code="org.jboss.cache.TreeCache" - name="portal:service=TreeCache,type=transient"> - <attribute name="TransactionManagerLookupClass">org.jboss.cache.JBossTransactionManagerLookup</attribute> - <attribute name="IsolationLevel">REPEATABLE_READ</attribute> - <attribute name="CacheMode">LOCAL</attribute> - </mbean> - <mbean - code="org.jboss.portal.security.impl.store.JBossTreeCacheProvider" - name="portal:service=TreeCacheProvider,type=transient" - xmbean-dd="org/jboss/portal/security/impl/store/JBossTreeCacheProvider.xml"> - <depends optional-attribute-name="CacheName">portal:service=TreeCache,type=transient</depends> - </mbean> - - <!-- --> - <mbean - code="org.jboss.portal.security.impl.JBossPortalPolicyConfigServiceImpl" - name="portal:policy=PortalPolicyConfigService" - xmbean-dd="org/jboss/portal/security/impl/JBossPortalPolicyConfigServiceImpl.xml"> - </mbean> - <mbean - code="org.jboss.portal.security.impl.JBossPortalPolicyConfigStoreImpl" - name="portal:policy=PortalPolicyConfigStore,type=PortalObject" - xmbean-dd="org/jboss/portal/security/impl/JBossPortalPolicyConfigStoreImpl.xml"> - <depends optional-attribute-name="ConfigListener" proxy-type="attribute">portal:policy=JaccPortalPolicyConfigurator</depends> - <depends optional-attribute-name="CacheProvider" proxy-type="attribute">portal:service=TreeCacheProvider,type=persistent</depends> - <depends optional-attribute-name="PortalPolicyConfigService" proxy-type="attribute">portal:policy=PortalPolicyConfigService</depends> - <attribute name="PermissionType">portalobject</attribute> - <attribute name="Prefix">portalobject</attribute> - </mbean> - <mbean - code="org.jboss.portal.security.impl.JBossPortalPolicyConfigStoreImpl" - name="portal:policy=PortalPolicyConfigStore,type=Instance" - xmbean-dd="org/jboss/portal/security/impl/JBossPortalPolicyConfigStoreImpl.xml"> - <depends optional-attribute-name="ConfigListener" proxy-type="attribute">portal:policy=JaccPortalPolicyConfigurator</depends> - <depends optional-attribute-name="CacheProvider" proxy-type="attribute">portal:service=TreeCacheProvider,type=persistent</depends> - <depends optional-attribute-name="PortalPolicyConfigService" proxy-type="attribute">portal:policy=PortalPolicyConfigService</depends> - <attribute name="PermissionType">instance</attribute> - <attribute name="Prefix">instance</attribute> - </mbean> - <mbean - code="org.jboss.portal.security.impl.JBossPortalPolicyConfigStoreImpl" - name="portal:policy=PortalPolicyConfigStore,type=Component" - xmbean-dd="org/jboss/portal/security/impl/JBossPortalPolicyConfigStoreImpl.xml"> - <depends optional-attribute-name="ConfigListener" proxy-type="attribute">portal:policy=JaccPortalPolicyConfigurator</depends> - <depends optional-attribute-name="CacheProvider" proxy-type="attribute">portal:service=TreeCacheProvider,type=transient</depends> - <depends optional-attribute-name="PortalPolicyConfigService" proxy-type="attribute">portal:policy=PortalPolicyConfigService</depends> - <attribute name="PermissionType">component</attribute> - <attribute name="Prefix">component</attribute> - </mbean> - <mbean - code="org.jboss.portal.security.impl.JBossPortalPermissionFactory" - name="portal:service=PortalPermissionFactory" - xmbean-dd="org/jboss/portal/security/impl/JBossPortalPermissionFactory.xml"> - <attribute name="Config"> - portalobject=org.jboss.portal.core.security.PortalObjectPermission - instance=org.jboss.portal.core.security.InstancePermission - component=org.jboss.portal.core.security.ComponentPermission - </attribute> - </mbean> - - <!-- Server stack --> - <mbean - code="org.jboss.portal.core.aspects.server.TransactionInterceptor" - name="portal:service=Interceptor,type=Server,name=Transaction" - xmbean-dd="org/jboss/portal/core/aspects/server/TransactionInterceptor.xml"> - </mbean> - <mbean - code="org.jboss.portal.server.aspects.server.SessionInvalidatorInterceptor" - name="portal:service=Interceptor,type=Server,name=SessionInvalidator" - xmbean-dd="org/jboss/portal/server/aspects/server/SessionInvalidatorInterceptor.xml"> - </mbean> - <mbean - code="org.jboss.portal.core.aspects.server.UserInterceptor" - name="portal:service=Interceptor,type=Server,name=User" - xmbean-dd="org/jboss/portal/core/aspects/server/UserInterceptor.xml"> - </mbean> - <mbean - code="org.jboss.portal.core.aspects.server.LocaleInterceptor" - name="portal:service=Interceptor,type=Server,name=Locale" - xmbean-dd="org/jboss/portal/core/aspects/server/LocaleInterceptor.xml"> - </mbean> - <mbean - code="org.jboss.portal.server.aspects.server.ContentTypeInterceptor" - name="portal:service=Interceptor,type=Server,name=ContentType" - xmbean-dd="org/jboss/portal/server/aspects/server/ContentTypeInterceptor.xml"> - </mbean> - <mbean - code="org.jboss.portal.core.aspects.server.PolicyAssociationInterceptor" - name="portal:service=Interceptor,type=Server,name=PolicyAssociation" - xmbean-dd="org/jboss/portal/core/aspects/server/PolicyAssociationInterceptor.xml"> - <depends optional-attribute-name="PolicyService" proxy-type="attribute">portal:service=PolicyService</depends> - </mbean> - <mbean - code="org.jboss.portal.core.aspects.server.SubjectAssociationInterceptor" - name="portal:service=Interceptor,type=Server,name=SubjectAssociation" - xmbean-dd="org/jboss/portal/core/aspects/server/SubjectAssociationInterceptor.xml"> - </mbean> - <mbean - code="org.jboss.portal.server.impl.invocation.JBossInterceptorStack" - name="portal:service=InterceptorStack,type=Server" - xmbean-dd="org/jboss/portal/server/impl/invocation/JBossInterceptorStack.xml"> - <depends-list optional-attribute-name="InterceptorNames"> - <depends-list-element>portal:service=Interceptor,type=Server,name=Transaction</depends-list-element> - <depends-list-element>portal:service=Interceptor,type=Server,name=SessionInvalidator</depends-list-element> - <depends-list-element>portal:service=Interceptor,type=Server,name=User</depends-list-element> - <depends-list-element>portal:service=Interceptor,type=Server,name=Locale</depends-list-element> - <depends-list-element>portal:service=Interceptor,type=Server,name=ContentType</depends-list-element> - <depends-list-element>portal:service=Interceptor,type=Server,name=PolicyAssociation</depends-list-element> - <depends-list-element>portal:service=Interceptor,type=Server,name=SubjectAssociation</depends-list-element> - </depends-list> - </mbean> - - <!-- Command stack --> - <mbean - code="org.jboss.portal.core.aspects.controller.NavigationInterceptor" - name="portal:service=Interceptor,type=Command,name=Navigation" - xmbean-dd="org/jboss/portal/core/aspects/controller/NavigationInterceptor.xml"> - </mbean> - <mbean - code="org.jboss.portal.core.aspects.controller.PortalNodeInterceptor" - name="portal:service=Interceptor,type=Command,name=PortalNode" - xmbean-dd="org/jboss/portal/core/aspects/controller/PortalNodeInterceptor.xml"> - </mbean> - <mbean - code="org.jboss.portal.core.aspects.controller.PolicyEnforcementInterceptor" - name="portal:service=Interceptor,type=Command,name=PolicyEnforcement" - xmbean-dd="org/jboss/portal/core/aspects/controller/PolicyEnforcementInterceptor.xml"> - <depends optional-attribute-name="PortalPermissionFactory" proxy-type="attribute">portal:service=PortalPermissionFactory</depends> - </mbean> - <mbean - code="org.jboss.portal.core.aspects.controller.EventBroadcasterInterceptor" - name="portal:service=Interceptor,type=Command,name=EventBroadcaster" - xmbean-dd="org/jboss/portal/core/aspects/controller/EventBroadcasterInterceptor.xml"> - </mbean> - <mbean - code="org.jboss.portal.server.impl.invocation.JBossInterceptorStack" - name="portal:service=InterceptorStack,type=Command" - xmbean-dd="org/jboss/portal/server/impl/invocation/JBossInterceptorStack.xml"> - <depends-list optional-attribute-name="InterceptorNames"> - <depends-list-element>portal:service=Interceptor,type=Command,name=Navigation</depends-list-element> - <depends-list-element>portal:service=Interceptor,type=Command,name=PortalNode</depends-list-element> - <depends-list-element>portal:service=Interceptor,type=Command,name=PolicyEnforcement</depends-list-element> - <depends-list-element>portal:service=Interceptor,type=Command,name=EventBroadcaster</depends-list-element> - </depends-list> - </mbean> - - <!-- Portlet stack --> - <mbean - code="org.jboss.portal.portlet.aspects.component.ValveInterceptor" - name="portal:service=Interceptor,type=Component,name=Valve" - xmbean-dd="org/jboss/portal/portlet/aspects/component/ValveInterceptor.xml"> - </mbean> - <mbean - code="org.jboss.portal.server.aspects.component.ContextTrackerInterceptor" - name="portal:service=Interceptor,type=Component,name=ContextTracker" - xmbean-dd="org/jboss/portal/server/aspects/component/ContextTrackerInterceptor.xml"> - </mbean> - <mbean - code="org.jboss.portal.portlet.aspects.component.SecureTransportInterceptor" - name="portal:service=Interceptor,type=Component,name=SecureTransport" - xmbean-dd="org/jboss/portal/portlet/aspects/component/SecureTransportInterceptor.xml"> - </mbean> - <mbean - code="org.jboss.portal.portlet.aspects.component.SessionPreDispatchInterceptor" - name="portal:service=Interceptor,type=Component,name=SessionPreDispatch" - xmbean-dd="org/jboss/portal/portlet/aspects/component/SessionPreDispatchInterceptor.xml"> - </mbean> - <mbean - code="org.jboss.portal.server.aspects.component.ContextDispatcherInterceptor" - name="portal:service=Interceptor,type=Component,name=ContextDispatcher" - xmbean-dd="org/jboss/portal/server/aspects/component/ContextDispatcherInterceptor.xml"> - </mbean> - <mbean - code="org.jboss.portal.portlet.aspects.component.SessionPostDispatchInterceptor" - name="portal:service=Interceptor,type=Component,name=SessionPostDispatch" - xmbean-dd="org/jboss/portal/portlet/aspects/component/SessionPostDispatchInterceptor.xml"> - </mbean> - <mbean - code="org.jboss.portal.bridge.BridgeInterceptor" - name="portal:service=Interceptor,type=Component,name=Bridge" - xmbean-dd="org/jboss/portal/bridge/BridgeInterceptor.xml"> - </mbean> - <mbean - code="org.jboss.portal.server.aspects.component.WindowStatesInterceptor" - name="portal:service=Interceptor,type=Component,name=WindowStates" - xmbean-dd="org/jboss/portal/server/aspects/component/WindowStatesInterceptor.xml"> - </mbean> - <mbean - code="org.jboss.portal.server.aspects.component.ModesInterceptor" - name="portal:service=Interceptor,type=Component,name=Modes" - xmbean-dd="org/jboss/portal/server/aspects/component/ModesInterceptor.xml"> - </mbean> - <mbean - code="org.jboss.portal.server.aspects.component.CacheInterceptor" - name="portal:service=Interceptor,type=Component,name=Cache" - xmbean-dd="org/jboss/portal/server/aspects/component/CacheInterceptor.xml"> - </mbean> - <mbean - code="org.jboss.portal.server.aspects.component.NavigationInterceptor" - name="portal:service=Interceptor,type=Component,name=Navigation" - xmbean-dd="org/jboss/portal/server/aspects/component/NavigationInterceptor.xml"> - </mbean> - <mbean - code="org.jboss.portal.core.aspects.component.TransactionInterceptor" - name="portal:service=Interceptor,type=Component,name=Transaction" - xmbean-dd="org/jboss/portal/core/aspects/component/TransactionInterceptor.xml"> - </mbean> - <mbean - code="org.jboss.portal.core.aspects.component.HeaderInterceptor" - name="portal:service=Interceptor,type=Component,name=Header" - xmbean-dd="org/jboss/portal/core/aspects/component/HeaderInterceptor.xml"> - </mbean> - <mbean - code="org.jboss.portal.server.impl.invocation.JBossInterceptorStack" - name="portal:service=InterceptorStack,type=Component" - xmbean-dd="org/jboss/portal/server/impl/invocation/JBossInterceptorStack.xml"> - <depends-list optional-attribute-name="InterceptorNames"> - <depends-list-element>portal:service=Interceptor,type=Component,name=Valve</depends-list-element> - <depends-list-element>portal:service=Interceptor,type=Component,name=SecureTransport</depends-list-element> - <depends-list-element>portal:service=Interceptor,type=Component,name=ContextTracker</depends-list-element> - <depends-list-element>portal:service=Interceptor,type=Component,name=SessionPreDispatch</depends-list-element> - <depends-list-element>portal:service=Interceptor,type=Component,name=ContextDispatcher</depends-list-element> - <depends-list-element>portal:service=Interceptor,type=Component,name=SessionPostDispatch</depends-list-element> - <depends-list-element>portal:service=Interceptor,type=Component,name=Bridge</depends-list-element> - <depends-list-element>portal:service=Interceptor,type=Component,name=WindowStates</depends-list-element> - <depends-list-element>portal:service=Interceptor,type=Component,name=Modes</depends-list-element> - <depends-list-element>portal:service=Interceptor,type=Component,name=Cache</depends-list-element> - <depends-list-element>portal:service=Interceptor,type=Component,name=Navigation</depends-list-element> - <depends-list-element>portal:service=Interceptor,type=Component,name=Header</depends-list-element> - <depends-list-element>portal:service=Interceptor,type=Component,name=Transaction</depends-list-element> - </depends-list> - </mbean> - - <!-- Theme and layout services --> - <mbean - code="org.jboss.portal.theme.invocation.LayoutInterceptor" - name="portal:service=Interceptor,type=Page,name=Layout" - xmbean-dd="org/jboss/portal/theme/invocation/LayoutInterceptor.xml"> - </mbean> - <mbean - code="org.jboss.portal.theme.invocation.ThemeInterceptor" - name="portal:service=Interceptor,type=Page,name=Theme" - xmbean-dd="org/jboss/portal/theme/invocation/ThemeInterceptor.xml"> - </mbean> - <mbean - code="org.jboss.portal.theme.invocation.RenderSetInterceptor" - name="portal:service=Interceptor,type=Page,name=RenderSet" - xmbean-dd="org/jboss/portal/theme/invocation/RenderSetInterceptor.xml"> - </mbean> - <mbean - code="org.jboss.portal.theme.invocation.StrategyInterceptor" - name="portal:service=Interceptor,type=Page,name=Strategy" - xmbean-dd="org/jboss/portal/theme/invocation/StrategyInterceptor.xml"> - </mbean> - <mbean - code="org.jboss.portal.server.impl.invocation.JBossInterceptorStack" - name="portal:service=InterceptorStack,type=Page" - xmbean-dd="org/jboss/portal/server/impl/invocation/JBossInterceptorStack.xml"> - <depends-list optional-attribute-name="InterceptorNames"> - <depends-list-element>portal:service=Interceptor,type=Page,name=Layout</depends-list-element> - <depends-list-element>portal:service=Interceptor,type=Page,name=Theme</depends-list-element> - <depends-list-element>portal:service=Interceptor,type=Page,name=RenderSet</depends-list-element> - <depends-list-element>portal:service=Interceptor,type=Page,name=Strategy</depends-list-element> - </depends-list> - </mbean> - <mbean - code="org.jboss.portal.theme.impl.ThemeServiceImpl" - name="portal:service=ThemeService" - xmbean-dd="org/jboss/portal/theme/impl/ThemeServiceImpl.xml"> - </mbean> - <mbean - code="org.jboss.portal.theme.impl.LayoutServiceImpl" - name="portal:service=LayoutService" - xmbean-dd="org/jboss/portal/theme/impl/LayoutServiceImpl.xml"> - </mbean> - <mbean - code="org.jboss.portal.theme.impl.page.PageServiceImpl" - name="portal:service=PageService" - xmbean-dd="org/jboss/portal/theme/impl/page/PageServiceImpl.xml"> - <depends optional-attribute-name="LayoutService" proxy-type="attribute">portal:service=LayoutService</depends> - <depends optional-attribute-name="ThemeService" proxy-type="attribute">portal:service=ThemeService</depends> - <depends optional-attribute-name="PageStack" proxy-type="attribute">portal:service=InterceptorStack,type=Page</depends> - </mbean> - - <!-- - | Uncomment in clustered mode : replicated cache for hibernate - - <mbean - code="org.jboss.cache.TreeCache" - name="portal:service=TreeCache,type=hibernate"> - <attribute name="TransactionManagerLookupClass">org.jboss.cache.JBossTransactionManagerLookup</attribute> - <attribute name="IsolationLevel">REPEATABLE_READ</attribute> - <attribute name="CacheMode">REPL_SYNC</attribute> - <attribute name="ClusterName">portal.hibernate</attribute> - </mbean> - <mbean - code="org.jboss.portal.security.impl.store.JBossTreeCacheProvider" - name="portal:service=TreeCacheProvider,type=hibernate" - xmbean-dd="org/jboss/portal/security/impl/store/JBossTreeCacheProvider.xml"> - <depends optional-attribute-name="CacheName">portal:service=TreeCache,type=hibernate</depends> - </mbean> - - --> - - <!-- Session factories --> - <mbean - code="org.jboss.portal.core.hibernate.SessionFactoryBinder" - name="portal:service=Hibernate" - xmbean-dd="org/jboss/portal/core/hibernate/SessionFactoryBinder.xml"> - <depends>jboss.jca:service=DataSourceBinding,name=PortalDS</depends> - <!-- Uncomment in clustered mode : hibernate depends on its tree cache service - <depends>portal:service=TreeCacheProvider,type=hibernate</depends> - --> - <attribute name="DoChecking">true</attribute> - <attribute name="ConfigLocation">conf/hibernate/user/hibernate.cfg.xml</attribute> - <attribute name="SetupLocation">conf/hibernate/user/setup.txt</attribute> - </mbean> - <mbean - code="org.jboss.portal.core.hibernate.SessionFactoryBinder" - name="portal:service=Hibernate,type=globalinstance" - xmbean-dd="org/jboss/portal/core/hibernate/SessionFactoryBinder.xml"> - <depends>jboss.jca:service=DataSourceBinding,name=PortalDS</depends> - <!-- Uncomment in clustered mode : hibernate depends on its tree cache service - <depends>portal:service=TreeCacheProvider,type=hibernate</depends> - --> - <attribute name="DoChecking">true</attribute> - <attribute name="ConfigLocation">conf/hibernate/instance/hibernate.cfg.xml</attribute> - </mbean> - <mbean - code="org.jboss.portal.core.hibernate.SessionFactoryBinder" - name="portal:service=Hibernate,type=globalportal" - xmbean-dd="org/jboss/portal/core/hibernate/SessionFactoryBinder.xml"> - <depends>jboss.jca:service=DataSourceBinding,name=PortalDS</depends> - <!-- Uncomment in clustered mode : hibernate depends on its tree cache service - <depends>portal:service=TreeCacheProvider,type=hibernate</depends> - --> - <attribute name="DoChecking">true</attribute> - <attribute name="ConfigLocation">conf/hibernate/portal/hibernate.cfg.xml</attribute> - </mbean> - - <!-- Modules --> - <mbean - code="org.jboss.portal.core.impl.user.UserModuleImpl" - name="portal:service=Module,type=User" - xmbean-dd="org/jboss/portal/core/impl/user/UserModuleImpl.xml"> - <depends optional-attribute-name="HibernateProvider" proxy-type="attribute">portal:service=Hibernate</depends> - <attribute name="JNDIName">java:portal/UserModule</attribute> - </mbean> - <mbean - code="org.jboss.portal.core.impl.role.RoleModuleImpl" - name="portal:service=Module,type=Role" - xmbean-dd="org/jboss/portal/core/impl/role/RoleModuleImpl.xml"> - <depends optional-attribute-name="HibernateProvider" proxy-type="attribute">portal:service=Hibernate</depends> - <attribute name="JNDIName">java:portal/RoleModule</attribute> - </mbean> - <!-- - <mbean - code="org.jboss.portal.core.impl.security.SecurityModuleImpl" - name="portal:service=Module,type=Security" - xmbean-dd="org/jboss/portal/core/impl/security/SecurityModuleImpl.xml"> - <depends>portal:service=Hibernate</depends> - <depends optional-attribute-name="Tree" proxy-type="attribute">portal:service=Tree</depends> - <attribute name="JNDIName">java:portal/SecurityModule</attribute> - </mbean> - --> - <mbean - code="org.jboss.portal.core.impl.mail.MailModuleImpl" - name="portal:service=Module,type=Mail" - xmbean-dd="org/jboss/portal/core/impl/mail/MailModuleImpl.xml"> - <depends>jboss:service=Mail</depends> - <depends>portal:service=Module,type=User</depends> - <attribute name="QueueCapacity">-1</attribute> - <attribute name="Gateway">localhost</attribute> - <attribute name="SmtpUser"></attribute> - <attribute name="SmtpPassword"></attribute> - <attribute name="JavaMailDebugEnabled">false</attribute> - <attribute name="SMTPConnectionTimeout">100000</attribute> - <attribute name="SMTPTimeout">10000</attribute> - <attribute name="JNDIName">java:portal/MailModule</attribute> - </mbean> - <mbean - code="org.jboss.security.auth.login.DynamicLoginConfig" - name="portal:service=JAASLoginModule"> - <depends optional-attribute-name="LoginConfigService">jboss.security:service=XMLLoginConfig</depends> - <depends optional-attribute-name="SecurityManagerService">jboss.security:service=JaasSecurityManager</depends> - <attribute name="AuthConfig">conf/login-config.xml</attribute> - </mbean> - - <!-- Registries --> - <mbean - code="org.jboss.portal.server.impl.app.JBossWebAppRegistryImpl" - name="portal:service=WebAppRegistry" - xmbean-dd="org/jboss/portal/server/impl/app/JBossWebAppRegistryImpl.xml"> - </mbean> - - <!-- Listener registry --> - <mbean - code="org.jboss.portal.core.event.PortalEventListenerRegistryImpl" - name="portal:service=ListenerRegistry" - xmbean-dd="org/jboss/portal/core/event/PortalEventListenerRegistryImpl.xml"> - </mbean> - - <!-- A sample listener --> - <mbean - code="org.jboss.portal.core.event.PortalEventListenerServiceImpl" - name="portal:service=ListenerService,type=test_listener" - xmbean-dd="org/jboss/portal/core/event/PortalEventListenerServiceImpl.xml"> - <depends optional-attribute-name="Registry" proxy-type="attribute">portal:service=ListenerRegistry</depends> - <attribute name="RegistryId">test_listener</attribute> - <attribute name="ListenerClassName">org.jboss.portal.core.portlet.test.event.PortletB$Listener</attribute> - </mbean> - - <!-- The different containers --> - <mbean - code="org.jboss.portal.core.impl.model.instance.PersistentInstanceContainer" - name="portal:container=Instance,type=global" - xmbean-dd="org/jboss/portal/core/impl/model/instance/PersistentInstanceContainer.xml"> - <depends optional-attribute-name="HibernateProvider" proxy-type="attribute">portal:service=Hibernate,type=globalinstance</depends> - </mbean> - <mbean - code="org.jboss.portal.core.impl.model.portal.PersistentPortalObjectContainer" - name="portal:container=PortalObject,type=global" - xmbean-dd="org/jboss/portal/core/impl/model/portal/PersistentPortalObjectContainer.xml"> - <depends optional-attribute-name="PortalEventListenerRegistry" proxy-type="attribute">portal:service=ListenerRegistry</depends> - <depends optional-attribute-name="HibernateProvider" proxy-type="attribute">portal:service=Hibernate,type=globalportal</depends> - </mbean> - - <!-- Define the command mappers --> - <mbean - code="org.jboss.portal.core.command.mapper.CanonicalCommandMapper" - name="portal:mapper=Canonical" - xmbean-dd="org/jboss/portal/core/command/mapper/CanonicalCommandMapper.xml"> - </mbean> - <mbean - code="org.jboss.portal.core.command.mapper.PrefixDelegatingCommandMapperService" - name="portal:mapper=PrefixDelegating" - xmbean-dd="org/jboss/portal/core/command/mapper/PrefixDelegatingCommandMapperService.xml"> - <depends optional-attribute-name="NextMapper" proxy-type="attribute">portal:mapper=Canonical</depends> - </mbean> - <mbean - code="org.jboss.portal.core.model.portal.DefaultPortalCommandMapper" - name="portal:mapper=DefaultPortal" - xmbean-dd="org/jboss/portal/core/model/portal/DefaultPortalCommandMapper.xml"> - <depends optional-attribute-name="NextMapper" proxy-type="attribute">portal:mapper=PrefixDelegating</depends> - <depends optional-attribute-name="Container" - proxy-type="attribute">portal:container=PortalObject,type=global</depends> - </mbean> - <mbean - code="org.jboss.portal.core.model.portal.PortalObjectCommandMapper" - name="portal:mapper=PortalObject,type=global" - xmbean-dd="org/jboss/portal/core/model/portal/PortalObjectCommandMapper.xml"> - <attribute name="Prefix">portal</attribute> - <depends optional-attribute-name="Mapper" proxy-type="attribute">portal:mapper=PrefixDelegating</depends> - <depends optional-attribute-name="Container" proxy-type="attribute">portal:container=PortalObject,type=global</depends> - </mbean> - - <!-- Labs command mapper --> - <mbean - code="org.jboss.labs.mapper.LabsCommandMapper" - name="portal:mapper=Labs" - xmbean-dd="org/jboss/labs/mapper/LabsCommandMapper.xml"> - <depends>shotoku:service=shotoku</depends> - <depends optional-attribute-name="NextMapper" proxy-type="attribute">portal:mapper=DefaultPortal</depends> - <depends optional-attribute-name="Container" - proxy-type="attribute">portal:container=PortalObject,type=global</depends> - </mbean> - - <mbean - code="org.jboss.portal.core.CoreController" - name="portal:controller=Request" - xmbean-dd="org/jboss/portal/core/CoreController.xml"> - <depends optional-attribute-name="PageService" proxy-type="attribute">portal:service=PageService</depends> - <depends optional-attribute-name="CommandMapper" proxy-type="attribute">portal:mapper=Labs</depends> - <depends optional-attribute-name="PortletStack" proxy-type="attribute">portal:service=InterceptorStack,type=Component</depends> - <depends optional-attribute-name="CommandStack" proxy-type="attribute">portal:service=InterceptorStack,type=Command</depends> - <depends optional-attribute-name="WebAppRegistry" proxy-type="attribute">portal:service=WebAppRegistry</depends> - <depends optional-attribute-name="PortalObjectContainer" proxy-type="attribute">portal:container=PortalObject,type=global</depends> - <depends optional-attribute-name="InstanceContainer" proxy-type="attribute">portal:container=Instance,type=global</depends> - </mbean> - - <mbean - code="org.jboss.portal.server.impl.ServerImpl" - name="portal:service=Server" - xmbean-dd="org/jboss/portal/server/impl/ServerImpl.xml"> - <depends optional-attribute-name="Config" proxy-type="attribute">portal:service=ServerConfig</depends> - </mbean> - - <!-- --> - <mbean - code="org.jboss.portal.server.deployment.jboss.ServerDeployer" - name="portal:deployer=PortalWebApp"> - <depends>jboss.system:service=MainDeployer</depends> - <depends>portal:container=PortalObject,type=global</depends> - <depends>portal:container=Instance,type=global</depends> - <depends optional-attribute-name="PortalServer" proxy-type="attribute">portal:service=Server</depends> - </mbean> - - <!-- Deployment factories --> - <mbean - code="org.jboss.portal.core.deployment.jboss.ObjectDeploymentFactory" - name="portal:deploymentFactory=Object" - xmbean-dd="org/jboss/portal/core/deployment/jboss/ObjectDeploymentFactory.xml"> - <depends optional-attribute-name="Deployer" proxy-type="attribute">portal:deployer=PortalWebApp</depends> - <depends optional-attribute-name="PortalObjectContainer" proxy-type="attribute">portal:container=PortalObject,type=global</depends> - <depends optional-attribute-name="InstanceContainer" proxy-type="attribute">portal:container=Instance,type=global</depends> - <depends optional-attribute-name="PortalObjectPolicyConfig" proxy-type="attribute">portal:policy=PortalPolicyConfigStore,type=PortalObject</depends> - <depends optional-attribute-name="InstancePolicyConfig" proxy-type="attribute">portal:policy=PortalPolicyConfigStore,type=Instance</depends> - <attribute name="SetupLocation">conf/data/default-object.xml</attribute> - <!-- Set to false in clustered mode, otherwise set to true --> - <attribute name="RegistrationControlledByService">true</attribute> - </mbean> - <mbean - code="org.jboss.portal.core.deployment.jboss.PortletAppDeploymentFactory" - name="portal:deploymentFactory=PortletApp" - xmbean-dd="org/jboss/portal/core/deployment/jboss/PortletAppDeploymentFactory.xml"> - <attribute name="APIFactoryClassName">org.jboss.portlet.JBossAPIFactory</attribute> - <depends optional-attribute-name="Deployer" proxy-type="attribute">portal:deployer=PortalWebApp</depends> - <depends optional-attribute-name="WebAppRegistry" proxy-type="attribute">portal:service=WebAppRegistry</depends> - <depends optional-attribute-name="Config" proxy-type="attribute">portal:service=ServerConfig</depends> - <depends optional-attribute-name="ComponentPolicyConfig" proxy-type="attribute">portal:policy=PortalPolicyConfigStore,type=Component</depends> - </mbean> - <mbean - code="org.jboss.portal.theme.deployment.jboss.LayoutDeploymentFactory" - name="portal:deploymentFactory=Layout" - xmbean-dd="org/jboss/portal/theme/deployment/jboss/LayoutDeploymentFactory.xml"> - <depends optional-attribute-name="Deployer" proxy-type="attribute">portal:deployer=PortalWebApp</depends> - <depends optional-attribute-name="LayoutService" proxy-type="attribute">portal:service=LayoutService</depends> - </mbean> - <mbean - code="org.jboss.portal.theme.deployment.jboss.LayoutFeaturesDeploymentFactory" - name="portal:deploymentFactory=LayoutFeatures" - xmbean-dd="org/jboss/portal/theme/deployment/jboss/LayoutFeaturesDeploymentFactory.xml"> - <depends optional-attribute-name="Deployer" proxy-type="attribute">portal:deployer=PortalWebApp</depends> - <depends optional-attribute-name="LayoutService" proxy-type="attribute">portal:service=LayoutService</depends> - </mbean> - <mbean - code="org.jboss.portal.theme.deployment.jboss.ThemeDeploymentFactory" - name="portal:deploymentFactory=Theme" - xmbean-dd="org/jboss/portal/theme/deployment/jboss/ThemeDeploymentFactory.xml"> - <depends optional-attribute-name="Deployer" proxy-type="attribute">portal:deployer=PortalWebApp</depends> - <depends optional-attribute-name="ThemeService" proxy-type="attribute">portal:service=ThemeService</depends> - </mbean> - <mbean - code="org.jboss.portal.server.deployment.WebAppAdapter" - name="portal:deployer=Adapter" - xmbean-dd="org/jboss/portal/server/deployment/WebAppAdapter.xml"> - <depends>portal:deploymentFactory=Object</depends> - <depends>portal:deploymentFactory=PortletApp</depends> - <depends>portal:deploymentFactory=Layout</depends> - <depends>portal:deploymentFactory=LayoutFeatures</depends> - <depends>portal:deploymentFactory=Theme</depends> - <depends>portal:service=Module,type=User</depends> - <depends>portal:service=Module,type=Role</depends> - <depends>portal:service=Module,type=Mail</depends> - <depends optional-attribute-name="Deployer" proxy-type="attribute">portal:deployer=PortalWebApp</depends> - <depends optional-attribute-name="InterceptedDeployer">jboss.web:service=WebServer</depends> - </mbean> - - <!-- - | Uncomment in cluster mode : have the deployment of objects run as a clustered singleton - - <mbean - code="org.jboss.ha.singleton.HASingletonController" - name="jboss.portal:service=Controller,target=ObjectDeploymentFactory"> - <depends>jboss:service=DefaultPartition</depends> - <depends>portal:deploymentFactory=Object</depends> - <attribute name="TargetName">portal:deploymentFactory=Object</attribute> - <attribute name="TargetStartMethod">registerFactory</attribute> - <attribute name="TargetStopMethod">unregisterFactory</attribute> - </mbean> - - --> -</server> \ No newline at end of file +<?xml version="1.0" encoding="UTF-8"?> +<server> + + <!-- Server configuration service --> + <mbean + code="org.jboss.portal.server.config.ServerConfigService" + name="portal:service=ServerConfig" + xmbean-dd="org/jboss/portal/server/config/ServerConfigService.xml"> + <attribute name="ConfigLocation">conf/config.xml</attribute> + </mbean> + + <!-- Jacc policy configuration --> + <mbean + code="org.jboss.portal.security.impl.jacc.PortalJaccPolicy" + name="jboss.security:service=JaccPolicyProvider" + xmbean-dd="org/jboss/portal/security/impl/jacc/PortalJaccPolicy.xml"> + <attribute name="ExternalPermissionTypes"> + org.jboss.portal.core.security.PortalObjectPermission, + org.jboss.portal.core.security.InstancePermission, + org.jboss.portal.core.security.ComponentPermission + </attribute> + </mbean> + + <!-- Security provider --> + <!-- todo when the xmbean loading is fixed in JBoss move the xmbean descriptor to a resource file : http://jira.jboss.com/jira/browse/JBAS-2501 --> + <mbean + code="org.jboss.portal.security.impl.jacc.JBossSecurityProviderImpl" + name="portal:service=SecurityProvider" + xmbean-dd=""> + <xmbean> + <descriptors> + <injection id="MBeanServerType" setMethod="setMBeanServer"/> + <injection id="ObjectNameType" setMethod="setObjectName"/> + </descriptors> + <attribute access="read-write" getMethod="getPolicyName" setMethod="setPolicyName"> + <description>The policy provider MBean name</description> + <name>PolicyName</name> + <type>javax.management.ObjectName</type> + </attribute> + <attribute access="read-write" getMethod="getPolicyAttributeName" setMethod="setPolicyAttributeName"> + <description>The Policy attribute name on the PolicyName MBean</description> + <name>PolicyAttributeName</name> + <type>java.lang.String</type> + </attribute> + <attribute access="read-write" getMethod="getConfig" setMethod="setConfig"> + <description>The Server Config</description> + <name>ConfigName</name> + <type>javax.management.ObjectName</type> + </attribute> + <attribute access="read-write" getMethod="getServerConfig"> + <description>(no description)</description> + <name>ServerConfig</name> + <type>org.jboss.portal.server.config.ServerConfig</type> + <descriptors> + <persistence/> + </descriptors> + </attribute> + <attribute access="read-write" getMethod="getPolicy"> + <description>(no description)</description> + <name>Policy</name> + <type>java.security.Policy</type> + <descriptors> + <persistence/> + </descriptors> + </attribute> + <operation impact="ACTION_INFO"> + <description>(no description)</description> + <name>inService</name> + <parameter> + <description>(no description)</description> + <name>policyContextID</name> + <type>java.lang.String</type> + </parameter> + <return-type>boolean</return-type> + <descriptors> + </descriptors> + </operation> + <operation impact="ACTION_INFO"> + <description>(no description)</description> + <name>getPolicyConfiguration</name> + <parameter> + <description>(no description)</description> + <name>policyContextID</name> + <type>java.lang.String</type> + </parameter> + <parameter> + <description>(no description)</description> + <name>remove</name> + <type>boolean</type> + </parameter> + <return-type>javax.security.jacc.PolicyConfiguration</return-type> + <descriptors> + </descriptors> + </operation> + <operation> + <name>start</name> + </operation> + <operation> + <name>stop</name> + </operation> + </xmbean> + <attribute name="PolicyName">jboss.security:service=JaccPolicyProvider</attribute> + <attribute name="PolicyAttributeName">PolicyProxy</attribute> + <attribute name="ConfigName">portal:service=ServerConfig</attribute> + </mbean> + <mbean + code="org.jboss.portal.security.impl.jacc.PortalPolicyServiceImpl" + name="portal:service=PolicyService" + xmbean-dd="org/jboss/portal/security/impl/jacc/PortalPolicyServiceImpl.xml"> + <depends optional-attribute-name="SecurityProvider" proxy-type="attribute">portal:service=SecurityProvider</depends> + </mbean> + <mbean + code="org.jboss.portal.security.impl.jacc.JaccPortalPolicyConfigurator" + name="portal:policy=JaccPortalPolicyConfigurator" + xmbean-dd="org/jboss/portal/security/impl/jacc/JaccPortalPolicyConfigurator.xml"> + <depends optional-attribute-name="JBossSecurityProvider" proxy-type="attribute">portal:service=SecurityProvider</depends> + <depends optional-attribute-name="PermissionFactory" proxy-type="attribute">portal:service=PortalPermissionFactory</depends> + </mbean> + + <!-- Persistent cache for portal objeccts and instances security stores --> + <mbean + code="org.jboss.cache.TreeCache" + name="portal:service=TreeCache,type=persistent"> + <depends>jboss.jca:service=DataSourceBinding,name=PortalDS</depends> + <attribute name="TransactionManagerLookupClass">org.jboss.cache.JBossTransactionManagerLookup</attribute> + <attribute name="IsolationLevel">REPEATABLE_READ</attribute> + <!-- Set to REPL_SYNC in clustered mode, otherwise LOCAL --> + <attribute name="CacheMode">LOCAL</attribute> + <attribute name="ClusterName">portal.security</attribute> + <attribute name="FetchStateOnStartup">true</attribute> + <attribute name="CacheLoaderClass">org.jboss.portal.core.security.store.HibernateCacheLoader</attribute> + <attribute name="CacheLoaderConfig">config.location=conf/hibernate/security/hibernate.cfg.xml</attribute> + <attribute name="CacheLoaderShared">true</attribute> + <attribute name="CacheLoaderFetchTransientState">false</attribute> + <attribute name="CacheLoaderFetchPersistentState">true</attribute> + <attribute name="CacheLoaderPreload">/</attribute> + </mbean> + <mbean + code="org.jboss.portal.security.impl.store.JBossTreeCacheProvider" + name="portal:service=TreeCacheProvider,type=persistent" + xmbean-dd="org/jboss/portal/security/impl/store/JBossTreeCacheProvider.xml"> + <depends optional-attribute-name="CacheName">portal:service=TreeCache,type=persistent</depends> + </mbean> + + <!-- Transient cache for component security store --> + <mbean + code="org.jboss.cache.TreeCache" + name="portal:service=TreeCache,type=transient"> + <attribute name="TransactionManagerLookupClass">org.jboss.cache.JBossTransactionManagerLookup</attribute> + <attribute name="IsolationLevel">REPEATABLE_READ</attribute> + <attribute name="CacheMode">LOCAL</attribute> + </mbean> + <mbean + code="org.jboss.portal.security.impl.store.JBossTreeCacheProvider" + name="portal:service=TreeCacheProvider,type=transient" + xmbean-dd="org/jboss/portal/security/impl/store/JBossTreeCacheProvider.xml"> + <depends optional-attribute-name="CacheName">portal:service=TreeCache,type=transient</depends> + </mbean> + + <!-- --> + <mbean + code="org.jboss.portal.security.impl.JBossPortalPolicyConfigServiceImpl" + name="portal:policy=PortalPolicyConfigService" + xmbean-dd="org/jboss/portal/security/impl/JBossPortalPolicyConfigServiceImpl.xml"> + </mbean> + <mbean + code="org.jboss.portal.security.impl.JBossPortalPolicyConfigStoreImpl" + name="portal:policy=PortalPolicyConfigStore,type=PortalObject" + xmbean-dd="org/jboss/portal/security/impl/JBossPortalPolicyConfigStoreImpl.xml"> + <depends optional-attribute-name="ConfigListener" proxy-type="attribute">portal:policy=JaccPortalPolicyConfigurator</depends> + <depends optional-attribute-name="CacheProvider" proxy-type="attribute">portal:service=TreeCacheProvider,type=persistent</depends> + <depends optional-attribute-name="PortalPolicyConfigService" proxy-type="attribute">portal:policy=PortalPolicyConfigService</depends> + <attribute name="PermissionType">portalobject</attribute> + <attribute name="Prefix">portalobject</attribute> + </mbean> + <mbean + code="org.jboss.portal.security.impl.JBossPortalPolicyConfigStoreImpl" + name="portal:policy=PortalPolicyConfigStore,type=Instance" + xmbean-dd="org/jboss/portal/security/impl/JBossPortalPolicyConfigStoreImpl.xml"> + <depends optional-attribute-name="ConfigListener" proxy-type="attribute">portal:policy=JaccPortalPolicyConfigurator</depends> + <depends optional-attribute-name="CacheProvider" proxy-type="attribute">portal:service=TreeCacheProvider,type=persistent</depends> + <depends optional-attribute-name="PortalPolicyConfigService" proxy-type="attribute">portal:policy=PortalPolicyConfigService</depends> + <attribute name="PermissionType">instance</attribute> + <attribute name="Prefix">instance</attribute> + </mbean> + <mbean + code="org.jboss.portal.security.impl.JBossPortalPolicyConfigStoreImpl" + name="portal:policy=PortalPolicyConfigStore,type=Component" + xmbean-dd="org/jboss/portal/security/impl/JBossPortalPolicyConfigStoreImpl.xml"> + <depends optional-attribute-name="ConfigListener" proxy-type="attribute">portal:policy=JaccPortalPolicyConfigurator</depends> + <depends optional-attribute-name="CacheProvider" proxy-type="attribute">portal:service=TreeCacheProvider,type=transient</depends> + <depends optional-attribute-name="PortalPolicyConfigService" proxy-type="attribute">portal:policy=PortalPolicyConfigService</depends> + <attribute name="PermissionType">component</attribute> + <attribute name="Prefix">component</attribute> + </mbean> + <mbean + code="org.jboss.portal.security.impl.JBossPortalPermissionFactory" + name="portal:service=PortalPermissionFactory" + xmbean-dd="org/jboss/portal/security/impl/JBossPortalPermissionFactory.xml"> + <attribute name="Config"> + portalobject=org.jboss.portal.core.security.PortalObjectPermission + instance=org.jboss.portal.core.security.InstancePermission + component=org.jboss.portal.core.security.ComponentPermission + </attribute> + </mbean> + + <!-- Server stack --> + <mbean + code="org.jboss.portal.core.aspects.server.TransactionInterceptor" + name="portal:service=Interceptor,type=Server,name=Transaction" + xmbean-dd="org/jboss/portal/core/aspects/server/TransactionInterceptor.xml"> + </mbean> + <mbean + code="org.jboss.portal.server.aspects.server.SessionInvalidatorInterceptor" + name="portal:service=Interceptor,type=Server,name=SessionInvalidator" + xmbean-dd="org/jboss/portal/server/aspects/server/SessionInvalidatorInterceptor.xml"> + </mbean> + <mbean + code="org.jboss.portal.core.aspects.server.UserInterceptor" + name="portal:service=Interceptor,type=Server,name=User" + xmbean-dd="org/jboss/portal/core/aspects/server/UserInterceptor.xml"> + </mbean> + <mbean + code="org.jboss.portal.core.aspects.server.LocaleInterceptor" + name="portal:service=Interceptor,type=Server,name=Locale" + xmbean-dd="org/jboss/portal/core/aspects/server/LocaleInterceptor.xml"> + </mbean> + <mbean + code="org.jboss.portal.server.aspects.server.ContentTypeInterceptor" + name="portal:service=Interceptor,type=Server,name=ContentType" + xmbean-dd="org/jboss/portal/server/aspects/server/ContentTypeInterceptor.xml"> + </mbean> + <mbean + code="org.jboss.portal.core.aspects.server.PolicyAssociationInterceptor" + name="portal:service=Interceptor,type=Server,name=PolicyAssociation" + xmbean-dd="org/jboss/portal/core/aspects/server/PolicyAssociationInterceptor.xml"> + <depends optional-attribute-name="PolicyService" proxy-type="attribute">portal:service=PolicyService</depends> + </mbean> + <mbean + code="org.jboss.portal.core.aspects.server.SubjectAssociationInterceptor" + name="portal:service=Interceptor,type=Server,name=SubjectAssociation" + xmbean-dd="org/jboss/portal/core/aspects/server/SubjectAssociationInterceptor.xml"> + </mbean> + <mbean + code="org.jboss.portal.server.impl.invocation.JBossInterceptorStack" + name="portal:service=InterceptorStack,type=Server" + xmbean-dd="org/jboss/portal/server/impl/invocation/JBossInterceptorStack.xml"> + <depends-list optional-attribute-name="InterceptorNames"> + <depends-list-element>portal:service=Interceptor,type=Server,name=Transaction</depends-list-element> + <depends-list-element>portal:service=Interceptor,type=Server,name=SessionInvalidator</depends-list-element> + <depends-list-element>portal:service=Interceptor,type=Server,name=User</depends-list-element> + <depends-list-element>portal:service=Interceptor,type=Server,name=Locale</depends-list-element> + <depends-list-element>portal:service=Interceptor,type=Server,name=ContentType</depends-list-element> + <depends-list-element>portal:service=Interceptor,type=Server,name=PolicyAssociation</depends-list-element> + <depends-list-element>portal:service=Interceptor,type=Server,name=SubjectAssociation</depends-list-element> + </depends-list> + </mbean> + + <!-- Command stack --> + <mbean + code="org.jboss.portal.core.aspects.controller.NavigationInterceptor" + name="portal:service=Interceptor,type=Command,name=Navigation" + xmbean-dd="org/jboss/portal/core/aspects/controller/NavigationInterceptor.xml"> + </mbean> + <mbean + code="org.jboss.portal.core.aspects.controller.PortalNodeInterceptor" + name="portal:service=Interceptor,type=Command,name=PortalNode" + xmbean-dd="org/jboss/portal/core/aspects/controller/PortalNodeInterceptor.xml"> + </mbean> + <mbean + code="org.jboss.portal.core.aspects.controller.PolicyEnforcementInterceptor" + name="portal:service=Interceptor,type=Command,name=PolicyEnforcement" + xmbean-dd="org/jboss/portal/core/aspects/controller/PolicyEnforcementInterceptor.xml"> + <depends optional-attribute-name="PortalPermissionFactory" proxy-type="attribute">portal:service=PortalPermissionFactory</depends> + </mbean> + <mbean + code="org.jboss.portal.core.aspects.controller.EventBroadcasterInterceptor" + name="portal:service=Interceptor,type=Command,name=EventBroadcaster" + xmbean-dd="org/jboss/portal/core/aspects/controller/EventBroadcasterInterceptor.xml"> + </mbean> + <mbean + code="org.jboss.portal.server.impl.invocation.JBossInterceptorStack" + name="portal:service=InterceptorStack,type=Command" + xmbean-dd="org/jboss/portal/server/impl/invocation/JBossInterceptorStack.xml"> + <depends-list optional-attribute-name="InterceptorNames"> + <depends-list-element>portal:service=Interceptor,type=Command,name=Navigation</depends-list-element> + <depends-list-element>portal:service=Interceptor,type=Command,name=PortalNode</depends-list-element> + <depends-list-element>portal:service=Interceptor,type=Command,name=PolicyEnforcement</depends-list-element> + <depends-list-element>portal:service=Interceptor,type=Command,name=EventBroadcaster</depends-list-element> + </depends-list> + </mbean> + + <!-- Portlet stack --> + <mbean + code="org.jboss.portal.portlet.aspects.component.ValveInterceptor" + name="portal:service=Interceptor,type=Component,name=Valve" + xmbean-dd="org/jboss/portal/portlet/aspects/component/ValveInterceptor.xml"> + </mbean> + <mbean + code="org.jboss.portal.server.aspects.component.ContextTrackerInterceptor" + name="portal:service=Interceptor,type=Component,name=ContextTracker" + xmbean-dd="org/jboss/portal/server/aspects/component/ContextTrackerInterceptor.xml"> + </mbean> + <mbean + code="org.jboss.portal.portlet.aspects.component.SecureTransportInterceptor" + name="portal:service=Interceptor,type=Component,name=SecureTransport" + xmbean-dd="org/jboss/portal/portlet/aspects/component/SecureTransportInterceptor.xml"> + </mbean> + <mbean + code="org.jboss.portal.portlet.aspects.component.SessionPreDispatchInterceptor" + name="portal:service=Interceptor,type=Component,name=SessionPreDispatch" + xmbean-dd="org/jboss/portal/portlet/aspects/component/SessionPreDispatchInterceptor.xml"> + </mbean> + <mbean + code="org.jboss.portal.server.aspects.component.ContextDispatcherInterceptor" + name="portal:service=Interceptor,type=Component,name=ContextDispatcher" + xmbean-dd="org/jboss/portal/server/aspects/component/ContextDispatcherInterceptor.xml"> + </mbean> + <mbean + code="org.jboss.portal.portlet.aspects.component.SessionPostDispatchInterceptor" + name="portal:service=Interceptor,type=Component,name=SessionPostDispatch" + xmbean-dd="org/jboss/portal/portlet/aspects/component/SessionPostDispatchInterceptor.xml"> + </mbean> + <mbean + code="org.jboss.portal.bridge.BridgeInterceptor" + name="portal:service=Interceptor,type=Component,name=Bridge" + xmbean-dd="org/jboss/portal/bridge/BridgeInterceptor.xml"> + </mbean> + <mbean + code="org.jboss.portal.server.aspects.component.WindowStatesInterceptor" + name="portal:service=Interceptor,type=Component,name=WindowStates" + xmbean-dd="org/jboss/portal/server/aspects/component/Win... [truncated message content] |
Author: soh...@jb... Date: 2006-05-04 10:05:38 -0400 (Thu, 04 May 2006) New Revision: 4089 Added: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/DeletePost.java labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/topics/delete_post.xhtml Modified: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/Constants.java labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/forums-config.xml labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/topics/viewtopic_body.xhtml Log: http://jira.jboss.com/jira/browse/JBFORUMS-70 - Delete a Post Modified: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/Constants.java =================================================================== --- labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/Constants.java 2006-05-04 13:12:55 UTC (rev 4088) +++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/Constants.java 2006-05-04 14:05:38 UTC (rev 4089) @@ -35,6 +35,7 @@ public static final String START_REPLY = "startReply"; public static final String START_NEW_TOPIC = "startNewTopic"; public static final String START_EDIT_POST = "startEditPost"; + public static final String TOPIC_DELETED = "topicDeleted"; //---------parameter constants-------------------------------------------------------------------------------------------------- public static final String p_categoryId = "c"; public static final String p_forumId = "f"; Added: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/DeletePost.java =================================================================== --- labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/DeletePost.java 2006-05-04 13:12:55 UTC (rev 4088) +++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/DeletePost.java 2006-05-04 14:05:38 UTC (rev 4089) @@ -0,0 +1,118 @@ +/* +* JBoss, Home of Professional Open Source +* Copyright 2005, JBoss Inc., and individual contributors as indicated +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* This is free software; you can redistribute it and/or modify it +* under the terms of the GNU Lesser General Public License as +* published by the Free Software Foundation; either version 2.1 of +* the License, or (at your option) any later version. +* +* This software is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this software; if not, write to the Free +* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA +* 02110-1301 USA, or see the FSF site: http://www.fsf.org. +*/ +package org.jboss.portlet.forums.ui.action; + +import org.jboss.portlet.forums.ui.BaseController; +import org.jboss.portlet.forums.ui.Constants; +import org.jboss.portlet.forums.ui.ForumUtil; +import org.jboss.portlet.forums.ui.JSFUtil; + +import org.jboss.portlet.forums.model.Forum; +import org.jboss.portlet.forums.model.Topic; +import org.jboss.portlet.forums.model.Post; + + +/* + * Created on May 3, 2006 + * + * @author <a href="mailto:soh...@jb...">Sohil Shah</a> + */ +public class DeletePost extends ActionController +{ + //---------------------------------------------------------------------------------------------------------------------------------- + /** + * + * + */ + public DeletePost() + { + + } + //actions--------------------------------------------------------------------------------------------------------------------------------- + /** + * + */ + public String confirmDelete() + { + String navState = null; + try + { + //get the post id + int postId = -1; + String p = ForumUtil.getParameter(Constants.p_postId); + if(p!=null && p.trim().length()>0) + { + postId = Integer.parseInt(p); + } + + //setup the business objects/data of interest + Post post = BaseController.getForumsModule().findPostById(new Integer(postId)); + Topic topic = post.getTopic(); + Forum forum = topic.getForum(); + boolean isFirstPost = false; + boolean isLastPost = false; + if(topic.getFirstPost().getId().intValue()==post.getId().intValue()) + { + isFirstPost = true; + } + if(topic.getLastPost().getId().intValue()==post.getId().intValue()) + { + isLastPost = true; + } + + //now perform the actual delete operation......................... + if (isLastPost && isFirstPost) + { + // cascade delete will take care of removing + // the post + // the watches + // the poll + // the links + this.getForumsModule().removeTopic(post.getTopic()); + forum.setPostCount(forum.getPostCount() - 1); + forum.setTopicCount(forum.getTopicCount() - 1); + + //set the proper navigation state + navState = Constants.TOPIC_DELETED; + } + else + { + this.getForumsModule().removePost(post); + topic.setReplies(topic.getReplies() - 1); + forum.setPostCount(forum.getPostCount() - 1); + if(isLastPost) + { + Post lastPost = this.getForumsModule().findLastPost(topic); + topic.setLastPostDate(lastPost.getCreateDate()); + } + + //set the proper navigation state + navState = Constants.SUCCESS; + } + } + catch(Exception e) + { + JSFUtil.handleException(e); + } + return navState; + } +} Modified: labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/forums-config.xml =================================================================== --- labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/forums-config.xml 2006-05-04 13:12:55 UTC (rev 4088) +++ labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/forums-config.xml 2006-05-04 14:05:38 UTC (rev 4089) @@ -9,8 +9,8 @@ <!-- general application configuration --> <application> <!-- jbossportal-facelets integration --> - <property-resolver>org.jboss.portal.faces.el.DelegatingPropertyResolver</property-resolver> - <view-handler>com.sun.facelets.FaceletPortletViewHandler</view-handler> + <!--property-resolver>org.jboss.portal.faces.el.DelegatingPropertyResolver</property-resolver> + <view-handler>com.sun.facelets.FaceletPortletViewHandler</view-handler--> <!-- standalone facelets integration --> <!--view-handler>com.sun.facelets.FaceletViewHandler</view-handler--> @@ -258,4 +258,23 @@ <managed-bean-class>org.jboss.portlet.forums.ui.action.ModeratorAction</managed-bean-class> <managed-bean-scope>session</managed-bean-scope> </managed-bean> + + <!-- managedBean for deletePost usecase --> + <managed-bean> + <managed-bean-name>deletePost</managed-bean-name> + <managed-bean-class>org.jboss.portlet.forums.ui.action.DeletePost</managed-bean-class> + <managed-bean-scope>request</managed-bean-scope> + </managed-bean> + <navigation-rule> + <from-view-id>/views/topics/delete_post.xhtml</from-view-id> + <!-- represents delete of the selected post was successfull --> + <navigation-case> + <from-outcome>success</from-outcome> + <to-view-id>/views/topics/viewtopic_body.xhtml</to-view-id> + </navigation-case> + <navigation-case> + <from-outcome>topicDeleted</from-outcome> + <to-view-id>/views/forums/viewforum_body.xhtml</to-view-id> + </navigation-case> + </navigation-rule> </faces-config> \ No newline at end of file Added: labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/topics/delete_post.xhtml =================================================================== --- labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/topics/delete_post.xhtml 2006-05-04 13:12:55 UTC (rev 4088) +++ labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/topics/delete_post.xhtml 2006-05-04 14:05:38 UTC (rev 4089) @@ -0,0 +1,64 @@ +<!-- +/* +* JBoss, Home of Professional Open Source +* Copyright 2005, JBoss Inc., and individual contributors as indicated +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* This is free software; you can redistribute it and/or modify it +* under the terms of the GNU Lesser General Public License as +* published by the Free Software Foundation; either version 2.1 of +* the License, or (at your option) any later version. +* +* This software is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this software; if not, write to the Free +* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA +* 02110-1301 USA, or see the FSF site: http://www.fsf.org. +*/ +--> + +<div xmlns="http://www.w3.org/1999/xhtml" + xmlns:ui="http://java.sun.com/jsf/facelets" + xmlns:c="http://java.sun.com/jstl/core" + xmlns:h="http://java.sun.com/jsf/html" + xmlns:f="http://java.sun.com/jsf/core" + xmlns:t="http://myfaces.apache.org/tomahawk" + xmlns:forums="http://www.jboss.com/products/jbossportal/forums" + class="bb" +> + +<ui:composition template="/views/common/common.xhtml"> +<ui:define name="mainContent"> + + <table class="forumline" width="100%" cellspacing="1" cellpadding="3" border="0"> + <tr> + <th class="thHead" height="25" valign="middle"><span class="tableTitle">Information</span></th> + </tr> + <tr> + <td class="row1" align="center"> + <h:form> + <span class="gen"><br/> + Are you sure you want to delete this post? + <br/><br/> + <input type="hidden" name="p" value="#{param['p']}"/> + <input type="hidden" name="t" value="#{param['t']}"/> + <input type="hidden" name="f" value="#{param['f']}"/> + <h:commandButton type="submit" value="Yes" styleClass="mainoption" action="#{deletePost.confirmDelete}"/> + &nbsp;&nbsp; + <h:commandButton type="button" value="No" styleClass="liteoption" onclick="javascript:history.back();"/> + </span> + </h:form> + </td> + </tr> + </table> + + +</ui:define> +</ui:composition> + +</div> \ No newline at end of file Modified: labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/topics/viewtopic_body.xhtml =================================================================== --- labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/topics/viewtopic_body.xhtml 2006-05-04 13:12:55 UTC (rev 4088) +++ labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/topics/viewtopic_body.xhtml 2006-05-04 14:05:38 UTC (rev 4089) @@ -228,6 +228,17 @@ alt="${resource.Reply_to_topic}" /> </f:verbatim> </h:commandLink> + <!-- add the delete post link --> + <h:outputLink value="#{forums:outputLink('/views/topics/delete_post.jsf',true)}" style="text-decoration: none;"> + <f:param name="p" value="#{postrow.id}"/> + <f:param name="t" value="#{topic.topic.id}"/> + <f:param name="f" value="#{topic.topic.forum.id}"/> + <f:verbatim> + <img border="0" + src="#{forums:themeURL('resourceReplyLockedURL')}" + alt="${resource.Topic_locked}" /> + </f:verbatim> + </h:outputLink> </td> </tr> <tr> |
From: <jbo...@li...> - 2006-05-04 13:13:09
|
Author: mar...@jb... Date: 2006-05-04 09:12:55 -0400 (Thu, 04 May 2006) New Revision: 4088 Added: labs/jbossesb/trunk/ESBCore/classes/org/jboss/soa/esbcore/addressing/EPR.java labs/jbossesb/trunk/ESBCore/classes/org/jboss/soa/esbcore/addressing/PortReference.java labs/jbossesb/trunk/ESBCore/classes/org/jboss/soa/esbcore/addressing/XMLUtil.java labs/jbossesb/trunk/ESBCore/classes/org/jboss/soa/esbcore/exceptions/MarshalException.java labs/jbossesb/trunk/ESBCore/classes/org/jboss/soa/internal/esbcore/addressing/PortReferenceHelper.java Removed: labs/jbossesb/trunk/ESBCore/classes/org/jboss/soa/esbcore/addressing/EPR.java labs/jbossesb/trunk/ESBCore/classes/org/jboss/soa/internal/esbcore/addressing/EPRImpl.java Modified: labs/jbossesb/trunk/ESBCore/classes/org/jboss/soa/esbcore/impl/tcp/plugin/infrastructure/receiver/ReceiverPluginImpl.java labs/jbossesb/trunk/ESBCore/classes/org/jboss/soa/esbcore/impl/tcp/plugin/infrastructure/sender/SenderPluginImpl.java labs/jbossesb/trunk/ESBCore/classes/org/jboss/soa/esbcore/messaging/Attachment.java labs/jbossesb/trunk/ESBCore/classes/org/jboss/soa/esbcore/messaging/Body.java labs/jbossesb/trunk/ESBCore/classes/org/jboss/soa/esbcore/messaging/Context.java labs/jbossesb/trunk/ESBCore/classes/org/jboss/soa/esbcore/messaging/Fault.java labs/jbossesb/trunk/ESBCore/classes/org/jboss/soa/esbcore/messaging/Header.java labs/jbossesb/trunk/ESBCore/classes/org/jboss/soa/esbcore/messaging/Message.java labs/jbossesb/trunk/ESBCore/classes/org/jboss/soa/esbcore/tests/tcp/TcpClient.java labs/jbossesb/trunk/ESBCore/classes/org/jboss/soa/esbcore/tests/tcp/TcpService.java Log: Added initial addressing implementation and updated tests and dispatchers accordingly. http://jira.jboss.com/jira/browse/JBESB-9 Deleted: labs/jbossesb/trunk/ESBCore/classes/org/jboss/soa/esbcore/addressing/EPR.java =================================================================== --- labs/jbossesb/trunk/ESBCore/classes/org/jboss/soa/esbcore/addressing/EPR.java 2006-05-04 10:47:38 UTC (rev 4087) +++ labs/jbossesb/trunk/ESBCore/classes/org/jboss/soa/esbcore/addressing/EPR.java 2006-05-04 13:12:55 UTC (rev 4088) @@ -1,55 +0,0 @@ -package org.jboss.soa.esbcore.addressing; - -/* - * JBoss, Home of Professional Open Source - * Copyright 2006, JBoss Inc., and others contributors as indicated - * by the @authors tag. All rights reserved. - * See the copyright.txt in the distribution for a - * full listing of individual contributors. - * This copyrighted material is made available to anyone wishing to use, - * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU Lesser General Public License, v. 2.1. - * This program is distributed in the hope that it will be useful, but WITHOUT A - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A - * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - * You should have received a copy of the GNU Lesser General Public License, - * v.2.1 along with this distribution; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301, USA. - * - * (C) 2005-2006, - * @author mar...@jb... - */ - -/** - * This class represents the endpoint reference for services. - */ - -import java.net.URI; - -public interface EPR -{ - public void setTo (URI uri); - public URI getTo (); - public void setFrom (URI uri); - public URI getFrom (); - public void setReplyTo (URI uri); - public URI getReplyTo (); - public void setFaultTo (URI uri); - public URI getFaultTo (); - public void setAction (URI uri); - public URI getAction (); - public void setMessageID (URI uri); - public URI getMessageID (); -// public void setMetaData (MetaData md); -// public MetaData getMetaData (); -// public void addReferenceParameter (...); - - public void copy (EPR from); - - /* - * In lieu of toXML and fromXML - */ - public byte[] toBytes(); - public void fromBytes (byte[] b); -} \ No newline at end of file Added: labs/jbossesb/trunk/ESBCore/classes/org/jboss/soa/esbcore/addressing/EPR.java =================================================================== --- labs/jbossesb/trunk/ESBCore/classes/org/jboss/soa/esbcore/addressing/EPR.java 2006-05-04 10:47:38 UTC (rev 4087) +++ labs/jbossesb/trunk/ESBCore/classes/org/jboss/soa/esbcore/addressing/EPR.java 2006-05-04 13:12:55 UTC (rev 4088) @@ -0,0 +1,302 @@ +package org.jboss.soa.esbcore.addressing; + +/* + * JBoss, Home of Professional Open Source + * Copyright 2006, JBoss Inc., and others contributors as indicated + * by the @authors tag. All rights reserved. + * See the copyright.txt in the distribution for a + * full listing of individual contributors. + * This copyrighted material is made available to anyone wishing to use, + * modify, copy, or redistribute it subject to the terms and conditions + * of the GNU Lesser General Public License, v. 2.1. + * This program is distributed in the hope that it will be useful, but WITHOUT A + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + * You should have received a copy of the GNU Lesser General Public License, + * v.2.1 along with this distribution; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + * + * (C) 2005-2006, + * @author mar...@jb... + */ + +import org.jboss.soa.esbcore.addressing.PortReference.Extension; +import org.jboss.soa.internal.esbcore.addressing.PortReferenceHelper; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +/** + * This class represents the endpoint reference for services. + */ + +import java.net.URI; +import java.net.URISyntaxException; + +public class EPR +{ + public EPR () + { + _to = new PortReference(); + + _from = _replyTo = _relatesTo = _faultTo = null; + _action = _messageID = null; + } + + public EPR (URI uri) + { + _to = new PortReference(uri.toString()); + + _from = _replyTo = _relatesTo = _faultTo = null; + _action = _messageID = null; + } + + public void setTo (PortReference uri) + { + _to = uri; + } + + public PortReference getTo () throws URISyntaxException + { + return _to; + } + + public void setFrom (PortReference uri) + { + _from = uri; + } + + public PortReference getFrom () throws URISyntaxException + { + return _from; + } + + public void setReplyTo (PortReference uri) + { + _replyTo = uri; + } + + public PortReference getReplyTo () throws URISyntaxException + { + return _replyTo; + } + + public void setFaultTo (PortReference uri) + { + _faultTo = uri; + } + + public PortReference getFaultTo () throws URISyntaxException + { + return _faultTo; + } + + public void setRelatesTo (PortReference uri) + { + _relatesTo = uri; + } + + public PortReference getRelatesTo () throws URISyntaxException + { + return _relatesTo; + } + + public void setAction (URI uri) + { + _action = uri; + } + + public URI getAction () throws URISyntaxException + { + return _action; + } + + public void setMessageID (URI uri) + { + _messageID = uri; + } + + public URI getMessageID () throws URISyntaxException + { + return _messageID; + } + + public void copy (EPR from) + { + EPR fromImpl = (EPR) from; + + _to = fromImpl._to; + _from = fromImpl._from; + _replyTo = fromImpl._replyTo; + _relatesTo = fromImpl._relatesTo; + _faultTo = fromImpl._faultTo; + _action = fromImpl._action; + _messageID = fromImpl._messageID; + } + +// public void setMetaData (MetaData md); +// public MetaData getMetaData (); +// public void addReferenceParameter (...); + + public String toString () + { + return "To: "+_to+" From: "+_from+" ReplyTo: "+_replyTo+" FaultTo: "+_faultTo+" Action: "+_action; + } + + + public Element toXML (Document doc, Element header) + { + try + { + Element toElement = doc.createElementNS(XMLUtil.WSA_NAMESPACE_URI, XMLUtil.WSA_PREFIX+":"+XMLUtil.TO_TAG); + PortReferenceHelper.toXML(header, doc, toElement, _to, true); + header.appendChild(toElement); + + Element fromElement = doc.createElementNS(XMLUtil.WSA_NAMESPACE_URI, XMLUtil.WSA_PREFIX+":"+XMLUtil.FROM_TAG); + PortReferenceHelper.toXML(header, doc, fromElement, _from, false); + header.appendChild(fromElement); + + Element replyToElement = doc.createElementNS(XMLUtil.WSA_NAMESPACE_URI, XMLUtil.WSA_PREFIX+":"+XMLUtil.REPLY_TO_TAG); + PortReferenceHelper.toXML(header, doc, replyToElement, _from, false); + header.appendChild(replyToElement); + + Element relatesToElement = doc.createElementNS(XMLUtil.WSA_NAMESPACE_URI, XMLUtil.WSA_PREFIX+":"+XMLUtil.RELATES_TO_TAG); + PortReferenceHelper.toXML(header, doc, relatesToElement, _from, false); + header.appendChild(relatesToElement); + + Element faultToElement = doc.createElementNS(XMLUtil.WSA_NAMESPACE_URI, XMLUtil.WSA_PREFIX+":"+XMLUtil.FAULT_TO_TAG); + PortReferenceHelper.toXML(header, doc, faultToElement, _from, false); + header.appendChild(faultToElement); + + Element actionElement = doc.createElementNS(XMLUtil.WSA_NAMESPACE_URI, XMLUtil.WSA_PREFIX+":"+XMLUtil.ACTION_TAG); + actionElement.setNodeValue(_action.toString()); + header.appendChild(actionElement); + + Element messageIDElement = doc.createElementNS(XMLUtil.WSA_NAMESPACE_URI, XMLUtil.WSA_PREFIX+":"+XMLUtil.MESSAGE_IDENTIFIER_TAG); + messageIDElement.setNodeValue(_messageID.toString()); + header.appendChild(messageIDElement); + + return header; + } + catch (Exception ex) + { + ex.printStackTrace(); + + return null; + } + } + + public void fromXML (Element header) + { + try + { + NodeList nl = header.getChildNodes(); + + for (int i = 0; i < nl.getLength(); i++) + { + Node n = nl.item(i); + + if (n.getNodeName().equals(XMLUtil.WSA_PREFIX+":"+XMLUtil.TO_TAG)) + { + try + { + _to = PortReferenceHelper.fromXML((Element) n, true); + } + catch (Exception ex) + { + + } + } + + if (n.getNodeName().equals(XMLUtil.WSA_PREFIX+":"+XMLUtil.FROM_TAG)) + { + try + { + _from = PortReferenceHelper.fromXML((Element) n, false); + } + catch (Exception ex) + { + + } + } + + if (n.getNodeName().equals(XMLUtil.WSA_PREFIX+":"+XMLUtil.REPLY_TO_TAG)) + { + try + { + _replyTo = PortReferenceHelper.fromXML((Element) n, false); + } + catch (Exception ex) + { + + } + } + + if (n.getNodeName().equals(XMLUtil.WSA_PREFIX+":"+XMLUtil.RELATES_TO_TAG)) + { + try + { + _relatesTo = PortReferenceHelper.fromXML((Element) n, false); + } + catch (Exception ex) + { + + } + } + + if (n.getNodeName().equals(XMLUtil.WSA_PREFIX+":"+XMLUtil.FAULT_TO_TAG)) + { + try + { + _faultTo = PortReferenceHelper.fromXML((Element) n, false); + } + catch (Exception ex) + { + + } + } + + if (n.getNodeName().equals(XMLUtil.WSA_PREFIX+":"+XMLUtil.ACTION_TAG)) + { + try + { + _action = new URI(n.getNodeValue()); + } + catch (Exception ex) + { + + } + } + + if (n.getNodeName().equals(XMLUtil.WSA_PREFIX+":"+XMLUtil.MESSAGE_IDENTIFIER_TAG)) + { + try + { + _messageID = new URI(n.getNodeValue()); + } + catch (Exception ex) + { + + } + } + } + } + catch (Exception ex) + { + // TODO error checking!! + + ex.printStackTrace(); + } + } + + private PortReference _to; + private PortReference _from; + private PortReference _faultTo; + private PortReference _replyTo; + private PortReference _relatesTo; + private URI _action; + private URI _messageID; + +} \ No newline at end of file Added: labs/jbossesb/trunk/ESBCore/classes/org/jboss/soa/esbcore/addressing/PortReference.java =================================================================== --- labs/jbossesb/trunk/ESBCore/classes/org/jboss/soa/esbcore/addressing/PortReference.java 2006-05-04 10:47:38 UTC (rev 4087) +++ labs/jbossesb/trunk/ESBCore/classes/org/jboss/soa/esbcore/addressing/PortReference.java 2006-05-04 13:12:55 UTC (rev 4088) @@ -0,0 +1,331 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2006, JBoss Inc., and others contributors as indicated + * by the @authors tag. All rights reserved. + * See the copyright.txt in the distribution for a + * full listing of individual contributors. + * This copyrighted material is made available to anyone wishing to use, + * modify, copy, or redistribute it subject to the terms and conditions + * of the GNU Lesser General Public License, v. 2.1. + * This program is distributed in the hope that it will be useful, but WITHOUT A + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + * You should have received a copy of the GNU Lesser General Public License, + * v.2.1 along with this distribution; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + * + * (C) 2005-2006, + * @author mar...@jb... + */ + +/* + * Copyright (c) 2002, 2003, Arjuna Technologies Limited. + * + * PortReference.java + */ + +package org.jboss.soa.esbcore.addressing; + +import java.util.Iterator; +import java.util.List; +import java.util.LinkedList; +import java.util.HashMap; + + +/** + * An implementation of a WS-Addressing EPR. It needs completely rewriting after + * the interoperability workshop as it is not extensible and not guaranteed to + * work in the general case. It's morphed with the changing WS-C/WS-T and + * WS-Addr specifications and their quirks; now that WS-Addr is finalized the + * old quirks no longer need to be supported so it's best to rewrite this from + * scratch. + * + * An instance of a PortReference represents a single element in WS-A. + */ + +public class PortReference { + public PortReference() { + } + + public PortReference(String address) { + setAddress(address); + } + + public void setAddress(String address) { + _address = address; + } + + public String getAddress() { + return _address; + } + + public void addExtension(PortReference.Extension extension) { + _extensions.add(extension); + } + + // all extensions are added as the Arjuna namespace. + + public void addExtension(String value) { + addExtension(XMLUtil.INSTANCE_IDENTIFIER_TAG, XMLUtil.WSARJADDR_PREFIX, + XMLUtil.WSARJADDR_NAMESPACE_URI, value, + Extension.REFERENCE_PROPERTIES); + } + + public void addExtension(String tag, String value) { + addExtension(tag, XMLUtil.WSARJADDR_PREFIX, + XMLUtil.WSARJADDR_NAMESPACE_URI, value, + Extension.REFERENCE_PROPERTIES); + } + + /** + * Define the tag, prefix and namespace URI for the extension value. The + * parent is a refProperty. + */ + + public void addExtension(String tag, String prefix, String uri, String value) { + _extensions.add(new Extension(tag, prefix, uri, value, + Extension.REFERENCE_PROPERTIES)); + } + + /** + * Define the tag, prefix and namespace URI for the extension value. The + * parent field defines whether the attribute has a refParam, refProp or + * neither as its parent. + */ + + public void addExtension(String tag, String prefix, String uri, + String value, int parent) { + _extensions.add(new Extension(tag, prefix, uri, value, parent)); + } + + // placeholders only + + public void addPortType(String qName) { + } + + public void addServiceName(String portName, String qName) { + } + + public void addPolicy() { + } + + public String getExtensionValue(String tag) { + String extensionValue = null; + Iterator iterator = _extensions.iterator(); + + while (iterator.hasNext() && (extensionValue == null)) { + Extension extension = (Extension) iterator.next(); + + if (tag.equals(extension.getTag())) + extensionValue = extension.getValue(); + } + + return extensionValue; + } + + public Iterator getExtensions() { + return _extensions.iterator(); + } + + public void clearExtensions() { + _extensions.clear(); + } + + public String toString() { + return "PortReference < " + _address + " >"; + } + + public String extendedToString() { + String addr = "<" + XMLUtil.WSA_PREFIX + ":Address " + _address + "/>"; + + Iterator extensions = getExtensions(); + + while (extensions.hasNext()) { + Extension ext = (Extension) extensions.next(); + + addr += ", <" + XMLUtil.WSA_PREFIX + ":" + + XMLUtil.REFERENCE_PROPERTIES_TAG + " " + ext.getPrefix() + + ":" + ext.getTag() + " : " + ext.getValue() + "/>"; + } + + return "PortReference : " + addr; + } + + /** + * Is this object equal to the specified parameter? + * + * @param rhs + * The rhs object. + * @return true if the specified object is equal, false otherwise. + */ + public boolean equals(final Object rhs) { + if ((rhs != null) && (rhs.getClass() == getClass())) { + // This should really only include reference property extensions + final PortReference rhsPortReference = (PortReference) rhs; + return (equalsObject(_address, rhsPortReference._address) + && equalsObject(_extensions, rhsPortReference._extensions) + && equalsObject(_portType, rhsPortReference._portType) + && equalsObject(_serviceName, rhsPortReference._serviceName) && equalsObject( + _policies, rhsPortReference._policies)); + } + return false; + } + + /** + * Return the hash code for this object. + * + * @return the hash code value. + */ + public int hashCode() { + // Not checked for spread. + return (objectHashCode(_address, 0x1) + ^ objectHashCode(_extensions, 0x2) + ^ objectHashCode(_portType, 0x4) + ^ objectHashCode(_serviceName, 0x8) ^ objectHashCode(_policies, + 0x10)); + } + + public static class Extension { + public static final int REFERENCE_PROPERTIES = 0; + public static final int REFERENCE_PARAMETERS = 1; + public static final int NEITHER = 2; + + public Extension(String tag, String prefix, String uri) { + this(tag, prefix, uri, null, REFERENCE_PROPERTIES); + } + + public Extension(String tag, String prefix, String uri, String value) { + this(tag, prefix, uri, value, REFERENCE_PROPERTIES); + } + + public Extension(String tag, String prefix, String uri, String value, + int parent) { + _tag = tag; + _prefix = prefix; + _uri = uri; + _value = value; + _parent = parent; + } + + public int getParent() { + return _parent; + } + + public String getTag() { + return _tag; + } + + public String getPrefix() { + return _prefix; + } + + public String getURI() { + return _uri; + } + + public String getValue() { + return _value; + } + + public LinkedList getChildren() { + return _extensions; + } + + public HashMap getAttributes() { + return _attributes; + } + + public void addAttributes(HashMap props) { + _attributes = props; + } + + public void addChild(Extension child) { + if (_extensions == null) + _extensions = new LinkedList(); + + _extensions.add(child); + } + + public String toString() { + return new String("< " + _tag + ", " + _prefix + ", " + _uri + ", " + + _value + " >"); + } + + /** + * Is this object equal to the specified parameter (ignoring prefix)? + * + * @param rhs + * The rhs object. + * @return true if the specified object is equal, false otherwise. + */ + public boolean equals(final Object rhs) { + if ((rhs != null) && (rhs.getClass() == getClass())) { + final Extension rhsExtension = (Extension) rhs; + return (equalsObject(_tag, rhsExtension._tag) + && equalsObject(_uri, rhsExtension._uri) + && equalsObject(_value, rhsExtension._value) + && equalsObject(_extensions, rhsExtension._extensions) && (_parent == rhsExtension._parent)); + } + return false; + } + + /** + * Return the hash code for this object. + * + * @return the hash code value. + */ + public int hashCode() { + // Not checked for spread. + return (_parent ^ objectHashCode(_tag, 0x4) + ^ objectHashCode(_uri, 0x8) ^ objectHashCode(_value, 0x10) ^ objectHashCode( + _extensions, 0x20)); + } + + private String _tag = null; + private String _prefix = null; + private String _uri = null; + private String _value = null; + private int _parent = NEITHER; + private LinkedList _extensions = null; + private HashMap _attributes = null; + + } + + /** + * Get the hash code from the object or use the default if null. + * + * @param obj + * The object. + * @param defaultHashCode + * The default hash code. + * @return The hash code. + */ + static int objectHashCode(final Object obj, final int defaultHashCode) { + return (obj == null ? defaultHashCode : obj.hashCode()); + } + + /** + * Are the two objects equal? + * + * @param lhs + * The lhs object. + * @param rhs + * The rhs object. + * @return true if equal or both null, false otherwise. + */ + static boolean equalsObject(final Object lhs, final Object rhs) { + if (lhs == null) { + return (rhs == null); + } else { + return lhs.equals(rhs); + } + } + + private String _address = null; + private LinkedList _extensions = new LinkedList(); + private Extension _portType = null; + private Extension _serviceName = null; + private List _policies = null; + +} Added: labs/jbossesb/trunk/ESBCore/classes/org/jboss/soa/esbcore/addressing/XMLUtil.java =================================================================== --- labs/jbossesb/trunk/ESBCore/classes/org/jboss/soa/esbcore/addressing/XMLUtil.java 2006-05-04 10:47:38 UTC (rev 4087) +++ labs/jbossesb/trunk/ESBCore/classes/org/jboss/soa/esbcore/addressing/XMLUtil.java 2006-05-04 13:12:55 UTC (rev 4088) @@ -0,0 +1,62 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2006, JBoss Inc., and others contributors as indicated + * by the @authors tag. All rights reserved. + * See the copyright.txt in the distribution for a + * full listing of individual contributors. + * This copyrighted material is made available to anyone wishing to use, + * modify, copy, or redistribute it subject to the terms and conditions + * of the GNU Lesser General Public License, v. 2.1. + * This program is distributed in the hope that it will be useful, but WITHOUT A + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + * You should have received a copy of the GNU Lesser General Public License, + * v.2.1 along with this distribution; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + * + * (C) 2005-2006, + * @author mar...@jb... + */ + +/* + * Copyright (c) 2002, 2003, Arjuna Technologies Limited. + * + * XMLUtil.java + */ + +package org.jboss.soa.esbcore.addressing; + +public class XMLUtil +{ + // WS-Addr + + public static final String WSA_PREFIX = "wsa"; + public static final String WSA_NAMESPACE_URI = "http://schemas.xmlsoap.org/ws/2004/08/addressing"; + + public static final String ENDPOINT_REFERENCE_TAG = "EndpointReference"; + public static final String MESSAGE_IDENTIFIER_TAG = "MessageID"; + public static final String REFERENCE_PROPERTIES_TAG = "ReferenceProperties"; + public static final String REFERENCE_PARAMETERS_TAG = "ReferenceParameters"; + public static final String REPLY_TO_TAG = "ReplyTo"; + public static final String FROM_TAG = "From"; + + public static final String TO_TAG = "To"; + public static final String ADDRESS_TAG = "Address"; + public static final String ACTION_TAG = "Action"; + public static final String RELATES_TO_TAG = "RelatesTo"; + public static final String FAULT_TO_TAG = "FaultTo"; + + // WS-ARJADDR + + public static final String WSARJADDR_PREFIX = "wsarjaddr"; + public static final String WSARJADDR_NAMESPACE_URI = "http://schemas.arjuna.com/ws/2004/06/wsarjaddr"; + + public static final String INSTANCE_IDENTIFIER_TAG = "InstanceIdentifier"; + + public static final String UNKNOWNERROR_ERROR_CODE = "UnknownError"; + + // XML Namespace + public static final String XMLNS_URI = "http://www.w3.org/2000/xmlns/" ; + public static final String XMLNS_PREFIX = "xmlns:" ; +} Added: labs/jbossesb/trunk/ESBCore/classes/org/jboss/soa/esbcore/exceptions/MarshalException.java =================================================================== --- labs/jbossesb/trunk/ESBCore/classes/org/jboss/soa/esbcore/exceptions/MarshalException.java 2006-05-04 10:47:38 UTC (rev 4087) +++ labs/jbossesb/trunk/ESBCore/classes/org/jboss/soa/esbcore/exceptions/MarshalException.java 2006-05-04 13:12:55 UTC (rev 4088) @@ -0,0 +1,36 @@ +package org.jboss.soa.esbcore.exceptions; + +/* + * JBoss, Home of Professional Open Source + * Copyright 2006, JBoss Inc., and others contributors as indicated + * by the @authors tag. All rights reserved. + * See the copyright.txt in the distribution for a + * full listing of individual contributors. + * This copyrighted material is made available to anyone wishing to use, + * modify, copy, or redistribute it subject to the terms and conditions + * of the GNU Lesser General Public License, v. 2.1. + * This program is distributed in the hope that it will be useful, but WITHOUT A + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + * You should have received a copy of the GNU Lesser General Public License, + * v.2.1 along with this distribution; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + * + * (C) 2005-2006, + * @author mar...@jb... + */ + +import java.lang.Exception; + +public class MarshalException extends Exception { + + public MarshalException () { + super(); + } + + public MarshalException (String s) { + super(s); + } + +} Modified: labs/jbossesb/trunk/ESBCore/classes/org/jboss/soa/esbcore/impl/tcp/plugin/infrastructure/receiver/ReceiverPluginImpl.java =================================================================== --- labs/jbossesb/trunk/ESBCore/classes/org/jboss/soa/esbcore/impl/tcp/plugin/infrastructure/receiver/ReceiverPluginImpl.java 2006-05-04 10:47:38 UTC (rev 4087) +++ labs/jbossesb/trunk/ESBCore/classes/org/jboss/soa/esbcore/impl/tcp/plugin/infrastructure/receiver/ReceiverPluginImpl.java 2006-05-04 13:12:55 UTC (rev 4088) @@ -24,6 +24,8 @@ import java.io.ByteArrayInputStream; import java.io.DataInputStream; import java.io.InputStream; +import java.io.StringReader; +import java.io.StringWriter; import java.net.InetSocketAddress; import java.net.ServerSocket; import java.net.Socket; @@ -32,85 +34,71 @@ import java.net.URI; import java.net.URL; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; + +import org.jboss.soa.esbcore.addressing.EPR; import org.jboss.soa.esbcore.messaging.Body; import org.jboss.soa.esbcore.messaging.Message; import org.jboss.soa.esbcore.plugin.infrastructure.receiver.ReceiverPlugin; -import org.jboss.soa.internal.esbcore.addressing.EPRImpl; +import org.w3c.dom.Document; +import com.sun.org.apache.xml.internal.serialize.OutputFormat; +import com.sun.org.apache.xml.internal.serialize.XMLSerializer; + public class ReceiverPluginImpl implements ReceiverPlugin { // TODO to and from XML - + // TODO ports (topics etc) should be setup in the contract. - - public Message receive () + + public Message receive() { try { // get the URL from the contract? - + URL listener = new URL("http://localhost:8080"); - + ServerSocket serverSocket = new ServerSocket(listener.getPort()); Socket theSocket = serverSocket.accept(); - DataInputStream inputStream = new DataInputStream(theSocket.getInputStream()); - - int headerSize = inputStream.readInt(); - - if (headerSize <= 0) + DataInputStream inputStream = new DataInputStream(theSocket + .getInputStream()); + + int msgSize = inputStream.readInt(); + + if (msgSize <= 0) { // error!!!! } else { - byte[] hdr = new byte[headerSize]; + byte[] content = new byte[msgSize]; + + inputStream.read(content, 0, msgSize); - inputStream.read(hdr, 0, headerSize); - - int contentSize = inputStream.readInt(); - byte[] content = null; + theSocket.close(); + serverSocket.close(); - if (contentSize <= 0) - { - // error! - - // TODO Exceptions!! - } - else - { - content = new byte[contentSize]; - - inputStream.read(content, 0, contentSize); + ByteArrayInputStream byteStream = new ByteArrayInputStream(content); + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + DocumentBuilder docBuilder = factory.newDocumentBuilder(); + Document doc = docBuilder.parse(byteStream); - InetSocketAddress sender = (InetSocketAddress) theSocket.getRemoteSocketAddress(); - EPRImpl epr = new EPRImpl(); - - epr.fromBytes(hdr); - epr.setFrom(new URI("tcp://"+sender.getHostName()+":"+sender.getPort())); - - Message msg = new Message(); - - msg.getBody().setContents(content); - msg.getHeader().setEPR(epr); - - theSocket.close(); - serverSocket.close(); - - return msg; - } + Message msg = new Message(); + + msg.fromXML(doc); + + return msg; } - } - catch (SocketException ex) - { + } catch (SocketException ex) { // TODO EXCEPTIONS!!!!! - + return null; - } - catch (Exception ex) - { + } catch (Exception ex) { ex.printStackTrace(); } - + return null; } } Modified: labs/jbossesb/trunk/ESBCore/classes/org/jboss/soa/esbcore/impl/tcp/plugin/infrastructure/sender/SenderPluginImpl.java =================================================================== --- labs/jbossesb/trunk/ESBCore/classes/org/jboss/soa/esbcore/impl/tcp/plugin/infrastructure/sender/SenderPluginImpl.java 2006-05-04 10:47:38 UTC (rev 4087) +++ labs/jbossesb/trunk/ESBCore/classes/org/jboss/soa/esbcore/impl/tcp/plugin/infrastructure/sender/SenderPluginImpl.java 2006-05-04 13:12:55 UTC (rev 4088) @@ -31,11 +31,11 @@ import org.jboss.soa.esbcore.messaging.Message; import org.jboss.soa.esbcore.addressing.EPR; +import org.jboss.soa.esbcore.addressing.PortReference; import org.jboss.soa.esbcore.common.Protocols; import org.jboss.soa.esbcore.exceptions.*; import java.net.InetAddress; -import java.net.InetSocketAddress; import java.net.MalformedURLException; import java.net.Socket; import java.net.URI; @@ -44,7 +44,16 @@ import java.io.ByteArrayOutputStream; import java.io.DataOutputStream; import java.io.IOException; +import java.io.StringWriter; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; + +import org.w3c.dom.Document; + +import com.sun.org.apache.xml.internal.serialize.OutputFormat; +import com.sun.org.apache.xml.internal.serialize.XMLSerializer; + public class SenderPluginImpl implements SenderPlugin { public SenderPluginImpl () @@ -73,7 +82,7 @@ // get the destination from the EPR EPR epr = msg.getHeader().getEPR(); - URI destination = epr.getTo(); + URI destination = new URI(epr.getTo().getAddress()); // probably shouldn't happen by the time we get here, but ... @@ -89,20 +98,41 @@ URI from = new URI(Protocols.TCP+"://"+localAddress.getHostName()+":"+sender.getLocalPort()); ByteArrayOutputStream byteStream = new ByteArrayOutputStream(); DataOutputStream dataStream = new DataOutputStream(byteStream); + PortReference returnEndpoint = new PortReference(from.toString()); - epr.setFrom(from); - epr.setFaultTo(from); - epr.setReplyTo(from); - epr.setAction(SenderPluginImpl._action); + epr.setFrom(returnEndpoint); + epr.setFaultTo(returnEndpoint); + epr.setReplyTo(returnEndpoint); + epr.setAction(SenderPluginImpl._action); + + // TODO remove magic strings and numbers! + + epr.setMessageID(new URI(new String("tcp:msgid:"+System.currentTimeMillis()))); - byte[] header = msg.getHeader().toBytes(); + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + DocumentBuilder builder = factory.newDocumentBuilder(); + + Document doc = builder.newDocument(); + + msg.toXML(doc); + + StringWriter sWriter = new StringWriter(); + OutputFormat format = new OutputFormat(); + format.setIndenting(true); - dataStream.writeInt(header.length); - dataStream.write(header, 0, header.length); - dataStream.writeInt(contents.length); - dataStream.write(contents, 0, contents.length); + XMLSerializer xmlS = new XMLSerializer(sWriter, format); + + xmlS.asDOMSerializer(); + xmlS.serialize(doc); + + String documentAsString = sWriter.toString(); + byte[] docAsBytes = documentAsString.getBytes(); + + dataStream.writeInt(docAsBytes.length); + dataStream.write(docAsBytes, 0, docAsBytes.length); dataStream.flush(); byteStream.writeTo(sender.getOutputStream()); + byteStream.flush(); sender.close(); } @@ -111,7 +141,14 @@ } catch (MalformedURLException ex) { - throw new InvalidParameterException("Malformed URL "+msg.getHeader().getEPR().getTo()); + try + { + throw new InvalidParameterException("Malformed URL "+msg.getHeader().getEPR().getTo()); + } + catch (Exception exp) + { + throw new InvalidParameterException("Malformed URL"); + } } catch (IOException ex) { @@ -121,6 +158,12 @@ { throw new SendFailedException(ex); } + catch (Exception ex) + { + ex.printStackTrace(); + + throw new SendFailedException(ex); + } } public void sendAsync (Message msg) throws ProtocolNotSupportedException Modified: labs/jbossesb/trunk/ESBCore/classes/org/jboss/soa/esbcore/messaging/Attachment.java =================================================================== --- labs/jbossesb/trunk/ESBCore/classes/org/jboss/soa/esbcore/messaging/Attachment.java 2006-05-04 10:47:38 UTC (rev 4087) +++ labs/jbossesb/trunk/ESBCore/classes/org/jboss/soa/esbcore/messaging/Attachment.java 2006-05-04 13:12:55 UTC (rev 4088) @@ -1,5 +1,9 @@ package org.jboss.soa.esbcore.messaging; +import org.jboss.soa.esbcore.addressing.EPR; +import org.w3c.dom.Document; +import org.w3c.dom.Element; + /* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and others contributors as indicated @@ -30,4 +34,17 @@ public class Attachment { + public Element toXML (Document doc, Element envelope) + { + Element attachmentElement = doc.createElement("attachment"); + + envelope.appendChild(attachmentElement); + + return attachmentElement; + } + + public void fromXML (Element envelope) + { + } + } Modified: labs/jbossesb/trunk/ESBCore/classes/org/jboss/soa/esbcore/messaging/Body.java =================================================================== --- labs/jbossesb/trunk/ESBCore/classes/org/jboss/soa/esbcore/messaging/Body.java 2006-05-04 10:47:38 UTC (rev 4087) +++ labs/jbossesb/trunk/ESBCore/classes/org/jboss/soa/esbcore/messaging/Body.java 2006-05-04 13:12:55 UTC (rev 4088) @@ -2,6 +2,12 @@ import java.security.InvalidParameterException; +import org.jboss.soa.esbcore.addressing.EPR; +import org.w3c.dom.CDATASection; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.NodeList; + /* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and others contributors as indicated @@ -34,6 +40,34 @@ _content = null; } + public Element toXML (Document doc, Element envelope) + { + Element bodyElement = doc.createElement("body"); + + envelope.appendChild(bodyElement); + + bodyElement.appendChild(doc.createCDATASection(new String(_content))); + + return bodyElement; + } + + public void fromXML (Element envelope) + { + NodeList nl = envelope.getChildNodes(); + + for (int i = 0; i < nl.getLength(); i++) + { + if (nl.item(i).getNodeName().equals("body")) + { + CDATASection cdata = (CDATASection) nl.item(i).getFirstChild(); + + _content = cdata.getWholeText().getBytes(); + + break; + } + } + } + public void setContents (byte[] content) { _content = content; Modified: labs/jbossesb/trunk/ESBCore/classes/org/jboss/soa/esbcore/messaging/Context.java =================================================================== --- labs/jbossesb/trunk/ESBCore/classes/org/jboss/soa/esbcore/messaging/Context.java 2006-05-04 10:47:38 UTC (rev 4087) +++ labs/jbossesb/trunk/ESBCore/classes/org/jboss/soa/esbcore/messaging/Context.java 2006-05-04 13:12:55 UTC (rev 4088) @@ -1,5 +1,9 @@ package org.jboss.soa.esbcore.messaging; +import org.jboss.soa.esbcore.addressing.EPR; +import org.w3c.dom.Document; +import org.w3c.dom.Element; + /* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and others contributors as indicated @@ -23,4 +27,16 @@ public class Context { + public Element toXML (Document doc, Element envelope) + { + Element contextElement = doc.createElement("context"); + + envelope.appendChild(contextElement); + + return contextElement; + } + + public void fromXML (Element envelope) + { + } } \ No newline at end of file Modified: labs/jbossesb/trunk/ESBCore/classes/org/jboss/soa/esbcore/messaging/Fault.java =================================================================== --- labs/jbossesb/trunk/ESBCore/classes/org/jboss/soa/esbcore/messaging/Fault.java 2006-05-04 10:47:38 UTC (rev 4087) +++ labs/jbossesb/trunk/ESBCore/classes/org/jboss/soa/esbcore/messaging/Fault.java 2006-05-04 13:12:55 UTC (rev 4088) @@ -1,5 +1,9 @@ package org.jboss.soa.esbcore.messaging; +import org.jboss.soa.esbcore.addressing.EPR; +import org.w3c.dom.Document; +import org.w3c.dom.Element; + /* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and others contributors as indicated @@ -23,4 +27,17 @@ public class Fault { + public Element toXML (Document doc, Element envelope) + { + Element faultElement = doc.createElement("fault"); + + envelope.appendChild(faultElement); + + return faultElement; + } + + public void fromXML (Element envelope) + { + } + } \ No newline at end of file Modified: labs/jbossesb/trunk/ESBCore/classes/org/jboss/soa/esbcore/messaging/Header.java =================================================================== --- labs/jbossesb/trunk/ESBCore/classes/org/jboss/soa/esbcore/messaging/Header.java 2006-05-04 10:47:38 UTC (rev 4087) +++ labs/jbossesb/trunk/ESBCore/classes/org/jboss/soa/esbcore/messaging/Header.java 2006-05-04 13:12:55 UTC (rev 4088) @@ -22,6 +22,11 @@ */ import org.jboss.soa.esbcore.addressing.EPR; +import org.jboss.soa.esbcore.addressing.EPR; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; /** * The message header. Contains such things as routing information. @@ -46,10 +51,40 @@ _epr = addr; } - public byte[] toBytes () + public Element toXML (Document doc, Element envelope) { - return _epr.toBytes(); + // TODO remove MAGIC strings!! + + Element headerElement = doc.createElement("header"); + + envelope.appendChild(headerElement); + + return _epr.toXML(doc, headerElement); } + public void fromXML (Element envelope) + { + _epr = new EPR(); + + NodeList nl = envelope.getChildNodes(); + Element headerElement = null; + + for (int i = 0; i < nl.getLength(); i++) + { + Node n = nl.item(i); + + if (n.getNodeName().equals("header")) + { + headerElement = (Element) n; + break; + } + } + + // TODO error handling!! + + if (headerElement != null) + _epr.fromXML(headerElement); + } + private EPR _epr; } \ No newline at end of file Modified: labs/jbossesb/trunk/ESBCore/classes/org/jboss/soa/esbcore/messaging/Message.java =================================================================== --- labs/jbossesb/trunk/ESBCore/classes/org/jboss/soa/esbcore/messaging/Message.java 2006-05-04 10:47:38 UTC (rev 4087) +++ labs/jbossesb/trunk/ESBCore/classes/org/jboss/soa/esbcore/messaging/Message.java 2006-05-04 13:12:55 UTC (rev 4088) @@ -1,5 +1,17 @@ package org.jboss.soa.esbcore.messaging; +import org.jboss.soa.esbcore.addressing.EPR; +import org.w3c.dom.DOMImplementation; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.w3c.dom.bootstrap.DOMImplementationRegistry; +import org.w3c.dom.ls.DOMImplementationLS; +import org.w3c.dom.ls.LSSerializer; + +import com.sun.org.apache.xerces.internal.xni.XMLDocumentHandler; + /* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and others contributors as indicated @@ -88,6 +100,66 @@ return _theAttachment; } + // to/from XML here, rather than on individual elements + + public Document toXML (Document doc) + { + try + { + // TODO remove magic strings! + + Element envelope = doc.createElement("envelope"); + + doc.appendChild(envelope); + + _theHeader.toXML(doc, envelope); + _theContext.toXML(doc, envelope); + _theBody.toXML(doc, envelope); + _theFault.toXML(doc, envelope); + _theAttachment.toXML(doc, envelope); + + return doc; + } + catch (Exception ex) + { + // TODO error handling + + ex.printStackTrace(); + + return null; + } + } + + public void fromXML (Document doc) + { + try + { + NodeList nl = doc.getChildNodes(); + Element envelope = null; + + for (int i = 0; i < nl.getLength(); i++) + { + Node n = nl.item(i); + + if (n.getNodeName().equals("envelope")) + { + envelope = (Element) n; + break; + } + } + + _theHeader.fromXML(envelope); + _theContext.fromXML(envelope); + _theBody.fromXML(envelope); + _theFault.fromXML(envelope); + _theAttachment.fromXML(envelope); + } + catch (Exception ex) + { + ex.printStackTrace(); + } + } + private Header _theHeader = new Header(); private Context _theContext = new Context(); private Body _theBody = new Body(); Modified: labs/jbossesb/trunk/ESBCore/classes/org/jboss/soa/esbcore/tests/tcp/TcpClient.java =================================================================== --- labs/jbossesb/trunk/ESBCore/classes/org/jboss/soa/esbcore/tests/tcp/TcpClient.java 2006-05-04 10:47:38 UTC (rev 4087) +++ labs/jbossesb/trunk/ESBCore/classes/org/jboss/soa/esbcore/tests/tcp/TcpClient.java 2006-05-04 13:12:55 UTC (rev 4088) @@ -2,6 +2,7 @@ import java.net.URI; +import org.jboss.soa.esbcore.addressing.EPR; import org.jboss.soa.esbcore.contract.basic.DispatcherContractImpl; import org.jboss.soa.esbcore.contract.basic.client.ClientPluginContractImpl; import org.jboss.soa.esbcore.contract.basic.client.ContractDefinitionImpl; @@ -12,7 +13,6 @@ import org.jboss.soa.esbcore.messaging.Body; import org.jboss.soa.esbcore.plugin.infrastructure.DispatcherFactory; import org.jboss.soa.esbcore.plugin.infrastructure.sender.SenderPluginFactory; -import org.jboss.soa.internal.esbcore.addressing.EPRImpl; /* * JBoss, Home of Professional Open Source @@ -79,7 +79,7 @@ * Create a reference to the endpoint service we want to talk to. */ - EPRImpl epr = new EPRImpl(destination); + EPR epr = new EPR(destination); /* * Now create the contract definition we need to assemble the right components Modified: labs/jbossesb/trunk/ESBCore/classes/org/jboss/soa/esbcore/tests/tcp/TcpService.java =================================================================== --- labs/jbossesb/trunk/ESBCore/classes/org/jboss/soa/esbcore/tests/tcp/TcpService.java 2006-05-04 10:47:38 UTC (rev 4087) +++ labs/jbossesb/trunk/ESBCore/classes/org/jboss/soa/esbcore/tests/tcp/TcpService.java 2006-05-04 13:12:55 UTC (rev 4088) @@ -2,6 +2,7 @@ import java.net.URI; +import org.jboss.soa.esbcore.addressing.EPR; import org.jboss.soa.esbcore.contract.basic.DispatcherContractImpl; import org.jboss.soa.esbcore.contract.basic.service.ServicePluginContractImpl; import org.jboss.soa.esbcore.contract.basic.service.ContractDefinitionImpl; @@ -12,7 +13,6 @@ import org.jboss.soa.esbcore.messaging.Body; import org.jboss.soa.esbcore.plugin.infrastructure.DispatcherFactory; import org.jboss.soa.esbcore.plugin.infrastructure.receiver.ReceiverPluginFactory; -import org.jboss.soa.internal.esbcore.addressing.EPRImpl; /* * JBoss, Home of Professional Open Source @@ -132,7 +132,7 @@ try { - EPRImpl from = new EPRImpl(); + EPR from = new EPR(); Body payload = httpServicePlugin.receive(from); String message = new String(payload.getContents()); Deleted: labs/jbossesb/trunk/ESBCore/classes/org/jboss/soa/internal/esbcore/addressing/EPRImpl.java =================================================================== --- labs/jbossesb/trunk/ESBCore/classes/org/jboss/soa/internal/esbcore/addressing/EPRImpl.java 2006-05-04 10:47:38 UTC (rev 4087) +++ labs/jbossesb/trunk/ESBCore/classes/org/jboss/soa/internal/esbcore/addressing/EPRImpl.java 2006-05-04 13:12:55 UTC (rev 4088) @@ -1,191 +0,0 @@ -package org.jboss.soa.internal.esbcore.addressing; - -/* - * JBoss, Home of Professional Open Source - * Copyright 2006, JBoss Inc., and others contributors as indicated - * by the @authors tag. All rights reserved. - * See the copyright.txt in the distribution for a - * full listing of individual contributors. - * This copyrighted material is made available to anyone wishing to use, - * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU Lesser General Public License, v. 2.1. - * This program is distributed in the hope that it will be useful, but WITHOUT A - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A - * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - * You should have received a copy of the GNU Lesser General Public License, - * v.2.1 along with this distribution; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301, USA. - * - * (C) 2005-2006, - * @author mar...@jb... - */ - -import org.jboss.soa.esbcore.addressing.EPR; - -/** - * This class represents the endpoint reference for services. - */ - -import java.net.URI; - -public class EPRImpl implements EPR -{ - public EPRImpl () - { - this(null); - } - - public EPRImpl (URI uri) - { - _to = uri; - _from = _replyTo = _faultTo = _action = _messageID = null; - } - - public void setTo (URI uri) - { - _to = uri; - } - - public URI getTo () - { - return _to; - } - - public void setFrom (URI uri) - { - _from = uri; - } - - public URI getFrom () - { - return _from; - } - - public void setReplyTo (URI uri) - { - _replyTo = uri; - } - public URI getReplyTo () - { - return _replyTo; - } - - public void setFaultTo (URI uri) - { - _faultTo = uri; - } - - public URI getFaultTo () - { - return _faultTo; - } - - public void setAction (URI uri) - { - _action = uri; - } - - public URI getAction () - { - return _action; - } - - public void setMessageID (URI uri) - { - _messageID = uri; - } - - public URI getMessageID () - { - return _messageID; - } - - public void copy (EPR from) - { - _to = from.getTo(); - _from = from.getFrom(); - _replyTo = from.getReplyTo(); - _faultTo = from.getFaultTo(); - _action = from.getAction(); - } - -// public void setMetaData (MetaData md); -// public MetaData getMetaData (); -// public void addReferenceParameter (...); - - public String toString () - { - return "To: "+_to+" From: "+_from+" ReplyTo: "+_replyTo+" FaultTo: "+_faultTo+" Action: "+_action; - } - - /* - * In lieu of toXML and fromXML - * - * @see org.jboss.soa.esbcore.addressing.EPR#toBytes() - */ - - public byte[] toBytes () - { - return toString().getBytes(); - } - - public void fromBytes (byte[] buff) - { - String fullBuffer = new String(buff); - - try - { - int fromStart = fullBuffer.indexOf(" From: "); - String toField = fullBuffer.substring(0, fromStart); - - if (!toField.equals("null")) - { - _to = new URI(toField.substring(4)); - } - - int replyToStart = fullBuffer.indexOf(" ReplyTo: ", fromStart); - String fromField = fullBuffer.substring(fromStart+7, replyToStart); - - if (!fromField.equals("null")) - { - _from = new URI(fromField.substring(7)); - } - - int faultToStart = fullBuffer.indexOf(" FaultTo: ", replyToStart); - String replyToField = fullBuffer.substring(replyToStart+10, faultToStart); - - if (!replyToField.equals("null")) - { - _replyTo = new URI(replyToField.substring(0)); - } - - int actionStart = fullBuffer.indexOf(" Action: ", faultToStart); - String faultToField = fullBuffer.substring(faultToStart+10, actionStart); - - if (!faultToField.equals("null")) - { - _faultTo = new URI(faultToField.substring(0)); - } - - String actionField = fullBuffer.substring(actionStart+9); - - if (!actionField.equals("null")) - { - _action = new URI(actionField.substring(0)); - } - } - catch (Exception ex) - { - ex.printStackTrace(); - } - } - - private URI _to; - private URI _from; - private URI _replyTo; - private URI _faultTo; - private URI _action; - private URI _messageID; - -} \ No newline at end of file Added: labs/jbossesb/trunk/ESBCore/classes/org/jboss/soa/internal/esbcore/addressing/PortReferenceHelper.java =================================================================== --- labs/jbossesb/trunk/ESBCore/classes/org/jboss/soa/internal/esbcore/addressing/PortReferenceHelper.java 2006-05-04 10:47:38 UTC (rev 4087) +++ labs/jbossesb/trunk/ESBCore/classes/org/jboss/soa/internal/esbcore/addressing/PortReferenceHelper.java 2006-05-04 13:12:55 UTC (rev 4088) @@ -0,0 +1,373 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2006, JBoss Inc., and others contributors as indicated + * by the @authors tag. All rights reserved. + * See the copyright.txt in the distribution for a + * full listing of individual contributors. + * This copyrighted material is made available to anyone wishing to use, + * modify, copy, or redistribute it subject to the terms and conditions + * of the GNU Lesser General Public License, v. 2.1. + * This program is distributed in the hope that it will be useful, but WITHOUT A + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + * You should have received a copy of the GNU Lesser General Public License, + * v.2.1 along with this distribution; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + * + * (C) 2005-2006, + * @author mar...@jb... + */ + +/* + * Copyright (c) 2002, 2003, Arjuna Technologies Limited. + * + * PortReferenceHelper.java + */ + +package org.jboss.soa.internal.esbcore.addressing; + +import java.util.Iterator; +import java.util.LinkedList; +import java.util.HashMap; +import java.util.Map; + +import org.w3c.dom.Attr; +import org.w3c.dom.Element; +import org.w3c.dom.NamedNodeMap; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.w3c.dom.Text; + +import org.jboss.soa.esbcore.addressing.PortReference; +import org.jboss.soa.esbcore.addressing.XMLUtil; +import org.jboss.soa.esbcore.addressing.PortReference.Extension; +import org.jboss.soa.esbcore.exceptions.MarshalException; + +/* + * This should pack the PortReference into an ERP. + * + * It would be better if PortReference had a packToXML and unpackFromXML. + * + * This needs rewriting after the interoperability workshop! + */ + +public class PortReferenceHelper { + /** + * WS-Addressing is broken in that the To field is a URI, even if the From + * field was an EPR! You have to use the EPR bits separately. So, the + * toField is used to indicate whether we are packing this address as a To + * field (when we need to treat it differently) or as an EPR. + */ + + /** ************************************************** */ + public static void toXML(org.w3c.dom.Element header, + org.w3c.dom.Document document, + org.w3c.dom.Element portReferenceElement, + PortReference portReference, boolean toField) + throws MarshalException { + try { + if (!toField) { + Element addressElement = document.createElementNS( + XMLUtil.WSA_NAMESPACE_URI, XMLUtil.ADDRESS_TAG); + addressElement.setPrefix(XMLUtil.WSA_PREFIX); + addressElement.appendChild(document + .createTextNode(portReference.getAddress())); + portReferenceElement.appendChild(addressElement); + } else { + portReferenceElement.appendChild(document + .createTextNode(portReference.getAddress())); + } + + Iterator extensions = portReference.getExtensions(); + Element referenceProperties = null; + + while (extensions.hasNext()) { + PortReference.Extension extension = (PortReference.Extension) extensions + .next(); + + /* + * WS-Addressing is broken in that the To field is a URI, even + * if the From field was an EPR! You have to use the EPR bits + * separately. Doh! + */ + + if (!toField) { + if (referenceProperties == null) { + referenceProperties = document.createElementNS( + XMLUtil.WSA_NAMESPACE_URI, + XMLUtil.REFERENCE_PROPERTIES_TAG); + referenceProperties.setPrefix(XMLUtil.WSA_PREFIX); + portReferenceElement.appendChild(referenceProperties); + } + } else + referenceProperties = header; + + extensionToXML(referenceProperties, document, extension); + } + } catch (Exception exception) { + exception.printStackTrace(); + throw new MarshalException("Marshal failure: " + exception); + } + } + + /** **************************** */ + public static PortReference fromXML(org.w3c.dom.Element portReferenceElement, boolean toField) + throws MarshalException { + PortReference portReference = new PortReference();; + + if (toField) + portReference.setAddress(portReferenceElement.getTextContent()); + + org.w3c.dom.NodeList elements = portReferenceElement.getChildNodes(); + + for (int i = 1; i < elements.getLength(); i++) { + final Object extensionObject = elements.item(i); + + if (extensionObject instanceof Element) { + int parentNodeType = PortReference.Extension.NEITHER; + Element extensionElement = (Element) extensionObject; + NodeList children = extensionElement.getChildNodes(); + String parentName = extensionElement.getNodeName(); + boolean haveChildren = false; + + if (parentName.equals(XMLUtil.REFERENCE_PROPERTIES_TAG)) + parentNodeType = PortReference.Extension.REFERENCE_PROPERTIES; + else { + if (parentName.equals(XMLUtil.REFERENCE_PARAMETERS_TAG)) + parentNodeType = PortReference.Extension.REFERENCE_PARAMETERS; + else + { + if (!toField && parentName.equals(XMLUtil.WSA_PREFIX+":"+XMLUtil.ADDRESS_TAG)) + { + portReference.setAddress(extensionElement.getTextContent()); + } + } + } + + final int numChildren = children.getLength(); + for (int count = 0; count < numChildren; count++) { + final Object childObject = children.item(count); + + if (childObject instanceof Element) { + Element childElement = (Element) childObject; + portReference + .addExtension(childrenFromXML(childElement)); + haveChildren = true; + } + } + + if (!haveChildren) { + PortReference.Extension ext = new PortReference.Extension( + extensionElement.getNodeName(), null, null, + extensionElement.getNodeValue(), parentNodeType); + + portReference.addExtension(ext); + + final NamedNodeMap attrs = extensionElement.getAttributes(); + final int numAttrs = attrs.getLength(); + if (numAttrs > 0) { + final HashMap p = new HashMap(); + for (int count = 0; count < numAttrs; count++) { + final Attr attr = (Attr) attrs.item(count); + if (!"http://www.w3.org/2000/xmlns/".equals(attr + .getNamespaceURI())) { + final ArjunaName name = generateName(attr); + p.put(name, attr.getValue()); + } + } + + ext.addAttributes(p); + } + } + } + } + + return portReference; + } + + private final static PortReference.Extension childrenFromXML( + Element childRoot) { + final NodeList children = childRoot.getChildNodes(); + final int numChildNodes = children.getLength(); + + final PortReference.Extension extension; + if (numChildNodes > 0) { + Object childObject = children.item(0); + if (childObject instanceof Element) { + extension = new PortReference.Extension(childRoot + .getNodeName(), childRoot.getPrefix(), childRoot + .getNamespaceURI()); + for (int count = 1; count < numChildNodes; count++) { + extension.addChild(childrenFromXML((Element) childObject)); + childObject = children.item(count); + } + } else { + extension = new PortReference.Extension(childRoot + .getNodeName(), childRoot.getPrefix(), childRoot + .getNamespaceURI(), ((Node) childObject).getNodeValue()); + } + } else { + extension = new PortReference.Extension(childRoot.getNodeName(), + childRoot.getPrefix(), childRoot.getNamespaceURI(), + childRoot.getNodeValue()); + } + + final NamedNodeMap attrs = childRoot.getAttributes(); + final int numAttrs = attrs.getLength(); + if (numAttrs > 0) { + final HashMap p = new HashMap(); + for (int count = 0; count < numAttrs; count++) { + final Attr attr = (Attr) attrs.item(count); + if (!"http://www.w3.org/2000/xmlns/".equals(attr + .getNamespaceURI())) { + final ArjunaName name = generateName(attr); + p.put(name, attr.getValue()); + } + } + + extension.addAttributes(p); + } + return extension; + } + + private final static Element extensionToXML(Element packInto, + org.w3c.dom.Document document, PortReference.Extension toPack) + throws MarshalException { + final String uri = toPack.getURI(); + final Element element; + if (uri == null) { + element = document.createElement(toPack.getTag()); + } else { + final String prefix = toPack.getPrefix(); + element = document.createElementNS(uri, toPack.getTag()); + element.setPrefix(prefix); + element.setAttributeNS(XMLUtil.XMLNS_URI, XMLUtil.XMLNS_PREFIX + + toPack.getPrefix(), uri); + } + packInto.appendChild(element); + + if (toPack.getValue() != null) { + final Text text = document.createTextNode(toPack.getValue()); + element.appendChild(text); + } + + LinkedList extensions = toPack.getChildren(); + + if (extensions != null) { + for (int i = 0; i < extensions.size(); i++) { + PortReference.Extension ext = (PortReference.Extension) extensions + .get(i); + + extensionToXML(element, document, ext); + } + } + + HashMap attrs = toPack.getAttributes(); + + if (attrs != null) { + Iterator names = attrs.entrySet().iterator(); + + while (names.hasNext()) { + Map.Entry entry = (Map.Entry) names.next(); + ArjunaName name = (ArjunaName) entry.getKey(); + final String value = (String) entry.getValue(); + final String attrURI = name.toString(); + if (attrURI != null) { + element.setAttributeNS(attrURI, name.getQualifiedName(), + value); + } else { + element.setAttribute(name.getQualifiedName(), value); + } + } + } + + return element; + } + + /** + * Generate a name based on the attribute. + * + * @param attr + * The current attribute. + * @return The name + */ + private static ArjunaName generateName(final Attr attr) { + final String localName = attr.getNodeName(); + final String uri = attr.getNamespaceURI(); + final String prefix = attr.getPrefix(); + + return new ArjunaName(uri, prefix, localName); + } + + private static class ArjunaName + { + /** + * The uri. + */ + private final String uri; + + /** + * The prefix. + */ + private final String prefix; + + /** + * The local name. + */ + private... [truncated message content] |
From: <jbo...@li...> - 2006-05-04 10:47:48
|
Author: mic...@jb... Date: 2006-05-04 06:47:38 -0400 (Thu, 04 May 2006) New Revision: 4087 Modified: labs/jbossrules/trunk/documentation/manual/en/master.xml Log: Modified: labs/jbossrules/trunk/documentation/manual/en/master.xml =================================================================== --- labs/jbossrules/trunk/documentation/manual/en/master.xml 2006-05-04 10:38:20 UTC (rev 4086) +++ labs/jbossrules/trunk/documentation/manual/en/master.xml 2006-05-04 10:47:38 UTC (rev 4087) @@ -111,6 +111,11 @@ <xi:include href="Chapter-Rule_Language/Section-Conditional_Elements.xml" /--> </chapter> + <chapter> + <title>Decision Tables</title> + <xi:include href="Chapter-Decision_Tables/Section-Spreadsheet.xml" /> + </chapter> + <chapter> <title>The Rule Workbench (IDE)</title> |
From: <jbo...@li...> - 2006-05-04 10:39:07
|
Author: mic...@jb... Date: 2006-05-04 06:38:20 -0400 (Thu, 04 May 2006) New Revision: 4086 Added: labs/jbossrules/trunk/documentation/manual/en/Chapter-Decision_Tables/ labs/jbossrules/trunk/documentation/manual/en/Chapter-Decision_Tables/Section-Spreadsheet.xml labs/jbossrules/trunk/documentation/manual/en/Chapter-Decision_Tables/Thumbs.db labs/jbossrules/trunk/documentation/manual/en/Chapter-Decision_Tables/excel.png labs/jbossrules/trunk/documentation/manual/en/Chapter-Decision_Tables/expanded.png labs/jbossrules/trunk/documentation/manual/en/Chapter-Decision_Tables/keywords.png labs/jbossrules/trunk/documentation/manual/en/Chapter-Decision_Tables/multi_table.png labs/jbossrules/trunk/documentation/manual/en/Chapter-Decision_Tables/open_office.png labs/jbossrules/trunk/documentation/manual/en/Chapter-Decision_Tables/row_col.png labs/jbossrules/trunk/documentation/manual/en/Chapter-Decision_Tables/wizard.png Log: documentation improvements Added: labs/jbossrules/trunk/documentation/manual/en/Chapter-Decision_Tables/Section-Spreadsheet.xml =================================================================== --- labs/jbossrules/trunk/documentation/manual/en/Chapter-Decision_Tables/Section-Spreadsheet.xml 2006-05-04 10:21:11 UTC (rev 4085) +++ labs/jbossrules/trunk/documentation/manual/en/Chapter-Decision_Tables/Section-Spreadsheet.xml 2006-05-04 10:38:20 UTC (rev 4086) @@ -0,0 +1,351 @@ +<?xml version="1.0" encoding="UTF-8"?> +<section> + <title>Decision tables in spreadsheets</title> + + <para>Drools supports managing rules in a Spreadsheet format. Formats + supported are Excel, and CSV. Thus you can use a variety of spreadsheet + programs (such as Microsoft Excel, OpenOffice.org Calc amongst others). It + is expected that web based decision table editors will be included in a near + future release.</para> + + <para>Decision tables are an old concept (in software terms) but have proven + useful over the years. Very briefly speaking, in Drools decision tables are + a way to generate rules driven from the data entered into a spreadsheet. All + the usual features of a spreadsheet for data capture and manipulation can be + taken advantage of.</para> + + <section> + <title>When to use Decision tables</title> + + <para>You may want to consider decision tables if you have rules that can + be expressed as rule templates + data. In each row of a decision table, + data is collected that is combined with the tempaltes to generate a + rule.</para> + + <para>Many businesses already use spreadsheets for managing data, + calculations etc. If you are happy to continue this way, you can also + manage your business rules this way. This also assumes you are happy to + manage packages of rules in .xls or .csv files. Decision tables are not + recommented for rules that do not follow a set of templates, or where + there are a small number of rules (or if you don't want to use software + like excel or open office). They are ideal in the sense that you can + control what "parameters" of rules can be edited, without exposing the + rules directly.</para> + </section> + + <section> + <title>Overview</title> + + <para>Here are some examples of real world decision tables (slightly + edited to protect the innocent).</para> + + <screenshot> + <screeninfo>Using excel to edit a decision table</screeninfo> + + <mediaobject> + <imageobject> + <imagedata fileref="excel.png" /> + </imageobject> + </mediaobject> + </screenshot> + + <screenshot> + <screeninfo>Using OpenOffice</screeninfo> + + <mediaobject> + <imageobject> + <imagedata fileref="open_office.png" /> + </imageobject> + </mediaobject> + </screenshot> + + <para>In the above examples, the technical aspects of the decision table + have been collapsed away (standard spreadsheet feature).</para> + + <para>The rules start from row 17 (each row results in a rule). The + conditions are in column C, D, E etc.. (off screen are the actions). You + can see that the value in the cells are quite simple, and have meaning + when you look at the headers in Row 16. Column B is just a description. It + is conventional to use colour to make it obvious what the different areas + of the table mean.</para> + + <para>Note that although the decision tables look like the process top + down, this is not necessarily the case. It is ideal if you can author + rules in such a way as order does not matter (simply as it makes + maintenance easier, you are not trying to shift rows around all the time). + As each row is a rule, the same principles apply. As the rule engine + processes the facts, any rules that match may fire (some people are + confused by this - it is possible to clear the agenda when a rule fires + and simulate a very simple decision table where the first match exists). + Also note that you can have multiple tables on the one spreadsheet (so + rules can be grouped where they share common templates - yet at the end of + the day they are all combined into a one rule package). Decision tables + are essentually a tool to generate DRL rules automatically.</para> + + <screenshot> + <screeninfo>A real world example using multiple tables for grouping like + rules</screeninfo> + + <mediaobject> + <imageobject> + <imagedata fileref="multi_table.png" /> + </imageobject> + </mediaobject> + </screenshot> + </section> + + <section> + <title>How decision tables work</title> + + <para>The spreadsheet looks for the "RuleTable" keyword to indicate the + start of a rule table (both the starting row and column). Other keywords + are also used to define other package level attributes (covered later). It + is important to keep the keywords in the one column. By convention the + second column ("B") is used for this, but it can be any column (convention + is to leave a margin on the left for notes). In the following diagram, C + is actually the column where it starts. Everything to the left of this is + ignored.</para> + + <screenshot> + <screeninfo>Rows and columns</screeninfo> + + <mediaobject> + <imageobject> + <imagedata fileref="row_col.png" /> + </imageobject> + </mediaobject> + </screenshot> + + <para>If we expand the hidden sections, it starts to make more sense how + it works. Note the keywords in column C.</para> + + <screenshot> + <screeninfo>Expanded for rule templates</screeninfo> + + <mediaobject> + <imageobject> + <imagedata fileref="expanded.png" /> + </imageobject> + </mediaobject> + </screenshot> + + <para>Now you can see the hidden magic that makes it work. The RuleSet + keyword indicates the name to be used in the "rule package" that all the + rules will come under (this is optional, it will have a default) in the + cell immediately to the right. The other keywords visible in Column C are: + Import, Sequential which will be covered later - just note that in general + the keywords make up name/value pairs. The RuleTable keyword is important + as it indicates that a chunk of rules will follow, based on some rule + templates. After the RuleTable keyword there is a name - this name is used + to prefix the generated rules names (the row numbers are appended to + create unique rule names). The column of RuleTable indicates the column in + which the rules start.</para> + + <para>Referring to row 14 (the row immediately after RuleTable): the + keywords CONDITION and ACTION indicate that the data in the columns below + are for either the LHS or the RHS parts of a rule. There are other + attributes on the rule which can also be optionally set this way. Row 15 + contains the rule templates themselves: note that they use the "$para" + place holder to indicate where data from the cells below will be populated + (you can use $param, or $1, $2 etc to indicate parameters from a comma + seperated list in a cell below). Row 16 is ignored - it is textual + descriptions of the rule template.</para> + + <para>Row 17 to 18 shows data, which will be combined (interpolated) with + the templates in row 15, to generate rules. If a cell contains no data, + then its template is ignored (eg it means that condition, or action, does + not apply for that rule-row). Rule rows are read until there is a BLANK + row. You can have mutliple RuleTables in a sheet. Row 20 contains another + keyword, and a value - the row positions of keywords like this do not + matter (most people put them at the top) but their column should be the + same one where the RuleTable or RuleSet keywords should appear (in this + case column C has been chosen to be significant, but you can use column A + if you like).</para> + </section> + + <section> + <title>Keywords and syntax</title> + + <section> + <title>Syntax of templates</title> + + <para>The syntax of what goes in the templates is dependent on if it is + a CONDITION column or ACTION column. In either case, it is identical to + "vanilla" DRL for the LHS or RHS respectively. This means in the LHS, + the constraint language must be used, and in the RHS it is a snippet of + code to be executed.</para> + + <para>The "$para" place holder is used in templates to indicate where + data form the cell will be interpolated. You can also use "$1" to the + same effect. If the cell contains a comma seperated list of values, $1 + and $2 etc. may be used to indicate which positional parameter from the + list of values in the cell will be used. <programlisting>For example: If the templates is [Foo(bar == $param)] and the cell is [ 42 ] then the result will be [Foo(bar == 42)] +If the template is [Foo(bar < $1, baz == $2)] and the cell is [42,42] then the result will be [Foo(bar > 42, baz ==42)] +</programlisting></para> + </section> + + <section> + <title>Keywords</title> + + <para>The following table describes the keywords that are pertinent to + the rule table structure.</para> + + <table> + <title>Keywords</title> + + <tgroup cols="3"> + <thead> + <row> + <entry>Keyword</entry> + + <entry>Description</entry> + + <entry>Is required?</entry> + </row> + </thead> + + <tbody> + <row> + <entry>RuleSet</entry> + + <entry>The cell to the right of this contains the ruleset + name</entry> + + <entry>One only (if left out, it will default)</entry> + </row> + + <row> + <entry>Sequential</entry> + + <entry>The cell to the right of this can be true or false. If + true, then salience is used to ensure that rules fire from the + top down</entry> + + <entry>optional</entry> + </row> + + <row> + <entry>Import</entry> + + <entry>The cell to the right contains a comma seperated list of + java classes to import</entry> + + <entry>optional</entry> + </row> + + <row> + <entry>RuleTable</entry> + + <entry>A cell starting with RuleTable indicates the start of a + definition of a rule table. The actual rule table starts the + next row down. The rule table is read left-to-right, and + top-down, until there is one BLANK ROW.</entry> + + <entry>at least one. if there are more, then they are all added + to the one ruleset</entry> + </row> + + <row> + <entry>CONDITION</entry> + + <entry>Indicates that this column will be for rule + conditions</entry> + + <entry>At least one per rule table</entry> + </row> + + <row> + <entry>ACTION</entry> + + <entry>Indicates that this column will be for rule + consequences</entry> + + <entry>At least one per rule table</entry> + </row> + + <row> + <entry>PRIORITY</entry> + + <entry>Indicates that this columns values will set the + 'salience' values for the rule row. Over-rides the 'Sequential' + flag.</entry> + + <entry>optional</entry> + </row> + + <row> + <entry>DURATION</entry> + + <entry>Indicates that this columns values will set the duration + values for the rule row. </entry> + + <entry>optional</entry> + </row> + + <row> + <entry>NAME</entry> + + <entry>Indicates that this columns values will set the name for + the rule generated from that row</entry> + + <entry>optional</entry> + </row> + + <row> + <entry>Functions</entry> + + <entry>The cell immediately to the right can contain functions + which can be used in the rule snippets. Drools supports + functions defined in the DRL, allowing logic to be embedded in + the rule, and changed without hard coding, use with care. Same + syntax as regular DRL.</entry> + + <entry>optional</entry> + </row> + + <row> + <entry>Variables</entry> + + <entry>The cell immediately to the right can contain global + declartions which drools supports. This is a type, followed by a + variable name. (if multiple variables are needed, comma seperate + them).</entry> + + <entry>optional</entry> + </row> + + <row> + <entry>UNLOOP</entry> + + <entry>Indicates that if there cell values in this column, the + no-loop attribute should be set</entry> + + <entry>optional</entry> + </row> + + <row> + <entry>Worksheet</entry> + + <entry>By default, the first worksheet is only looked at for + decision tables.</entry> + + <entry>N/A</entry> + </row> + + </tbody> + </tgroup> + </table> + + <screenshot> + <screeninfo>Example usage of keywords for imports, functions + etc.</screeninfo> + + <mediaobject> + <imageobject> + <imagedata fileref="keywords.png" /> + </imageobject> + </mediaobject> + </screenshot> + </section> + </section> +</section> \ No newline at end of file Property changes on: labs/jbossrules/trunk/documentation/manual/en/Chapter-Decision_Tables/Section-Spreadsheet.xml ___________________________________________________________________ Name: svn:eol-style + native Added: labs/jbossrules/trunk/documentation/manual/en/Chapter-Decision_Tables/Thumbs.db =================================================================== (Binary files differ) Property changes on: labs/jbossrules/trunk/documentation/manual/en/Chapter-Decision_Tables/Thumbs.db ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: labs/jbossrules/trunk/documentation/manual/en/Chapter-Decision_Tables/excel.png =================================================================== (Binary files differ) Property changes on: labs/jbossrules/trunk/documentation/manual/en/Chapter-Decision_Tables/excel.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: labs/jbossrules/trunk/documentation/manual/en/Chapter-Decision_Tables/expanded.png =================================================================== (Binary files differ) Property changes on: labs/jbossrules/trunk/documentation/manual/en/Chapter-Decision_Tables/expanded.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: labs/jbossrules/trunk/documentation/manual/en/Chapter-Decision_Tables/keywords.png =================================================================== (Binary files differ) Property changes on: labs/jbossrules/trunk/documentation/manual/en/Chapter-Decision_Tables/keywords.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: labs/jbossrules/trunk/documentation/manual/en/Chapter-Decision_Tables/multi_table.png =================================================================== (Binary files differ) Property changes on: labs/jbossrules/trunk/documentation/manual/en/Chapter-Decision_Tables/multi_table.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: labs/jbossrules/trunk/documentation/manual/en/Chapter-Decision_Tables/open_office.png =================================================================== (Binary files differ) Property changes on: labs/jbossrules/trunk/documentation/manual/en/Chapter-Decision_Tables/open_office.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: labs/jbossrules/trunk/documentation/manual/en/Chapter-Decision_Tables/row_col.png =================================================================== (Binary files differ) Property changes on: labs/jbossrules/trunk/documentation/manual/en/Chapter-Decision_Tables/row_col.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: labs/jbossrules/trunk/documentation/manual/en/Chapter-Decision_Tables/wizard.png =================================================================== (Binary files differ) Property changes on: labs/jbossrules/trunk/documentation/manual/en/Chapter-Decision_Tables/wizard.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream |
From: <jbo...@li...> - 2006-05-04 10:21:14
|
Author: mla...@jb... Date: 2006-05-04 06:21:11 -0400 (Thu, 04 May 2006) New Revision: 4085 Modified: labs/jbossweb/trunk/src/share/resources/ROOT.war/index.jsp Log: Uncomment the console link. It works now. Modified: labs/jbossweb/trunk/src/share/resources/ROOT.war/index.jsp =================================================================== --- labs/jbossweb/trunk/src/share/resources/ROOT.war/index.jsp 2006-05-04 10:05:45 UTC (rev 4084) +++ labs/jbossweb/trunk/src/share/resources/ROOT.war/index.jsp 2006-05-04 10:21:11 UTC (rev 4085) @@ -50,9 +50,7 @@ <li><a href="/status">Server Status</a></li> <li><a href="/status?full=true">Full Server Status</a></li> <li><a href="/jmx-console/">JMX Console</a></li> - <!-- <li><a href="/web-console/">JBoss Web Console</a></li> - --> </ul> </p> <br> |
From: <jbo...@li...> - 2006-05-04 10:05:54
|
Author: mic...@jb... Date: 2006-05-04 06:05:45 -0400 (Thu, 04 May 2006) New Revision: 4084 Modified: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/PackageBuilder.java Log: documentation improvements Modified: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/PackageBuilder.java =================================================================== --- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/PackageBuilder.java 2006-05-04 09:41:00 UTC (rev 4083) +++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/PackageBuilder.java 2006-05-04 10:05:45 UTC (rev 4084) @@ -44,6 +44,11 @@ import org.drools.xml.XmlPackageReader; import org.xml.sax.SAXException; +/** + * This is the main compiler class for parsing and compiling rules and assembling or merging them into a + * binary Package instance. + * This can be done by merging into existing binary packages, or totally from source. + */ public class PackageBuilder { private JavaCompiler compiler; @@ -57,16 +62,27 @@ private PackageBuilderConfiguration configuration; + /** + * Use this when package is starting from scratch. + */ public PackageBuilder() { this( null, null ); } + /** + * This will allow you to merge rules into this pre existing package. + */ public PackageBuilder(Package pkg) { this( pkg, null ); } + /** + * This allows you to pass in a pre existing package, and a configuration (for instance to set the classloader). + * @param pkg A pre existing package (can be null if none exists) + * @param configuration Optional configuration for this builder. + */ public PackageBuilder(Package pkg, PackageBuilderConfiguration configuration) { if ( configuration == null ) { |
From: <jbo...@li...> - 2006-05-04 09:41:21
|
Author: mar...@jb... Date: 2006-05-04 05:41:00 -0400 (Thu, 04 May 2006) New Revision: 4083 Modified: labs/jbosstm/trunk/ArjunaJTS/trailmap/README.txt labs/jbosstm/trunk/ArjunaJTS/trailmap/src/com/arjuna/demo/jta/jdbcbank/Bank.java Log: Fixed trailmap. http://jira.jboss.com/jira/browse/JBTM-58 Modified: labs/jbosstm/trunk/ArjunaJTS/trailmap/README.txt =================================================================== --- labs/jbosstm/trunk/ArjunaJTS/trailmap/README.txt 2006-05-04 09:40:18 UTC (rev 4082) +++ labs/jbosstm/trunk/ArjunaJTS/trailmap/README.txt 2006-05-04 09:41:00 UTC (rev 4083) @@ -1,53 +1,84 @@ -JBoss, Home of Professional Open Source -Copyright 2006, JBoss Inc., and individual contributors as indicated -by the @authors tag. All rights reserved. -See the copyright.txt in the distribution for a full listing -of individual contributors. -This copyrighted material is made available to anyone wishing to use, -modify, copy, or redistribute it subject to the terms and conditions -of the GNU General Public License, v. 2.0. -This program is distributed in the hope that it will be useful, but WITHOUT A -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A -PARTICULAR PURPOSE. See the GNU General Public License for more details. -You should have received a copy of the GNU General Public License, -v. 2.0 along with this distribution; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, -MA 02110-1301, USA. - -(C) 2005-2006, -@author JBoss Inc. -The trail map is provided with examples (the Banking application) that -allow a better understanding of the way to use the JBossTS -Programming interfaces. - -To build the sources files you should follow instructins given below: - - -- Ensure you have the Ant build system installed. Ant is a Java build -tool, similar to make. - It is available for free from http://ant.apache.org/ - The sample application requires version 1.5.1 or later. - -- The PATH and CLASSPATH environment variables need to be set -appropriately to use Arjuna Transaction Service. - - To make this easier, we provide a shell script setup-env.sh (and for - Windows a batch file setup-env.bat) which you can either source, or - use to input into your own environment. These scripts are located in - in the directory <arjunats_install_root>/bin/ - -Important Note: - - Ensure that, in your CLASSPATH, any JBossTS jar file appears before - the jacorb (version 2.2.2) jar files - - From a command prompt, go (or 'cd') to the directory containing the - build.xml file (<arjunats_install_root>/trailmap) and type 'ant'. - - Add the generated file named arjunats-demo.jar and located under - <arjunats_install_root>/trailmap/lib in you CLASSPATH environment - variable. - - For each sample, refer to the appropriate trail page. - - +JBoss, Home of Professional Open Source +Copyright 2006, JBoss Inc., and individual contributors as indicated +by the @authors tag. All rights reserved. +See the copyright.txt in the distribution for a full listing +of individual contributors. +This copyrighted material is made available to anyone wishing to use, +modify, copy, or redistribute it subject to the terms and conditions +of the GNU General Public License, v. 2.0. +This program is distributed in the hope that it will be useful, but WITHOUT A +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A +PARTICULAR PURPOSE. See the GNU General Public License for more details. +You should have received a copy of the GNU General Public License, +v. 2.0 along with this distribution; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +MA 02110-1301, USA. + +(C) 2005-2006, +@author JBoss Inc. +The trail map is provided with examples (the Banking application) that +allow a better understanding of the way to use the JBossTS +Programming interfaces. + +To build the sources files you should follow instructins given below: + + +- Ensure you have the Ant build system installed. Ant is a Java build +tool, similar to make. + It is available for free from http://ant.apache.org/ + The sample application requires version 1.5.1 or later. + +- The PATH and CLASSPATH environment variables need to be set +appropriately to use Arjuna Transaction Service. + + To make this easier, we provide a shell script setup-env.sh (and for + Windows a batch file setup-env.bat) which you can either source, or + use to input into your own environment. These scripts are located in + in the directory <arjunats_install_root>/bin/ + + JNDI is recommended way to use XADataSource because it isolates the application from the + different jdbc implementations. The JNDI implementation, that the jdbcbank sample uses is fscontext.jar, + which can be download from http://java.sun.com/products/jndi/downloads/index.html + +Important Note: + + Ensure that, in your CLASSPATH, any JBossTS jar file appears before + the jacorb (version 2.2.2) jar files + + From a command prompt, go (or 'cd') to the directory containing the + build.xml file (<arjunats_install_root>/trailmap) and type 'ant'. + + Add the generated file named arjunats-demo.jar and located under + <arjunats_install_root>/trailmap/lib in you CLASSPATH environment + variable. + + For each sample, refer to the appropriate trail page. + + Database Note: + + The out-of-the-box configuration assumes an Oracle database. If you want + to use MSSQLServer, then you need to do the following: + + 1. install SQL Server JDBC XA procedures http://edocs.bea.com/wls/docs81/jdbc_drivers/mssqlserver.html#1075232 + 2. Start up the Microsoft Distributed Transaction Coordinator (DTC) http://msdn2.microsoft.com/en-US/library/ms378931(SQL.90).aspx + +If to shift from using Oracle as in jdbcbank example to Microsoft SQLServer 2000, the +initialization code for XADataSource should be replaced. The jdbc driver which may be used is available from: +http://www.microsoft.com/downloads/details.aspx?familyid=07287B11-0502-461A-B138-2AA54BFDC03A&displaylang=en + +<code> + SQLServerDataSource ds = new com.microsoft.jdbcx.sqlserver.SQLServerDataSource(); + ds.setDescription("MSSQLServer2k DataSource"); + ds.setServerName(host); + ds.setPortNumber(1433); + ds.setDatabaseName(dbName); + ds.setSelectMethod("cursor"); //It's a Must emphasized in Driver's User Manual +</code> +to replace +<code> + Class oracleXADataSource = Class.forName("oracle.jdbc.xa.client.OracleXADataSource"); + DataSource ds = (DataSource) oracleXADataSource.newInstance(); + Method setUrlMethod = oracleXADataSource.getMethod("setURL", new Class[]{String.class}); + setUrlMethod.invoke(ds, new Object[]{new String("jdbc:oracle:thin:@" + host + ":" + port + ":" + dbName)}); +</code> + Modified: labs/jbosstm/trunk/ArjunaJTS/trailmap/src/com/arjuna/demo/jta/jdbcbank/Bank.java =================================================================== --- labs/jbosstm/trunk/ArjunaJTS/trailmap/src/com/arjuna/demo/jta/jdbcbank/Bank.java 2006-05-04 09:40:18 UTC (rev 4082) +++ labs/jbosstm/trunk/ArjunaJTS/trailmap/src/com/arjuna/demo/jta/jdbcbank/Bank.java 2006-05-04 09:41:00 UTC (rev 4083) @@ -1,276 +1,284 @@ -/* - * JBoss, Home of Professional Open Source - * Copyright 2006, JBoss Inc., and individual contributors as indicated - * by the @authors tag. All rights reserved. - * See the copyright.txt in the distribution for a full listing - * of individual contributors. - * This copyrighted material is made available to anyone wishing to use, - * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU General Public License, v. 2.0. - * This program is distributed in the hope that it will be useful, but WITHOUT A - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A - * PARTICULAR PURPOSE. See the GNU General Public License for more details. - * You should have received a copy of the GNU General Public License, - * v. 2.0 along with this distribution; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301, USA. - * - * (C) 2005-2006, - * @author JBoss Inc. - */ -/* - * Copyright (C) 2003, 2004 - * Arjuna Technologies Limited - * Newcastle upon Tyne, UK - * - * $Id: Bank.java 2342 2006-03-30 13:06:17Z $ - */ - -package com.arjuna.demo.jta.jdbcbank; - -import com.arjuna.ats.jdbc.TransactionalDriver; - -import java.sql.Connection; -import java.sql.DriverManager; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Statement; -import java.util.Properties; - - -/** - * This is the JDBC implementation of the Bank class used in the Arjuna Transactions product trailmap. It is used to - * create and clean the database that the example uses as well as perform the banking operations that all Bank - * implementations in the trailmap provide, such as creating and accessing an account. - */ -public class Bank -{ - /** - * An implementation of an SQL driver which can be used for transactional access to a database. - */ - private TransactionalDriver arjunaJDBC2Driver; - - /** - * The properties are used by the connection to log in to the database. - */ - private static Properties dbProperties; - - /** - * Creates a new JDBC-backed bank object. - */ - public Bank() - { - try - { - // Register the driver to use - DriverManager.registerDriver(new TransactionalDriver()); - - // Populate the connections properties with the required security credentials - dbProperties = new Properties(); - dbProperties.put(TransactionalDriver.userName, BankClient.user); - dbProperties.put(TransactionalDriver.password, BankClient.password); - - // Create the transactional driver to use to create the database - arjunaJDBC2Driver = new TransactionalDriver(); - - // Create the table (will drop an existing table if it already exists) - create_table(); - } - catch (Exception e) - { - e.printStackTrace(); - System.exit(0); - } - } - - /** - * Create a new bank account. This will reserve space in the database for the account and it's initial amount - * of cash. - * - * @param accountName The name of the account to open. - * @param openingBalance The opening balance of the account. - */ - public void create_account(String accountName, float openingBalance) - { - try - { - // Obtain a connection to the database using the transactional driver - Connection connection = arjunaJDBC2Driver.connect("jdbc:arjuna:jdbc/DB", dbProperties); - - // Create a statement and execute an update to the database to reserve space for the new bank account - Statement stmtx = connection.createStatement(); // tx statement - stmtx.executeUpdate("INSERT INTO accounts (accountName, value) VALUES ('" + accountName + "'," + openingBalance + ")"); - } - catch (SQLException e) - { - // We should set the rollback_only - System.out.println("SQL Exception ..........."); - e.printStackTrace(); - } - } - - /** - * Get the current balance of a required bank account. This will look at the database record for the account - * specified. - * - * @param accountName The name of the account to view. - * @return The balance of the requested account. - * - * @throws NotExistingAccount If the account does not exist. - */ - public float get_balance(String accountName) throws NotExistingAccount - { - float theBalance = 0; - try - { - // Obtain a connection to the database using the transactional driver - Connection connection = arjunaJDBC2Driver.connect("jdbc:arjuna:jdbc/DB", dbProperties); - - // Create a statement and execute a query on the database to determine the balance of the account - Statement stmtx = connection.createStatement(); // tx statement - ResultSet rs = stmtx.executeQuery("SELECT value from accounts WHERE name = '" + accountName + "'"); - - // Keep iterating through the result set, though there should only be one value - while (rs.next()) - { - theBalance = rs.getFloat("value"); - } - } - - catch (SQLException e) - { - // We should set the rollback_only - System.out.println("SQL Exception ..........."); - e.printStackTrace(); - throw new NotExistingAccount("The Account requested does not exist"); - } - - return theBalance; - } - - /** - * Debit the specified account by the required value. This will transactionally remove funds from the account by - * executing an update on the underlying JDBC data. - * - * @param accountName The name of the account to debit from. - * @param debitValue The amount of cash to debit from the account. - * - * @throws NotExistingAccount If the account does not exist. - */ - public void debit(String accountName, float debitValue) throws NotExistingAccount - { - try - { - // Obtain a connection to the database using the transactional driver - Connection connection = arjunaJDBC2Driver.connect("jdbc:arjuna:jdbc/DB", dbProperties); - - // Create a statement and execute an update to the database to debit the required account - Statement stmtx = connection.createStatement(); // tx statement - stmtx.executeUpdate("UPDATE accounts Set value = value - " + debitValue + " WHERE name = '" + accountName + "'"); - } - catch (SQLException e) - { - // We should set the rollback_only - System.out.println("SQL Exception ..........."); - e.printStackTrace(); - throw new NotExistingAccount("The Account requested does not exist"); - } - } - - /** - * Credit a specified bank account with the required amount. This method will transactionally update the underlying - * datastore with the amount of cash to add. - * - * @param accountName The name of the account to credit. - * @param creditAmount The amount of cash to credit the account with. - * - * @throws NotExistingAccount If the account does not exist. - */ - public void credit(String accountName, float creditAmount) throws NotExistingAccount - { - try - { - // Obtain a connection to the database using the transactional driver - Connection conne = arjunaJDBC2Driver.connect("jdbc:arjuna:jdbc/DB", dbProperties); - - // Create a statement and execute an update to the database to credit the required account - Statement stmtx = conne.createStatement(); // tx statement - stmtx.executeUpdate("UPDATE accounts Set value = value + " + creditAmount + " WHERE name = '" + accountName + "'"); - } - catch (SQLException e) - { - //We should set the rollback_only - System.out.println("SQL Exception ..........."); - e.printStackTrace(); - throw new NotExistingAccount("The Account requested does not exist"); - } - } - - /** - * This will allow the bank to transactionally move money from one account to another. - * - * @param fromAccount The account to remove money from. - * @param toAccount The account to add money to. - * @param transferAmount The amount of money to transfer. - * - * @throws NotExistingAccount If the account does not exist already. - */ - public void transfer(String fromAccount, String toAccount, float transferAmount) throws NotExistingAccount - { - try - { - // Obtain a connection to the database using the transactional driver - Connection connection = arjunaJDBC2Driver.connect("jdbc:arjuna:jdbc/DB", dbProperties); - - // Create a statement and execute an update to the database to credit the required account and debit the - // other account - Statement stmtx = connection.createStatement(); // tx statement - stmtx.executeUpdate("UPDATE accounts Set value = value - " + transferAmount + " WHERE name = '" + fromAccount + "'"); - stmtx.executeUpdate("UPDATE accounts Set value = value + " + transferAmount + " WHERE name = '" + toAccount + "'"); - } - catch (SQLException e) - { - //We should set the rollback_only - System.out.println("SQL Exception ..........."); - e.printStackTrace(); - throw new NotExistingAccount("The Account requested does not exist"); - } - } - - /** - * This utility method will create the bank account table if it does not already exist. If it does exist and the - * client has requested that the table be cleaned then the table is first dropped. - */ - private void create_table() - { - try - { - // Obtain a connection to the database using the transactional driver - System.out.println("\nCreating connection to database: "); - - // A JDBC connection is used to create and drop (where neccessary) the underlying database table - Connection connection = arjunaJDBC2Driver.connect("jdbc:arjuna:jdbc/DB", dbProperties); - - Statement stmt = connection.createStatement(); // non-tx statement - if (BankClient.clean) - { - System.out.println("\nDrop the table "); - stmt.executeUpdate("DROP TABLE accounts"); - } - - if (BankClient.clean || BankClient.create) - stmt.executeUpdate("CREATE TABLE accounts (name VARCHAR(10) NOT NULL UNIQUE, value REAL)"); - - stmt.close(); - connection.close(); - } - catch (SQLException e) - { - e.printStackTrace(); - System.exit(0); - } - } -} - - - +/* + * JBoss, Home of Professional Open Source + * Copyright 2006, JBoss Inc., and individual contributors as indicated + * by the @authors tag. All rights reserved. + * See the copyright.txt in the distribution for a full listing + * of individual contributors. + * This copyrighted material is made available to anyone wishing to use, + * modify, copy, or redistribute it subject to the terms and conditions + * of the GNU General Public License, v. 2.0. + * This program is distributed in the hope that it will be useful, but WITHOUT A + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License, + * v. 2.0 along with this distribution; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + * + * (C) 2005-2006, + * @author JBoss Inc. + */ +/* + * Copyright (C) 2003, 2004 + * Arjuna Technologies Limited + * Newcastle upon Tyne, UK + * + * $Id: Bank.java 2342 2006-03-30 13:06:17Z tjenkinson $ + */ + +package com.arjuna.demo.jta.jdbcbank; + +import com.arjuna.ats.jdbc.TransactionalDriver; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.Properties; + + +/** + * This is the JDBC implementation of the Bank class used in the Arjuna Transactions product trailmap. It is used to + * create and clean the database that the example uses as well as perform the banking operations that all Bank + * implementations in the trailmap provide, such as creating and accessing an account. + */ +public class Bank +{ + /** + * An implementation of an SQL driver which can be used for transactional access to a database. + */ + private TransactionalDriver arjunaJDBC2Driver; + + /** + * The properties are used by the connection to log in to the database. + */ + private static Properties dbProperties; + + /** + * Creates a new JDBC-backed bank object. + */ + public Bank() + { + try + { + // Register the driver to use + DriverManager.registerDriver(new TransactionalDriver()); + + // Populate the connections properties with the required security credentials + dbProperties = new Properties(); + dbProperties.put(TransactionalDriver.userName, BankClient.user); + dbProperties.put(TransactionalDriver.password, BankClient.password); + + // Create the transactional driver to use to create the database + arjunaJDBC2Driver = new TransactionalDriver(); + + // Create the table (will drop an existing table if it already exists) + create_table(); + } + catch (Exception e) + { + e.printStackTrace(); + System.exit(0); + } + } + + /** + * Create a new bank account. This will reserve space in the database for the account and it's initial amount + * of cash. + * + * @param accountName The name of the account to open. + * @param openingBalance The opening balance of the account. + */ + public void create_account(String accountName, float openingBalance) + { + try + { + // Obtain a connection to the database using the transactional driver + Connection connection = arjunaJDBC2Driver.connect("jdbc:arjuna:jdbc/DB", dbProperties); + + // Create a statement and execute an update to the database to reserve space for the new bank account + Statement stmtx = connection.createStatement(); // tx statement + stmtx.executeUpdate("INSERT INTO accounts (name, value) VALUES ('" + accountName + "'," + openingBalance + ")"); + } + catch (SQLException e) + { + // We should set the rollback_only + System.out.println("SQL Exception ..........."); + e.printStackTrace(); + } + } + + /** + * Get the current balance of a required bank account. This will look at the database record for the account + * specified. + * + * @param accountName The name of the account to view. + * @return The balance of the requested account. + * + * @throws NotExistingAccount If the account does not exist. + */ + public float get_balance(String accountName) throws NotExistingAccount + { + float theBalance = 0; + try + { + // Obtain a connection to the database using the transactional driver + Connection connection = arjunaJDBC2Driver.connect("jdbc:arjuna:jdbc/DB", dbProperties); + + // Create a statement and execute a query on the database to determine the balance of the account + Statement stmtx = connection.createStatement(); // tx statement + ResultSet rs = stmtx.executeQuery("SELECT value from accounts WHERE name = '" + accountName + "'"); + + // Keep iterating through the result set, though there should only be one value + while (rs.next()) + { + theBalance = rs.getFloat("value"); + } + } + + catch (SQLException e) + { + // We should set the rollback_only + System.out.println("SQL Exception ..........."); + e.printStackTrace(); + throw new NotExistingAccount("The Account requested does not exist"); + } + + return theBalance; + } + + /** + * Debit the specified account by the required value. This will transactionally remove funds from the account by + * executing an update on the underlying JDBC data. + * + * @param accountName The name of the account to debit from. + * @param debitValue The amount of cash to debit from the account. + * + * @throws NotExistingAccount If the account does not exist. + */ + public void debit(String accountName, float debitValue) throws NotExistingAccount + { + try + { + // Obtain a connection to the database using the transactional driver + Connection connection = arjunaJDBC2Driver.connect("jdbc:arjuna:jdbc/DB", dbProperties); + + // Create a statement and execute an update to the database to debit the required account + Statement stmtx = connection.createStatement(); // tx statement + stmtx.executeUpdate("UPDATE accounts Set value = value - " + debitValue + " WHERE name = '" + accountName + "'"); + } + catch (SQLException e) + { + // We should set the rollback_only + System.out.println("SQL Exception ..........."); + e.printStackTrace(); + throw new NotExistingAccount("The Account requested does not exist"); + } + } + + /** + * Credit a specified bank account with the required amount. This method will transactionally update the underlying + * datastore with the amount of cash to add. + * + * @param accountName The name of the account to credit. + * @param creditAmount The amount of cash to credit the account with. + * + * @throws NotExistingAccount If the account does not exist. + */ + public void credit(String accountName, float creditAmount) throws NotExistingAccount + { + try + { + // Obtain a connection to the database using the transactional driver + Connection conne = arjunaJDBC2Driver.connect("jdbc:arjuna:jdbc/DB", dbProperties); + + // Create a statement and execute an update to the database to credit the required account + Statement stmtx = conne.createStatement(); // tx statement + stmtx.executeUpdate("UPDATE accounts Set value = value + " + creditAmount + " WHERE name = '" + accountName + "'"); + } + catch (SQLException e) + { + //We should set the rollback_only + System.out.println("SQL Exception ..........."); + e.printStackTrace(); + throw new NotExistingAccount("The Account requested does not exist"); + } + } + + /** + * This will allow the bank to transactionally move money from one account to another. + * + * @param fromAccount The account to remove money from. + * @param toAccount The account to add money to. + * @param transferAmount The amount of money to transfer. + * + * @throws NotExistingAccount If the account does not exist already. + */ + public void transfer(String fromAccount, String toAccount, float transferAmount) throws NotExistingAccount + { + try + { + // Obtain a connection to the database using the transactional driver + Connection connection = arjunaJDBC2Driver.connect("jdbc:arjuna:jdbc/DB", dbProperties); + + // Create a statement and execute an update to the database to credit the required account and debit the + // other account + Statement stmtx = connection.createStatement(); // tx statement + stmtx.executeUpdate("UPDATE accounts Set value = value - " + transferAmount + " WHERE name = '" + fromAccount + "'"); + stmtx.executeUpdate("UPDATE accounts Set value = value + " + transferAmount + " WHERE name = '" + toAccount + "'"); + } + catch (SQLException e) + { + //We should set the rollback_only + System.out.println("SQL Exception ..........."); + e.printStackTrace(); + throw new NotExistingAccount("The Account requested does not exist"); + } + } + + /** + * This utility method will create the bank account table if it does not already exist. If it does exist and the + * client has requested that the table be cleaned then the table is first dropped. + */ + private void create_table() + { + try + { + // Obtain a connection to the database using the transactional driver + System.out.println("\nCreating connection to database: "); + + // A JDBC connection is used to create and drop (where neccessary) the underlying database table + Connection connection = arjunaJDBC2Driver.connect("jdbc:arjuna:jdbc/DB", dbProperties); + + Statement stmt = connection.createStatement(); // non-tx statement + if (BankClient.clean) + { + System.out.println("\nDrop the table "); + stmt.executeUpdate("DROP TABLE accounts"); + } + + if (BankClient.clean || BankClient.create) + { + stmt.executeUpdate("CREATE TABLE accounts (name VARCHAR(10) NOT NULL UNIQUE, value REAL)"); + + if (BankClient.clean) + BankClient.clean = false; + + if (BankClient.create) + BankClient.create = false; + } + + stmt.close(); + connection.close(); + } + catch (SQLException e) + { + e.printStackTrace(); + System.exit(0); + } + } +} + + + |
From: <jbo...@li...> - 2006-05-04 09:40:24
|
Author: mar...@jb... Date: 2006-05-04 05:40:18 -0400 (Thu, 04 May 2006) New Revision: 4082 Added: labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/jta/exceptions/InactiveTransactionException.java Modified: labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/transaction/arjunacore/TransactionImple.java Log: Added InactiveTransactionException Modified: labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/transaction/arjunacore/TransactionImple.java =================================================================== --- labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/transaction/arjunacore/TransactionImple.java 2006-05-04 07:38:05 UTC (rev 4081) +++ labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/transaction/arjunacore/TransactionImple.java 2006-05-04 09:40:18 UTC (rev 4082) @@ -1,1552 +1,1553 @@ -/* - * JBoss, Home of Professional Open Source - * Copyright 2006, JBoss Inc., and others contributors as indicated - * by the @authors tag. All rights reserved. - * See the copyright.txt in the distribution for a - * full listing of individual contributors. - * This copyrighted material is made available to anyone wishing to use, - * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU Lesser General Public License, v. 2.1. - * This program is distributed in the hope that it will be useful, but WITHOUT A - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A - * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - * You should have received a copy of the GNU Lesser General Public License, - * v.2.1 along with this distribution; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301, USA. - * - * (C) 2005-2006, - * @author JBoss Inc. - */ -/* - * Copyright (C) 2002, - * - * Hewlett-Packard Arjuna Labs, - * Newcastle upon Tyne, - * Tyne and Wear, - * UK. - * - * $Id: TransactionImple.java 2342 2006-03-30 13:06:17Z $ - */ - -package com.arjuna.ats.internal.jta.transaction.arjunacore; - -import com.arjuna.ats.internal.jta.xa.TxInfo; -import com.arjuna.ats.internal.jta.utils.*; -import com.arjuna.ats.internal.jta.utils.arjunacore.StatusConverter; -import com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple; -import com.arjuna.ats.internal.jta.resources.arjunacore.XAResourceRecord; - -import com.arjuna.ats.jta.utils.XAHelper; -import com.arjuna.ats.jta.xa.XidImple; -import com.arjuna.ats.jta.logging.*; -import com.arjuna.ats.jta.xa.XAModifier; - -import com.arjuna.ats.arjuna.coordinator.ActionStatus; -import com.arjuna.ats.arjuna.coordinator.BasicAction; -import com.arjuna.ats.arjuna.coordinator.AddOutcome; -import com.arjuna.ats.arjuna.common.*; - -import com.arjuna.common.util.logging.*; - -import javax.transaction.xa.*; - -import java.util.Hashtable; -import java.util.Enumeration; - -import javax.transaction.RollbackException; -import java.lang.IllegalStateException; - -/* - * Is given an AtomicAction, but uses the TwoPhaseCoordinator aspects of it - * to ensure that the thread association continues. - */ - -/** - * @message com.arjuna.ats.internal.jta.transaction.arjunacore.inactive - * [com.arjuna.ats.internal.jta.transaction.arjunacore.inactive] The - * transaction is not active! - * @message com.arjuna.ats.internal.jta.transaction.arjunacore.nullres - * [com.arjuna.ats.internal.jta.transaction.arjunacore.nullres] - * Resource paramater is null! - * @message com.arjuna.ats.internal.jta.transaction.arjunacore.illresstate - * [com.arjuna.ats.internal.jta.transaction.arjunacore.illresstate] - * illegal resource state - * @message com.arjuna.ats.internal.jta.transaction.arjunacore.notatomicaction - * [com.arjuna.ats.internal.jta.transaction.arjunacore.notatomicaction] - * Current transaction is not an AtomicAction! - */ - -public class TransactionImple implements javax.transaction.Transaction, - com.arjuna.ats.jta.transaction.Transaction -{ - - /* - * Only works with AtomicAction and TwoPhaseCoordinator. - */ - - /** - * Create a new transaction with the specified timeout. - */ - - public TransactionImple(int timeout) - { - _theTransaction = new AtomicAction(); - - _theTransaction.begin(timeout); - - _resources = new Hashtable(); - _duplicateResources = new Hashtable(); - _suspendCount = 0; - } - - /** - * Overloads Object.equals() - */ - - public boolean equals(Object obj) - { - if (jtaLogger.logger.isDebugEnabled()) - { - jtaLogger.logger.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC, com.arjuna.ats.jta.logging.FacilityCode.FAC_JTA, "TransactionImple.equals"); - } - - if (obj == null) - return false; - - if (obj == this) - return true; - - if (obj instanceof TransactionImple) - { - /* - * If we can't get either coordinator to compare, then assume - * transactions are different. - */ - - try - { - TransactionImple tx = (TransactionImple) obj; - - return tx.get_uid().equals(_theTransaction.get_uid()); - } - catch (Exception e) - { - } - } - - return false; - } - - /** - * Return -1 if we fail. - */ - - public int hashCode() - { - if (_theTransaction == null) - return -1; - else - return _theTransaction.get_uid().hashCode(); - } - - /** - * The JTA specification is vague on whether the calling thread can have any - * transaction associated with it. It does say that it need not have the - * same transaction as this one. We could call suspend prior to making these - * calls, but for now we do nothing. - */ - - /** - * We should never throw a HeuristicRollbackException because if we get a - * HeuristicRollback from a resource, and can successfully rollback the - * other resources, this is then the same as having simply been forced to - * rollback the transaction during phase 1. - * - * @message com.arjuna.ats.internal.jta.transaction.arjunacore.invalidstate - * [com.arjuna.ats.internal.jta.transaction.arjunacore.invalidstate] - * Invalid transaction state - */ - - public void commit() throws javax.transaction.RollbackException, - javax.transaction.HeuristicMixedException, - javax.transaction.HeuristicRollbackException, - java.lang.SecurityException, javax.transaction.SystemException, - java.lang.IllegalStateException - { - if (jtaLogger.logger.isDebugEnabled()) - { - jtaLogger.logger.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC, com.arjuna.ats.jta.logging.FacilityCode.FAC_JTA, "TransactionImple.commit"); - } - - if (_theTransaction != null) - { - switch (_theTransaction.status()) - { - case ActionStatus.RUNNING: - case ActionStatus.ABORT_ONLY: - break; - default: - throw new IllegalStateException( - jtaLogger.logMesg.getString("com.arjuna.ats.internal.jta.transaction.arjunacore.inactive")); - } - - /* - * Call end on any suspended resources. If this fails, then the - * transaction will be rolled back. - */ - - if (!endSuspendedRMs()) - _theTransaction.preventCommit(); - - // use end of TwoPhaseCoordinator to avoid thread changes. - - int status = _theTransaction.end(true); - - TransactionImple.removeTransaction(this); - - switch (status) - { - case ActionStatus.COMMITTED: - case ActionStatus.COMMITTING: // in case of async commit - break; - case ActionStatus.H_MIXED: - throw new javax.transaction.HeuristicMixedException(); - case ActionStatus.H_HAZARD: - throw new javax.transaction.HeuristicMixedException(); - case ActionStatus.H_ROLLBACK: - case ActionStatus.ABORTED: - throw new RollbackException(); - default: - throw new IllegalStateException( - jtaLogger.logMesg.getString("com.arjuna.ats.internal.jta.transaction.arjunacore.invalidstate")); - } - } - else - throw new IllegalStateException( - jtaLogger.logMesg.getString("com.arjuna.ats.internal.jta.transaction.arjunacore.inactive")); - } - - /** - * @message com.arjuna.ats.internal.jta.transaction.arjunacore.rollbackstatus - * [com.arjuna.ats.internal.jta.transaction.arjunacore.rollbackstatus] - * Transaction rollback status is: - * @message com.arjuna.ats.internal.jta.transaction.arjunacore.endsuspendfailed1 - * [com.arjuna.ats.internal.jta.transaction.arjunacore.endsuspendfailed1] - * Ending suspended RMs failed when rolling back the transaction! - * @message com.arjuna.ats.internal.jta.transaction.arjunacore.endsuspendfailed2 - * [com.arjuna.ats.internal.jta.transaction.arjunacore.endsuspendfailed2] - * Ending suspended RMs failed when rolling back the transaction, - * but transaction rolled back. - */ - - public void rollback() throws java.lang.IllegalStateException, - java.lang.SecurityException, javax.transaction.SystemException - { - if (jtaLogger.logger.isDebugEnabled()) - { - jtaLogger.logger.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC, com.arjuna.ats.jta.logging.FacilityCode.FAC_JTA, "TransactionImple.rollback"); - } - - if (_theTransaction != null) - { - switch (_theTransaction.status()) - { - case ActionStatus.RUNNING: - case ActionStatus.ABORT_ONLY: - break; - default: - throw new IllegalStateException( - jtaLogger.logMesg.getString("com.arjuna.ats.internal.jta.transaction.arjunacore.inactive")); - } - - /* - * Call end on any suspended resources. If this fails, then there's - * not a lot else we can do because the transaction is about to roll - * back anyway! - */ - - boolean endSuspendedFailed = !endSuspendedRMs(); - - if (endSuspendedFailed) - { - if (jtaLogger.loggerI18N.isWarnEnabled()) - { - jtaLogger.loggerI18N.warn("com.arjuna.ats.internal.jta.transaction.arjunacore.endsuspendfailed1"); - } - } - - int outcome = _theTransaction.cancel(); // use cancel of - // TwoPhaseCoordinator to - // avoid thread changes. - - TransactionImple.removeTransaction(this); - - switch (outcome) - { - case ActionStatus.ABORTED: - case ActionStatus.ABORTING: // in case of async rollback - break; - default: - throw new IllegalStateException( - jtaLogger.logMesg.getString("com.arjuna.ats.internal.jta.transaction.arjunacore.rollbackstatus") - + ActionStatus.stringForm(outcome)); - } - - if (endSuspendedFailed) - throw new IllegalStateException( - jtaLogger.logMesg.getString("com.arjuna.ats.internal.jta.transaction.arjunacore.endsuspendfailed2")); - } - else - throw new IllegalStateException( - jtaLogger.logMesg.getString("com.arjuna.ats.internal.jta.transaction.arjunacore.inactive")); - } - - public void setRollbackOnly() throws java.lang.IllegalStateException, - javax.transaction.SystemException - { - if (jtaLogger.logger.isDebugEnabled()) - { - jtaLogger.logger.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC, com.arjuna.ats.jta.logging.FacilityCode.FAC_JTA, "TransactionImple.setRollbackOnly"); - } - - if (_theTransaction != null) - { - if (!_theTransaction.preventCommit()) - throw new IllegalStateException( - jtaLogger.logMesg.getString("com.arjuna.ats.internal.jta.transaction.arjunacore.inactive")); - } - else - throw new IllegalStateException( - jtaLogger.logMesg.getString("com.arjuna.ats.internal.jta.transaction.arjunacore.inactive")); - } - - public int getStatus () throws javax.transaction.SystemException - { - if (jtaLogger.logger.isDebugEnabled()) - { - jtaLogger.logger.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC, com.arjuna.ats.jta.logging.FacilityCode.FAC_JTA, "TransactionImple.getStatus"); - } - - int status = javax.transaction.Status.STATUS_NO_TRANSACTION; - - if (_theTransaction != null) - { - return StatusConverter.convert(_theTransaction.status()); - } - - return status; - } - - /** - * @message com.arjuna.ats.internal.jta.transaction.arjunacore.nullparam - * [com.arjuna.ats.internal.jta.transaction.arjunacore.nullparam] - * null synchronization parameter! - * @message com.arjuna.ats.internal.jta.transaction.arjunacore.syncsnotallowed - * [com.arjuna.ats.internal.jta.transaction.arjunacore.syncsnotallowed] - * Synchronizations are not allowed! - */ - - public void registerSynchronization(javax.transaction.Synchronization sync) - throws javax.transaction.RollbackException, - java.lang.IllegalStateException, javax.transaction.SystemException - { - if (jtaLogger.logger.isDebugEnabled()) - { - jtaLogger.logger.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC, com.arjuna.ats.jta.logging.FacilityCode.FAC_JTA, "TransactionImple.registerSynchronization"); - } - - if (sync == null) - throw new javax.transaction.SystemException( - "TransactionImple.registerSynchronization - " - + jtaLogger.logMesg.getString("com.arjuna.ats.internal.jta.transaction.arjunacore.nullparam")); - - if (_theTransaction != null) - { - SynchronizationImple s = new SynchronizationImple(sync); - - if (_theTransaction.addSynchronization(s) != AddOutcome.AR_ADDED) - { - int status = _theTransaction.status(); - - switch (status) - { - case ActionStatus.ABORTED: - throw new javax.transaction.RollbackException(); - case ActionStatus.CREATED: - throw new IllegalStateException( - jtaLogger.logMesg.getString("com.arjuna.ats.internal.jta.transaction.arjunacore.inactive")); - default: - throw new IllegalStateException( - jtaLogger.logMesg.getString("com.arjuna.ats.internal.jta.transaction.arjunacore.syncsnotallowed")); - } - } - } - else - throw new IllegalStateException( - jtaLogger.logMesg.getString("com.arjuna.ats.internal.jta.transaction.arjunacore.inactive")); - } - - /** - * This is the JTA compliant version of the method. However, you had better - * know that your XAResource and family are truly compliant implementations. - * If they aren't then we may fail gracefully (e.g., some versions of Oracle - * don't work with arbitrary Xid implementations!) - * - * If the family isn't compliant, then you should use the other method and - * pass through a relevant XAModifier, which should address the issues we - * have already come across. - */ - - public boolean enlistResource(XAResource xaRes) throws RollbackException, - IllegalStateException, javax.transaction.SystemException - { - return enlistResource(xaRes, null); - } - - /** - * @message com.arjuna.ats.internal.jta.transaction.arjunacore.enlisterror - * [com.arjuna.ats.internal.jta.transaction.arjunacore.enlisterror] - * {0} - caught: {1} - * @message com.arjuna.ats.internal.jta.transaction.arjunacore.timeouterror[com.arjuna.ats.internal.jta.transaction.arjunacore.timeouterror] - * {0} setTransactionTimeout caught: {1} - * @message com.arjuna.ats.internal.jta.transaction.arjunacore.enliststarterror - * [com.arjuna.ats.internal.jta.transaction.arjunacore.enliststarterror] - * {0} - XAResource.start returned: {1} for {2} - * @message com.arjuna.ats.internal.jta.transaction.arjunacore.couldnotregister - * [com.arjuna.ats.internal.jta.transaction.arjunacore.couldnotregister] - * could not register transaction - * @message com.arjuna.ats.internal.jta.transaction.arjunacore.xastart - * [com.arjuna.ats.internal.jta.transaction.arjunacore.xastart] {0} - - * caught: {1} for {2} - */ - - public boolean enlistResource(XAResource xaRes, Object[] params) - throws RollbackException, IllegalStateException, - javax.transaction.SystemException - { - if (jtaLogger.logger.isDebugEnabled()) - { - jtaLogger.logger.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC, com.arjuna.ats.jta.logging.FacilityCode.FAC_JTA, "TransactionImple.enlistResource ( " - + xaRes + " )"); - } - - if (xaRes == null) - throw new javax.transaction.SystemException( - "TransactionImple.enlistResource - " - + jtaLogger.logMesg.getString("com.arjuna.ats.internal.jta.transaction.arjunacore.nullres")); - - int status = getStatus(); - - switch (status) - { - case javax.transaction.Status.STATUS_MARKED_ROLLBACK: - throw new RollbackException(); - case javax.transaction.Status.STATUS_ACTIVE: - break; - default: - throw new IllegalStateException( - jtaLogger.logMesg.getString("com.arjuna.ats.internal.jta.transaction.arjunacore.inactive")); - } - - XAModifier theModifier = null; - - if (params != null) - { - if (params.length >= XAMODIFIER + 1) - { - if (params[XAMODIFIER] instanceof XAModifier) - { - theModifier = (XAModifier) params[XAMODIFIER]; - } - } - } - - try - { - /* - * For each transaction we maintain a list of resources registered - * with it. Each element on this list also contains a list of - * threads which have registered this resource, and what their XID - * was for that registration. - */ - - TxInfo info = null; - - /* - * Have we seen this specific resource instance before? Do this - * trawl first before checking the RM instance later. Saves time. - */ - - try - { - synchronized (this) - { - info = (TxInfo) _resources.get(xaRes); - - if (info == null) - { - /* - * Null info means it's not in the main resources list, - * but may be in the duplicates. - */ - - info = (TxInfo) _duplicateResources.get(xaRes); - } - } - - if (info != null) - { - switch (info.getState()) - { - case TxInfo.ASSOCIATION_SUSPENDED: - { - /* - * Have seen resource before, so do a resume. The - * Resource instance will still be registered with the - * transaction though. - */ - - int xaStartResume = ((theModifier == null) ? XAResource.TMRESUME - : theModifier.xaStartParameters(XAResource.TMRESUME)); - - xaRes.start(info.xid(), xaStartResume); - - info.setState(TxInfo.ASSOCIATED); - - synchronized (this) - { - _suspendCount--; - } - - return true; // already registered resource with this - // transaction! - } - case TxInfo.ASSOCIATED: - { - /* - * Already active on this transaction. - */ - - return true; - } - case TxInfo.NOT_ASSOCIATED: - { - /* - * Resource was associated, but was presumably delisted. - */ - - int xaStartJoin = ((theModifier == null) ? XAResource.TMJOIN - : theModifier.xaStartParameters(XAResource.TMJOIN)); - - xaRes.start(info.xid(), xaStartJoin); - - info.setState(TxInfo.ASSOCIATED); - - return true; - } - default: - { - // Note: this exception will be caught by our catch - // block - - throw new IllegalStateException( - "TransactionImple.enlistResource - " - + jtaLogger.logMesg.getString("com.arjuna.ats.internal.jta.transaction.arjunacore.illresstate") - + ":" + info.getState()); - } - } - } - } - catch (IllegalStateException ex) - { - throw ex; // we threw it in the first place - } - catch (XAException exp) - { - if (info != null) - info.setState(TxInfo.FAILED); - - if (jtaLogger.loggerI18N.isWarnEnabled()) - { - jtaLogger.loggerI18N.warn("com.arjuna.ats.internal.jta.transaction.arjunacore.enlisterror", new Object[] - { "TransactionImple.enlistResource", XAHelper.printXAErrorCode(exp) }); - } - - return false; - } - - // if (threadIsActive(xaRes)) - // return true; // this thread has already registered a resource for - // this db - - /* - * We definitely haven't seen this specific resource instance - * before, but that doesn't mean that we haven't seen the RM it is - * connected to. - */ - - Xid xid = null; - TxInfo existingRM = isNewRM(xaRes); - - if (existingRM == null) - { - /* - * New RM, so create xid with new branch. - */ - - boolean branchRequired = true; - - synchronized (this) - { - if (_resources.size() == 0)// first ever, so no need for - // branch - { - //branchRequired = false; - branchRequired = true; - } - } - - xid = createXid(branchRequired, theModifier); - - boolean associatedWork = false; - int retry = 20; - - /* - * If another process has (or is about to) create the same - * transaction association then we will probably get a failure - * during start with XAER_DUPID. We know this must be due to - * another server, since we keep track of our own registrations. - * So, if this happens we create a new transaction branch and - * try again. - * - * To save time we could always just create branches by default. - * - * Is there a benefit to a zero branch? - */ - - while (!associatedWork) - { - try - { - int xaStartNormal = ((theModifier == null) ? XAResource.TMNOFLAGS - : theModifier.xaStartParameters(XAResource.TMNOFLAGS)); - - xaRes.start(xid, xaStartNormal); - - int timeout = _theTransaction.getTimeout(); - - if (timeout > 0) - { - try - { - xaRes.setTransactionTimeout(timeout); - } - catch (XAException te) - { - if (jtaLogger.loggerI18N.isWarnEnabled()) - { - jtaLogger.loggerI18N.warn("com.arjuna.ats.internal.jta.transaction.arjunacore.timeouterror", new Object[] - { "TransactionImple.enlistResource", XAHelper.printXAErrorCode(te), xid }); - } - } - } - - associatedWork = true; - - _resources.put(xaRes, new TxInfo(xid)); - } - catch (XAException e) - { - // transaction already created by another server - - if ((e.errorCode == XAException.XAER_DUPID) - || (e.errorCode == XAException.XAER_RMERR)) - { - if (retry > 0) - xid = createXid(true, theModifier); - - retry--; - } - else - { - /* - * Can't do start, so set transaction to rollback - * only. - */ - - if (jtaLogger.loggerI18N.isWarnEnabled()) - { - jtaLogger.loggerI18N.warn("com.arjuna.ats.internal.jta.transaction.arjunacore.enliststarterror", new Object[] - { "TransactionImple.enlistResource", XAHelper.printXAErrorCode(e), xid }); - } - - markRollbackOnly(); - - throw e; - } - - if (retry < 0) - { - if (jtaLogger.loggerI18N.isWarnEnabled()) - { - jtaLogger.loggerI18N.warn("com.arjuna.ats.internal.jta.transaction.arjunacore.enliststartfailed", new Object[] - { "TransactionImple.enlistResource", xid }); - } - - markRollbackOnly(); - - throw new javax.transaction.SystemException( - "TransactionImple.enlistResource - XAResource.start " - + jtaLogger.logMesg.getString("com.arjuna.ats.internal.jta.transaction.arjunacore.couldnotregister") - + ": " + xid); - } - } - } - } - else - { - /* - * Have seen this RM before, so ignore this instance. The first - * registered RM instance will be used to drive the transaction - * completion. We add it to the duplicateResource list so we can - * delist it correctly later though. - */ - - /* - * Re-create xid. - */ - - xid = existingRM.xid(); - - try - { - int xaStartJoin = ((theModifier == null) ? XAResource.TMJOIN - : theModifier.xaStartParameters(XAResource.TMJOIN)); - - xaRes.start(xid, xaStartJoin); - } - catch (XAException ex) - { - if (jtaLogger.loggerI18N.isWarnEnabled()) - { - jtaLogger.loggerI18N.warn("com.arjuna.ats.internal.jta.transaction.arjunacore.xastart", new Object[] - { "TransactionImple.enlistResource - xa_start ", XAHelper.printXAErrorCode(ex), xid }); - } - - markRollbackOnly(); - - throw ex; - } - - /* - * Add to duplicate resources list so we can keep track of it - * (particularly if we later have to delist). - */ - - _duplicateResources.put(xaRes, new TxInfo(xid)); - - return true; - } - - /* - * Control and Coordinator should be set, or we would not have - * gotten this far! - */ - - XAResourceRecord res = new XAResourceRecord(this, xaRes, xid, - params); - - if (_theTransaction.add(res) != AddOutcome.AR_ADDED) - { - markRollbackOnly(); - - return false; - } - else - return true; - } - catch (Exception e) - { - e.printStackTrace(); - - /* - * Some exceptional condition arose and we probably could not enlist - * the resouce. So, for safety mark the transaction as rollback - * only. - */ - - markRollbackOnly(); - - return false; - } - } - - /* - * Do we have to unregister resources? Assume not as it would not make much - * sense otherwise! - */ - - /** - * @message com.arjuna.ats.internal.jta.transaction.arjunacore.unknownresource - * [com.arjuna.ats.internal.jta.transaction.arjunacore.unknownresource] - * {0} - unknown resource - * @message com.arjuna.ats.internal.jta.transaction.arjunacore.delistresource - * [com.arjuna.ats.internal.jta.transaction.arjunacore.delistresource] - * {0} - caught exception during delist : {1} - * @message com.arjuna.ats.internal.jta.transaction.arjunacore.delistgeneral - * [com.arjuna.ats.internal.jta.transaction.arjunacore.delistgeneral] - * {0} caught exception {1} - * @message com.arjuna.ats.internal.jta.transaction.arjunacore.ressuspended - * [com.arjuna.ats.internal.jta.transaction.arjunacore.ressuspended] - * resource already suspended. - */ - - public boolean delistResource(XAResource xaRes, int flags) - throws IllegalStateException, javax.transaction.SystemException - { - if (jtaLogger.logger.isDebugEnabled()) - { - jtaLogger.logger.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC, com.arjuna.ats.jta.logging.FacilityCode.FAC_JTA, "TransactionImple.delistResource ( " - + xaRes + " )"); - } - - if (xaRes == null) - throw new javax.transaction.SystemException( - "TransactionImple.delistResource - " - + jtaLogger.logMesg.getString("com.arjuna.ats.internal.jta.transaction.arjunacore.nullres")); - - int status = getStatus(); - - switch (status) - { - case javax.transaction.Status.STATUS_ACTIVE: - break; - case javax.transaction.Status.STATUS_MARKED_ROLLBACK: - break; - default: - throw new IllegalStateException( - jtaLogger.logMesg.getString("com.arjuna.ats.internal.jta.transaction.arjunacore.inactive")); - } - - TxInfo info = null; - - try - { - synchronized (this) - { - info = (TxInfo) _resources.get(xaRes); - - if (info == null) - info = (TxInfo) _duplicateResources.get(xaRes); - } - - if (info == null) - { - if (jtaLogger.loggerI18N.isWarnEnabled()) - { - jtaLogger.loggerI18N.warn("com.arjuna.ats.internal.jta.transaction.arjunacore.unknownresource", new Object[] - { "TransactionImple.delistResource" }); - } - - return false; - } - else - { - boolean optimizedRollback = false; - - try - { - /* - * If we know the transaction is going to rollback, then we - * can try to rollback the RM now. Just an optimisation. - */ - - if (status == javax.transaction.Status.STATUS_MARKED_ROLLBACK) - { - if (XAUtils.canOptimizeDelist(xaRes)) - { - xaRes.end(info.xid(), XAResource.TMFAIL); - xaRes.rollback(info.xid()); - - info.setState(TxInfo.OPTIMIZED_ROLLBACK); - - optimizedRollback = true; - } - } - } - catch (Exception e) - { - // failed, so try again when transaction does rollback - } - - switch (info.getState()) - { - case TxInfo.ASSOCIATED: - { - if ((flags & XAResource.TMSUCCESS) != 0) - { - xaRes.end(info.xid(), XAResource.TMSUCCESS); - info.setState(TxInfo.NOT_ASSOCIATED); - } - else - { - if ((flags & XAResource.TMSUSPEND) != 0) - { - xaRes.end(info.xid(), XAResource.TMSUSPEND); - info.setState(TxInfo.ASSOCIATION_SUSPENDED); - - synchronized (this) - { - _suspendCount++; - } - } - else - { - xaRes.end(info.xid(), XAResource.TMFAIL); - info.setState(TxInfo.FAILED); - } - } - } - break; - case TxInfo.ASSOCIATION_SUSPENDED: - { - if ((flags & XAResource.TMSUCCESS) != 0) - { - // Oracle barfs if we don't send resume first, despite - // what XA says! - - if (XAUtils.mustEndSuspendedRMs(xaRes)) - xaRes.start(info.xid(), XAResource.TMRESUME); - - xaRes.end(info.xid(), XAResource.TMSUCCESS); - info.setState(TxInfo.NOT_ASSOCIATED); - - synchronized (this) - { - _suspendCount--; - } - } - else - { - if ((flags & XAResource.TMSUSPEND) != 0) - { - // Note: this exception will be caught by our catch - // block - - throw new IllegalStateException( - "TransactionImple.delistResource - " - + jtaLogger.logMesg.getString("com.arjuna.ats.internal.jta.transaction.arjunacore.ressuspended")); - } - else - { - xaRes.end(info.xid(), XAResource.TMFAIL); - info.setState(TxInfo.FAILED); - - synchronized (this) - { - _suspendCount--; - } - } - } - } - break; - default: - { - if (!optimizedRollback) - throw new IllegalStateException( - "TransactionImple.delistResource - " - + jtaLogger.logMesg.getString("com.arjuna.ats.internal.jta.transaction.arjunacore.illresstate") - + ":" + info.getState()); - } - } - - info = null; - - return true; - } - } - catch (IllegalStateException ex) - { - throw ex; - } - catch (XAException exp) - { - if (info != null) - info.setState(TxInfo.FAILED); - - /* - * For safety mark the transaction as rollback only. - */ - - markRollbackOnly(); - - if (jtaLogger.loggerI18N.isWarnEnabled()) - { - jtaLogger.loggerI18N.warn("com.arjuna.ats.internal.jta.transaction.arjunacore.delistresource", new Object[] - { "TransactionImple.delistResource", XAHelper.printXAErrorCode(exp) }); - } - - return false; - } - catch (Exception e) - { - if (jtaLogger.loggerI18N.isWarnEnabled()) - { - jtaLogger.loggerI18N.warn("com.arjuna.ats.internal.jta.transaction.arjunacore.delistgeneral", new Object[] - { "TransactionImple.delistResource", e }); - } - - /* - * Some exception occurred and we probably could not delist the - * resource. So, for safety mark the transaction as rollback only. - */ - - markRollbackOnly(); - - return false; - } - } - - public final Uid get_uid() - { - return _theTransaction.get_uid(); - } - - public String toString() - { - if (_theTransaction == null) - return "TransactionImple < ac, NoTransaction >"; - else - { - return "TransactionImple < ac, " + _theTransaction + " >"; - } - } - - public int getXAResourceState(XAResource xaRes) - { - int state = TxInfo.UNKNOWN; - - if (xaRes != null) - { - TxInfo info = (TxInfo) _resources.get(xaRes); - - if (info == null) - { - info = (TxInfo) _duplicateResources.get(xaRes); - } - - if (info != null) - state = info.getState(); - } - - return state; - } - - public static final TransactionImple getTransaction() - { - TransactionImple tx = null; - - final BasicAction current = BasicAction.Current() ; - if (current != null) - { - final Uid txid = current.get_uid(); - - tx = (TransactionImple) _transactions.get(txid); - if (tx == null) - tx = new TransactionImple(current) ; - } - - return tx; - } - - public static final TransactionImple getTransaction(Uid id) - { - try - { - if (id != null) - return (TransactionImple) _transactions.get(id); - else - return null; - } - catch (Exception e) - { - return new TransactionImple(null); - } - } - - protected TransactionImple () - { - this(null); - } - - /** - * Create a new TransactionImple representation of a specified - * transaction. - */ - - protected TransactionImple (BasicAction curr) - { - try - { - if (curr == null) - { - _theTransaction = (com.arjuna.ats.arjuna.AtomicAction) BasicAction.Current(); - } - else - _theTransaction = (com.arjuna.ats.arjuna.AtomicAction) curr; - } - catch (ClassCastException ex) - { - if (jtaLogger.loggerI18N.isWarnEnabled()) - { - jtaLogger.loggerI18N.warn("com.arjuna.ats.internal.jta.transaction.arjunacore.notatomicaction"); - } - } - - if (_theTransaction != null) - { - _resources = new Hashtable(); - _duplicateResources = new Hashtable(); - } - else - { - _resources = null; - _duplicateResources = null; - } - - _suspendCount = 0; - } - - final com.arjuna.ats.arjuna.AtomicAction getAtomicAction() - { - return _theTransaction; - } - - /** - * Does the same as commit, but also changes the thread-to-tx association. - */ - - protected void commitAndDisassociate() - throws javax.transaction.RollbackException, - javax.transaction.HeuristicMixedException, - javax.transaction.HeuristicRollbackException, - java.lang.SecurityException, javax.transaction.SystemException, - java.lang.IllegalStateException - { - if (jtaLogger.logger.isDebugEnabled()) - { - jtaLogger.logger.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC, com.arjuna.ats.jta.logging.FacilityCode.FAC_JTA, "TransactionImple.commitAndDisassociate"); - } - - if (_theTransaction != null) - { - switch (_theTransaction.status()) - { - case ActionStatus.RUNNING: - case ActionStatus.ABORT_ONLY: - break; - default: - throw new IllegalStateException( - jtaLogger.logMesg.getString("com.arjuna.ats.internal.jta.transaction.arjunacore.inactive")); - } - } - - try - { - if (_theTransaction != null) - { - switch (_theTransaction.commit(true)) - { - case ActionStatus.COMMITTED: - case ActionStatus.COMMITTING: // in case of async commit - break; - case ActionStatus.H_MIXED: - throw new javax.transaction.HeuristicMixedException(); - case ActionStatus.H_HAZARD: - throw new javax.transaction.HeuristicMixedException(); - case ActionStatus.H_ROLLBACK: - case ActionStatus.ABORTED: - throw new RollbackException(); - default: - throw new IllegalStateException( - jtaLogger.logMesg.getString("com.arjuna.ats.internal.jta.transaction.arjunacore.invalidstate")); - } - } - else - throw new IllegalStateException( - jtaLogger.logMesg.getString("com.arjuna.ats.internal.jta.transaction.arjunacore.inactive")); - } - catch (javax.transaction.HeuristicMixedException ex) - { - throw ex; - } - catch (RollbackException ex) - { - throw ex; - } - catch (IllegalStateException ex) - { - throw ex; - } - finally - { - TransactionImple.removeTransaction(this); - } - } - - /** - * If this is an imported transaction (via JCA) then this will be the Xid - * we are pretending to be. Otherwise, it will be null. - * - * @return null if we are a local transaction, a valid Xid if we have been - * imported. - */ - - protected Xid baseXid () - { - return null; - } - - /** - * Does the same as rollback, but also changes the thread-to-tx association. - */ - - protected void rollbackAndDisassociate() - throws java.lang.IllegalStateException, - java.lang.SecurityException, javax.transaction.SystemException - { - if (jtaLogger.logger.isDebugEnabled()) - { - jtaLogger.logger.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC, com.arjuna.ats.jta.logging.FacilityCode.FAC_JTA, "TransactionImple.rollbackAndDisassociate"); - } - - if (_theTransaction != null) - { - switch (_theTransaction.status()) - { - case ActionStatus.RUNNING: - case ActionStatus.ABORT_ONLY: - break; - default: - throw new IllegalStateException( - jtaLogger.logMesg.getString("com.arjuna.ats.internal.jta.transaction.arjunacore.inactive")); - } - } - - try - { - if (_theTransaction != null) - { - int outcome = _theTransaction.abort(); - - switch (outcome) - { - case ActionStatus.ABORTED: - case ActionStatus.ABORTING: // in case of async rollback - break; - default: - throw new IllegalStateException( - jtaLogger.logMesg.getString("com.arjuna.ats.internal.jta.transaction.arjunacore.rollbackstatus") - + ActionStatus.stringForm(outcome)); - } - } - else - throw new IllegalStateException( - jtaLogger.logMesg.getString("com.arjuna.ats.internal.jta.transaction.arjunacore.inactive")); - } - catch (IllegalStateException ex) - { - throw ex; - } - finally - { - TransactionImple.removeTransaction(this); - } - } - - /** - * If there are any suspended RMs then we should call end on them before the - * transaction is terminated. - * - * @message com.arjuna.ats.internal.jta.transaction.arjunacore.xaenderror - * [com.arjuna.ats.internal.jta.transaction.arjunacore.xaenderror] - * Could not call end on a suspended resource! - */ - - private boolean endSuspendedRMs() - { - boolean result = true; - - if (_suspendCount > 0) - { - Enumeration el = _resources.keys(); - - /* - * Loop over all registered resources. Those that are in a suspended - * state must have end called on them. If this fails, then we will - * eventually roll back the transaction, but we will continue down - * the list to try to end any other suspended resources. - */ - - if (el != null) - { - try - { - /* - * Would it gain us much to just loop for _suspendCount? - */ - - while (el.hasMoreElements()) - { - /* - * Get the XAResource in case we have to call end on it. - */ - - XAResource xaRes = (XAResource) el.nextElement(); - TxInfo info = (TxInfo) _resources.get(xaRes); - - if (info.getState() == TxInfo.ASSOCIATION_SUSPENDED) - { - if (XAUtils.mustEndSuspendedRMs(xaRes)) - xaRes.start(info.xid(), XAResource.TMRESUME); - - xaRes.end(info.xid(), XAResource.TMSUCCESS); - info.setState(TxInfo.NOT_ASSOCIATED); - } - } - } - catch (XAException ex) - { - if (jtaLogger.loggerI18N.isWarnEnabled()) - { - jtaLogger.loggerI18N.warn("com.arjuna.ats.internal.jta.transaction.arjunacore.xaenderror"); - } - - result = false; - } - } - - _suspendCount = 0; - } - - return result; - } - - /* - * If this thread has already registered a resource for the same db then - * don't use this copy. For some databases it would actually be ok for us to - * use the resource (at least to do an xa_start equivalent on it), but for - * Oracle 8.1.6 it causes their JDBC driver to crash! - */ - - /** - * @message com.arjuna.ats.internal.jta.transaction.arjunacore.threadexception - * [com.arjuna.ats.internal.jta.transaction.arjunacore.threadexception] - * Caught the following error: {0} - */ - - private final boolean threadIsActive(XAResource xaRes) - { - Thread t = Thread.currentThread(); - - try - { - Enumeration el = _resources.keys(); - - if (el != null) - { - while (el.hasMoreElements()) - { - XAResource x = (XAResource) el.nextElement(); - - if (x.isSameRM(xaRes)) - { - TxInfo info = (TxInfo) _resources.get(x); - - if (info.thread() == t) - return true; - } - } - } - - el = _duplicateResources.keys(); - - if (el != null) - { - while (el.hasMoreElements()) - { - XAResource x = (XAResource) el.nextElement(); - - if (x.isSameRM(xaRes)) - { - TxInfo info = (TxInfo) _resources.get(x); - - if (info.thread() == t) - return true; - } - } - } - } - catch (Exception e) - { - if (jtaLogger.loggerI18N.isWarnEnabled()) - { - jtaLogger.loggerI18N.warn("com.arjuna.ats.internal.jta.transaction.arjunacore.threadexception", new Object[] - { e }); - } - - throw new com.arjuna.ats.arjuna.exceptions.FatalError(e.toString()); - } - - return false; - } - - /** - * isNewRM returns an existing TxInfo for the same RM, if present. Null - * otherwise. - * - * @message com.arjuna.ats.internal.jta.transaction.arjunacore.newtmerror - * [com.arjuna.ats.internal.jta.transaction.arjunacore.newtmerror] - * {0} caught XAException: {0} - * @message com.arjuna.ats.internal.jta.transaction.arjunacore.isnewrm - * [com.arjuna.ats.internal.jta.transaction.arjunacore.isnewrm] - * Caught unexpected exception: {0} - */ - - private final TxInfo isNewRM(XAResource xaRes) - { - try - { - synchronized (this) - { - Enumeration el = _resources.keys(); - - if (el != null) - { - while (el.hasMoreElements()) - { - XAResource x = (XAResource) el.nextElement(); - - if (x.isSameRM(xaRes)) - { - return (TxInfo) _resources.get(x); - } - } - } - - el = _duplicateResources.keys(); - - if (el != null) - { - while (el.hasMoreElements()) - { - XAResource x = (XAResource) el.nextElement(); - - if (x.isSameRM(xaRes)) - { - return (TxInfo) _duplicateResources.get(x); - } - } - } - } - } - catch (XAException ex) - { - if (jtaLogger.loggerI18N.isWarnEnabled()) - { - jtaLogger.loggerI18N.warn("com.arjuna.ats.internal.jta.transaction.arjunacore.newtmerror", new Object[] - { "TransactionImple.isNewRM", XAHelper.printXAErrorCode(ex) }); - } - - throw new com.arjuna.ats.arjuna.exceptions.FatalError(ex.toString()); - } - catch (Exception e) - { - if (jtaLogger.loggerI18N.isWarnEnabled()) - { - jtaLogger.loggerI18N.warn("com.arjuna.ats.internal.jta.transaction.arjunacore.newtmerror", new Object[] - { e }); - } - - throw new com.arjuna.ats.arjuna.exceptions.FatalError(e.toString()); - } - - return null; - } - - private final Xid createXid(boolean branch, XAModifier theModifier) - { - Xid xid = baseXid(); - - if (xid != null) - return xid; - - xid = new XidImple(_theTransaction, branch); - - if (theModifier != null) - { - try - { - xid = theModifier.createXid((XidImple) xid); - } - catch (Exception e) - { - e.printStackTrace(); - } - } - - return xid; - } - - /* - * This method calls setRollbackOnly and catches any exceptions it may throw - * and issues a warning. We use this in places wherew we need to force the - * outcome of the transaction but already have an exception to throw back to - * the application, so a failure here will only be masked. - */ - - /** - * @message com.arjuna.ats.internal.jta.transaction.arjunacore.markrollback - * [com.arjuna.ats.internal.jta.transaction.arjunacore.markrollback] - * {0} - could not mark {0} as rollback only - */ - - private final void markRollbackOnly() - { - if (_theTransaction != null) - { - if (!_theTransaction.preventCommit()) - { - if (jtaLogger.loggerI18N.isWarnEnabled()) - { - jtaLogger.loggerI18N.warn("com.arjuna.ats.internal.jta.transaction.arjunacore.markrollback", new Object[] - { "TransactionImple.markRollbackOnly", _theTransaction }); - } - } - } - } - - /* - * Add and remove transactions from list. - */ - - static final protected void putTransaction(TransactionImple tx) - { - _transactions.put(tx.get_uid(), tx); - } - - static final protected void removeTransaction(TransactionImple tx) - { - _transactions.remove(tx.get_uid()); - } - - protected com.arjuna.ats.arjuna.AtomicAction _theTransaction; - - private Hashtable _resources; - private Hashtable _duplicateResources; - private int _suspendCount; - - private static Hashtable _transactions = new Hashtable(); - -} +/* + * JBoss, Home of Professional Open Source + * Copyright 2006, JBoss Inc., and others contributors as indicated + * by the @authors tag. All rights reserved. + * See the copyright.txt in the distribution for a + * full listing of individual contributors. + * This copyrighted material is made available to anyone wishing to use, + * modify, copy, or redistribute it subject to the terms and conditions + * of the GNU Lesser General Public License, v. 2.1. + * This program is distributed in the hope that it will be useful, but WITHOUT A + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + * You should have received a copy of the GNU Lesser General Public License, + * v.2.1 along with this distribution; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + * + * (C) 2005-2006, + * @author JBoss Inc. + */ +/* + * Copyright (C) 2002, + * + * Hewlett-Packard Arjuna Labs, + * Newcastle upon Tyne, + * Tyne and Wear, + * UK. + * + * $Id: TransactionImple.java 2342 2006-03-30 13:06:17Z kconner $ + */ + +package com.arjuna.ats.internal.jta.transaction.arjunacore; + +import com.arjuna.ats.internal.jta.xa.TxInfo; +import com.arjuna.ats.internal.jta.utils.*; +import com.arjuna.ats.internal.jta.utils.arjunacore.StatusConverter; +import com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple; +import com.arjuna.ats.internal.jta.resources.arjunacore.XAResourceRecord; + +import com.arjuna.ats.jta.utils.XAHelper; +import com.arjuna.ats.jta.xa.XidImple; +import com.arjuna.ats.jta.exceptions.InactiveTransactionException; +import com.arjuna.ats.jta.logging.*; +import com.arjuna.ats.jta.xa.XAModifier; + +import com.arjuna.ats.arjuna.coordinator.ActionStatus; +import com.arjuna.ats.arjuna.coordinator.BasicAction; +import com.arjuna.ats.arjuna.coordinator.AddOutcome; +import com.arjuna.ats.arjuna.common.*; + +import com.arjuna.common.util.logging.*; + +import javax.transaction.xa.*; + +import java.util.Hashtable; +import java.util.Enumeration; + +import javax.transaction.RollbackException; +import java.lang.IllegalStateException; + +/* + * Is given an AtomicAction, but uses the TwoPhaseCoordinator aspects of it + * to ensure that the thread association continues. + */ + +/** + * @message com.arjuna.ats.internal.jta.transaction.arjunacore.inactive + * [com.arjuna.ats.internal.jta.transaction.arjunacore.inactive] The + * transaction is not active! + * @message com.arjuna.ats.internal.jta.transaction.arjunacore.nullres + * [com.arjuna.ats.internal.jta.transaction.arjunacore.nullres] + * Resource paramater is null! + * @message com.arjuna.ats.internal.jta.transaction.arjunacore.illresstate + * [com.arjuna.ats.internal.jta.transaction.arjunacore.illresstate] + * illegal resource state + * @message com.arjuna.ats.internal.jta.transaction.arjunacore.notatomicaction + * [com.arjuna.ats.internal.jta.transaction.arjunacore.notatomicaction] + * Current transaction is not an AtomicAction! + */ + +public class TransactionImple implements javax.transaction.Transaction, + com.arjuna.ats.jta.transaction.Transaction +{ + + /* + * Only works with AtomicAction and TwoPhaseCoordinator. + */ + + /** + * Create a new transaction with the specified timeout. + */ + + public TransactionImple(int timeout) + { + _theTransaction = new AtomicAction(); + + _theTransaction.begin(timeout); + + _resources = new Hashtable(); + _duplicateResources = new Hashtable(); + _suspendCount = 0; + } + + /** + * Overloads Object.equals() + */ + + public boolean equals(Object obj) + { + if (jtaLogger.logger.isDebugEnabled()) + { + jtaLogger.logger.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC, com.arjuna.ats.jta.logging.FacilityCode.FAC_JTA, "TransactionImple.equals"); + } + + if (obj == null) + return false; + + if (obj == this) + return true; + + if (obj instanceof TransactionImple) + { + /* + * If we can't get either coordinator to compare, then assume + * transactions are different. + */ + + try + { + TransactionImple tx = (TransactionImple) obj; + + return tx.get_uid().equals(_theTransaction.get_uid()); + } + catch (Exception e) + { + } + } + + return false; + } + + /** + * Return -1 if we fail. + */ + + public int hashCode() + { + if (_theTransaction == null) + return -1; + else + return _theTransaction.get_uid().hashCode(); + } + + /** + * The JTA specification is vague on whether the calling thread can have any + * transaction associated with it. It does say that it need not have the + * same transaction as this one. We could call suspend prior to making these + * calls, but for now we do nothing. + */ + + /** + * We should never throw a HeuristicRollbackException because if we get a + * HeuristicRollback from a resource, and can successfully rollback the + * other resources, this is then the same as having simply been forced to + * rollback the transaction during phase 1. + * + * @message com.arjuna.ats.internal.jta.transaction.arjunacore.invalidstate + * [com.arjuna.ats.internal.jta.transaction.arjunacore.invalidstate] + * Invalid transaction state + */ + + public void commit() throws javax.transaction.RollbackException, + javax.transaction.HeuristicMixedException, + javax.transaction.HeuristicRollbackException, + java.lang.SecurityException, javax.transaction.SystemException, + java.lang.IllegalStateException + { + if (jtaLogger.logger.isDebugEnabled()) + { + jtaLogger.logger.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC, com.arjuna.ats.jta.logging.FacilityCode.FAC_JTA, "TransactionImple.commit"); + } + + if (_theTransaction != null) + { + switch (status = _theTransaction.status()) + { + case ActionStatus.RUNNING: + case ActionStatus.ABORT_ONLY: + break; + default: + throw new InactiveTransactionException( + jtaLogger.logMesg.getString("com.arjuna.ats.internal.jta.transaction.arjunacore.inactive")); + } + + /* + * Call end on any suspended resources. If this fails, then the + * transaction will be rolled back. + */ + + if (!endSuspendedRMs()) + _theTransaction.preventCommit(); + + // use end of TwoPhaseCoordinator to avoid thread changes. + + int status = _theTransaction.end(true); + + TransactionImple.removeTransaction(this); + + switch (status) + { + case ActionStatus.COMMITTED: + case ActionStatus.COMMITTING: // in case of async commit + break; + case ActionStatus.H_MIXED: + throw new javax.transaction.HeuristicMixedException(); + case ActionStatus.H_HAZARD: + throw new javax.transaction.HeuristicMixedException(); + case ActionStatus.H_ROLLBACK: + case ActionStatus.ABORTED: + throw new RollbackException(); + default: + throw new IllegalStateException( + jtaLogger.logMesg.getString("com.arjuna.ats.internal.jta.transaction.arjunacore.invalidstate")); + } + } + else + throw new IllegalStateException( + jtaLogger.logMesg.getString("com.arjuna.ats.internal.jta.transaction.arjunacore.inactive")); + } + + /** + * @message com.arjuna.ats.internal.jta.transaction.arjunacore.rollbackstatus + * [com.arjuna.ats.internal.jta.transaction.arjunacore.rollbackstatus] + * Transaction rollback status is: + * @message com.arjuna.ats.internal.jta.transaction.arjunacore.endsuspendfailed1 + * [com.arjuna.ats.internal.jta.transaction.arjunacore.endsuspendfailed1] + * Ending suspended RMs failed when rolling back the transaction! + * @message com.arjuna.ats.internal.jta.transaction.arjunacore.endsuspendfailed2 + * [com.arjuna.ats.internal.jta.transaction.arjunacore.endsuspendfailed2] + * Ending suspended RMs failed when rolling back the transaction, + * but transaction rolled back. + */ + + public void rollback() throws java.lang.IllegalStateException, + java.lang.SecurityException, javax.transaction.SystemException + { + if (jtaLogger.logger.isDebugEnabled()) + { + jtaLogger.logger.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC, com.arjuna.ats.jta.logging.FacilityCode.FAC_JTA, "TransactionImple.rollback"); + } + + if (_theTransaction != null) + { + switch (_theTransaction.status()) + { + case ActionStatus.RUNNING: + case ActionStatus.ABORT_ONLY: + break; + default: + throw new InactiveTransactionException( + jtaLogger.logMesg.getString("com.arjuna.ats.internal.jta.transaction.arjunacore.inactive")); + } + + /* + * Call end on any suspended resources. If this fails, then there's + * not a lot else we can do because the transaction is about to roll + * back anyway! + */ + + boolean endSuspendedFailed = !endSuspendedRMs(); + + if (endSuspendedFailed) + { + if (jtaLogger.loggerI18N.isWarnEnabled()) + { + jtaLogger.loggerI18N.warn("com.arjuna.ats.internal.jta.transaction.arjunacore.endsuspendfailed1"); + } + } + + int outcome = _theTransaction.cancel(); // use cancel of + // TwoPhaseCoordinator to + // avoid thread changes. + + TransactionImple.removeTransaction(this); + + switch (outcome) + { + case ActionStatus.ABORTED: + case ActionStatus.ABORTING: // in case of async rollback + break; + default: + throw new IllegalStateException( + jtaLogger.logMesg.getString("com.arjuna.ats.internal.jta.transaction.arjunacore.rollbackstatus") + + ActionStatus.stringForm(outcome)); + } + + if (endSuspendedFailed) + throw new IllegalStateException( + jtaLogger.logMesg.getString("com.arjuna.ats.internal.jta.transaction.arjunacore.endsuspendfailed2")); + } + else + throw new IllegalStateException( + jtaLogger.logMesg.getString("com.arjuna.ats.internal.jta.transaction.arjunacore.inactive")); + } + + public void setRollbackOnly() throws java.lang.IllegalStateException, + javax.transaction.SystemException + { + if (jtaLogger.logger.isDebugEnabled()) + { + jtaLogger.logger.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC, com.arjuna.ats.jta.logging.FacilityCode.FAC_JTA, "TransactionImple.setRollbackOnly"); + } + + if (_theTransaction != null) + { + if (!_theTransaction.preventCommit()) + throw new IllegalStateException( + jtaLogger.logMesg.getString("com.arjuna.ats.internal.jta.transaction.arjunacore.inactive")); + } + else + throw new IllegalStateException( + jtaLogger.logMesg.getString("com.arjuna.ats.internal.jta.transaction.arjunacore.inactive")); + } + + public int getStatus () throws javax.transaction.SystemException + { + if (jtaLogger.logger.isDebugEnabled()) + { + jtaLogger.logger.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC, com.arjuna.ats.jta.logging.FacilityCode.FAC_JTA, "TransactionImple.getStatus"); + } + + int status = javax.transaction.Status.STATUS_NO_TRANSACTION; + + if (_theTransaction != null) + { + return StatusConverter.convert(_theTransaction.status()); + } + + return status; + } + + /** + * @message com.arjuna.ats.internal.jta.transaction.arjunacore.nullparam + * [com.arjuna.ats.internal.jta.transaction.arjunacore.nullparam] + * null synchronization parameter! + * @message com.arjuna.ats.internal.jta.transaction.arjunacore.syncsnotallowed + * [com.arjuna.ats.internal.jta.transaction.arjunacore.syncsnotallowed] + * Synchronizations are not allowed! + */ + + public void registerSynchronization(javax.transaction.Synchronization sync) + throws javax.transaction.RollbackException, + java.lang.IllegalStateException, javax.transaction.SystemException + { + if (jtaLogger.logger.isDebugEnabled()) + { + jtaLogger.logger.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC, com.arjuna.ats.jta.logging.FacilityCode.FAC_JTA, "TransactionImple.registerSynchronization"); + } + + if (sync == null) + throw new javax.transaction.SystemException( + "TransactionImple.registerSynchronization - " + + jtaLogger.logMesg.getString("com.arjuna.ats.internal.jta.transaction.arjunacore.nullparam")); + + if (_theTransaction != null) + { + SynchronizationImple s = new SynchronizationImple(sync); + + if (_theTransaction.addSynchronization(s) != AddOutcome.AR_ADDED) + { + int status = _theTransaction.status(); + + switch (status) + { + case ActionStatus.ABORTED: + throw new javax.transaction.RollbackException(); + case ActionStatus.CREATED: + throw new IllegalStateException( + jtaLogger.logMesg.getString("com.arjuna.ats.internal.jta.transaction.arjunacore.inactive")); + default: + throw new IllegalStateException( + jtaLogger.logMesg.getString("com.arjuna.ats.internal.jta.transaction.arjunacore.syncsnotallowed")); + } + } + } + else + throw new IllegalStateException( + jtaLogger.logMesg.getString("com.arjuna.ats.internal.jta.transaction.arjunacore.inactive")); + } + + /** + * This is the JTA compliant version of the method. However, you had better + * know that your XAResource and family are truly compliant implementations. + * If they aren't then we may fail gracefully (e.g., some versions of Oracle + * don't work with arbitrary Xid implementations!) + * + * If the family isn't compliant, then you should use the other method and + * pass through a relevant XAModifier, which should address the issues we + * have already come across. + */ + + public boolean enlistResource(XAResource xaRes) throws RollbackException, + IllegalStateException, javax.transaction.SystemException + { + return enlistResource(xaRes, null); + } + + /** + * @message com.arjuna.ats.internal.jta.transaction.arjunacore.enlisterror + * [com.arjuna.ats.internal.jta.transaction.arjunacore.enlisterror] + * {0} - caught: {1} + * @message com.arjuna.ats.internal.jta.transaction.arjunacore.timeouterror[com.arjuna.ats.internal.jta.transaction.arjunacore.timeouterror] + * {0} setTransactionTimeout caught: {1} + * @message com.arjuna.ats.internal.jta.transaction.arjunacore.enliststarterror + * [com.arjuna.ats.internal.jta.transaction.arjunacore.enliststarterror] + * {0} - XAResource.start returned: {1} for {2} + * @message com.arjuna.ats.internal.jta.transaction.arjunacore.couldnotregister + * [com.arjuna.ats.internal.jta.transaction.arjunacore.couldnotregister] + * could not register transaction + * @message com.arjuna.ats.internal.jta.transaction.arjunacore.xastart + * [com.arjuna.ats.internal.jta.transaction.arjunacore.xastart] {0} - + * caught: {1} for {2} + */ + + public boolean enlistResource(XAResource xaRes, Object[] params) + throws RollbackException, IllegalStateException, + javax.transaction.SystemException + { + if (jtaLogger.logger.isDebugEnabled()) + { + jtaLogger.logger.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC, com.arjuna.ats.jta.logging.FacilityCode.FAC_JTA, "TransactionImple.enlistResource ( " + + xaRes + " )"); + } + + if (xaRes == null) + throw new javax.transaction.SystemException( + "TransactionImple.enlistResource - " + + jtaLogger.logMesg.getString("com.arjuna.ats.internal.jta.transaction.arjunacore.nullres")); + + int status = getStatus(); + + switch (status) + { + case javax.transaction.Status.STATUS_MARKED_ROLLBACK: + throw new RollbackException(); + case javax.transaction.Status.STATUS_ACTIVE: + break; + default: + throw new IllegalStateException( + jtaLogger.logMesg.getString("com.arjuna.ats.internal.jta.transaction.arjunacore.inactive")); + } + + XAModifier theModifier = null; + + if (params != null) + { + if (params.length >= XAMODIFIER + 1) + { + if (params[XAMODIFIER] instanceof XAModifier) + { + theModifier = (XAModifier) params[XAMODIFIER]; + } + } + } + + try + { + /* + * For each transaction we maintain a list of resources registered + * with it. Each element on this list also contains a list of + * threads which have registered this resource, and what their XID + * was for that registration. + */ + + TxInfo info = null; + + /* + * Have we seen this specific resource instance before? Do this + * trawl first before checking the RM instance later. Saves time. + */ + + try + { + synchronized (this) + { + info = (TxInfo) _resources.get(xaRes); + + if (info == null) + { + /* + * Null info means it's not in the main resources list, + * but may be in the duplicates. + */ + + info = (TxInfo) _du... [truncated message content] |
From: <jbo...@li...> - 2006-05-04 07:38:12
|
Author: mla...@jb... Date: 2006-05-04 03:38:05 -0400 (Thu, 04 May 2006) New Revision: 4081 Added: labs/jbossweb/trunk/src/share/native/php5servlet/NMAKEmakefile Removed: labs/jbossweb/trunk/src/share/native/php5servlet/php5servlet.dsp labs/jbossweb/trunk/src/share/native/php5servlet/php5servlet.dsw Modified: labs/jbossweb/trunk/src/share/native/php5servlet/php5servlet.c Log: Use common makefile system. Added: labs/jbossweb/trunk/src/share/native/php5servlet/NMAKEmakefile =================================================================== --- labs/jbossweb/trunk/src/share/native/php5servlet/NMAKEmakefile 2006-05-04 05:26:22 UTC (rev 4080) +++ labs/jbossweb/trunk/src/share/native/php5servlet/NMAKEmakefile 2006-05-04 07:38:05 UTC (rev 4081) @@ -0,0 +1,87 @@ +# Copyright 2001-2005 The Apache Software Foundation or its licensors, as +# applicable. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ==================================================================== +# +# NMAKEmakefile Master PHP5 Servlet SAPI makefile. +# Usage: +# DEBUG=1 Build DEBUG version of TCN +# +# Originally contributed by Mladen Turk <mturk jboss.com> +# +# ==================================================================== +# + +TARGET = DLL +BUILDIR_EXT = DLL +PROJECT = php5servlet +PHP5_LIB = php5ts.lib + +!include <../build/NMAKEcommon.inc> + +CFLAGS = $(CFLAGS) -DPHP5SERVLET_EXPORTS -DZTS -DZEND_WIN32 -DPHP_WIN32 + +!IFDEF DEBUG +CFLAGS = $(CFLAGS) -DZEND_DEBUG=1 +!ELSE +CFLAGS = $(CFLAGS) -DZEND_DEBUG=0 +!ENDIF + +!IF !DEFINED(SRCDIR) || "$(SRCDIR)" == "" +SRCDIR = . +!ENDIF + +INCLUDES = -I$(SRCDIR)/include $(JAVA_INCLUDES) + +!IFNDEF WITH_PHP5 +WITH_PHP5 = ../srclib/php +!ENDIF + +INCLUDES = $(INCLUDES) -I$(WITH_PHP5)/include/php -I$(WITH_PHP5)/include/php/win32 \ + -I$(WITH_PHP5)/include/php/Zend -I$(WITH_PHP5)/include/php/main -I$(WITH_PHP5)/include/php/TSRM + +LDIRS = /libpath:"$(WITH_PHP5)/dev" +LFLAGS = $(LFLAGS) $(PHP5_LIB) +LFLAGS = $(LFLAGS) user32.lib + +PDBFLAGS = -Fo$(BUILDIR)\ -Fd$(BUILDIR)\$(PROJECT)-src +OBJECTS = \ + $(BUILDIR)\php5servlet.obj + +BUILDLIB = $(BUILDIR)\$(PROJECT).dll +BUILDPDB = $(BUILDIR)\$(PROJECT).pdb +BUILDRES = $(BUILDIR)\$(PROJECT).res +BUILDMAN = $(BUILDLIB).manifest + +all : $(BUILDIR) $(BUILDLIB) + +$(BUILDIR) : + @$(MAKETARGET) + +{$(SRCDIR)}.c{$(BUILDIR)}.obj: + $(CC) $(CFLAGS) $(INCLUDES) $(PDBFLAGS) $< + +$(OBJECTS): $(SRCDIR)/*.c + +$(BUILDRES): $(SRCDIR)/php5servlet.rc + $(RC) $(RCFLAGS) /fo $(BUILDRES) $(SRCDIR)/php5servlet.rc + +$(BUILDLIB): $(BUILDIR) $(OBJECTS) $(BUILDRES) + $(LINK) $(LFLAGS) $(OBJECTS) $(BUILDRES) $(LIBS) $(LDIRS) /pdb:$(BUILDPDB) /out:$(BUILDLIB) + IF EXIST $(BUILDMAN) \ + mt -nologo -manifest $(BUILDMAN) -outputresource:$(BUILDLIB);2 + +clean: + @$(CLEANTARGET) Modified: labs/jbossweb/trunk/src/share/native/php5servlet/php5servlet.c =================================================================== --- labs/jbossweb/trunk/src/share/native/php5servlet/php5servlet.c 2006-05-04 05:26:22 UTC (rev 4080) +++ labs/jbossweb/trunk/src/share/native/php5servlet/php5servlet.c 2006-05-04 07:38:05 UTC (rev 4081) @@ -5,6 +5,16 @@ * See terms of license at gnu.org. */ +/* Ignore Microsoft's interpretation of secure development + * and the POSIX string handling API + */ +#if defined(_MSC_VER) && _MSC_VER >= 1400 +#ifndef _CRT_SECURE_NO_DEPRECATE +#define _CRT_SECURE_NO_DEPRECATE +#endif +#pragma warning(disable: 4996) +#endif + #include "php.h" #include "php_main.h" #include "SAPI.h" Deleted: labs/jbossweb/trunk/src/share/native/php5servlet/php5servlet.dsp =================================================================== --- labs/jbossweb/trunk/src/share/native/php5servlet/php5servlet.dsp 2006-05-04 05:26:22 UTC (rev 4080) +++ labs/jbossweb/trunk/src/share/native/php5servlet/php5servlet.dsp 2006-05-04 07:38:05 UTC (rev 4081) @@ -1,103 +0,0 @@ -# Microsoft Developer Studio Project File - Name="php5servlet" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=php5servlet - Win32 Debug_TS -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "php5servlet.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "php5servlet.mak" CFG="php5servlet - Win32 Debug_TS" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "php5servlet - Win32 Debug_TS" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "php5servlet - Win32 Release_TS" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "php5servlet - Win32 Debug_TS" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug_TS" -# PROP BASE Intermediate_Dir "Debug_TS" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug_TS" -# PROP Intermediate_Dir "Debug_TS" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PHP5SERVLET_EXPORTS" /YX /FD /GZ /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\include\php" /I "..\include\php\win32" /I "..\include\php\Zend" /I "..\include\php\main" /I "..\include\php\TSRM" /I "$(JAVA_HOME)\include" /I "$(JAVA_HOME)\include\win32" /D "_DEBUG" /D "COMPILE_LIBZEND" /D ZEND_DEBUG=1 /D "_WINDOWS" /D "_USRDLL" /D "PHP5SERVLET_EXPORTS" /D "MSVC5" /D "ZTS" /D "ZEND_WIN32" /D "PHP_WIN32" /D "WIN32" /D "_MBCS" /FR /YX /FD /GZ /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x40d /d "_DEBUG" -# ADD RSC /l 0x40d /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib php5ts.lib /nologo /version:4.0 /dll /debug /machine:I386 /nodefaultlib:"libcmt" /out:"Debug_TS/php5module.dll" /pdbtype:sept /libpath:"..\dev" - -!ELSEIF "$(CFG)" == "php5servlet - Win32 Release_TS" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release_TS" -# PROP BASE Intermediate_Dir "Release_TS" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release_TS" -# PROP Intermediate_Dir "Release_TS" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PHP5SERVLET_EXPORTS" /YX /FD /c -# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\include\php" /I "..\include\php\win32" /I "..\include\php\Zend" /I "..\include\php\main" /I "..\include\php\TSRM" /I "$(JAVA_HOME)\include" /I "$(JAVA_HOME)\include\win32" /D "NDEBUG" /D ZEND_DEBUG=0 /D "_WINDOWS" /D "_USRDLL" /D "PHP5SERVLET_EXPORTS" /D "MSVC5" /D "ZTS" /D "ZEND_WIN32" /D "PHP_WIN32" /D "WIN32" /D "_MBCS" /FR /YX /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x40d /d "NDEBUG" -# ADD RSC /l 0x40d /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib wsock32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib php5ts.lib /nologo /version:4.0 /dll /machine:I386 /out:"..\php5servlet.dll" /libpath:"..\dev" - -!ENDIF - -# Begin Target - -# Name "php5servlet - Win32 Debug_TS" -# Name "php5servlet - Win32 Release_TS" -# Begin Group "Source Files" - -# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" -# Begin Source File - -SOURCE=.\php5servlet.c -# End Source File -# End Group -# Begin Group "Header Files" - -# PROP Default_Filter "h;hpp;hxx;hm;inl" -# End Group -# End Target -# End Project Deleted: labs/jbossweb/trunk/src/share/native/php5servlet/php5servlet.dsw =================================================================== --- labs/jbossweb/trunk/src/share/native/php5servlet/php5servlet.dsw 2006-05-04 05:26:22 UTC (rev 4080) +++ labs/jbossweb/trunk/src/share/native/php5servlet/php5servlet.dsw 2006-05-04 07:38:05 UTC (rev 4081) @@ -1,29 +0,0 @@ -Microsoft Developer Studio Workspace File, Format Version 6.00 -# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! - -############################################################################### - -Project: "php5servlet"=".\php5servlet.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - |
From: <jbo...@li...> - 2006-05-04 05:26:27
|
Author: mic...@jb... Date: 2006-05-04 01:26:22 -0400 (Thu, 04 May 2006) New Revision: 4080 Modified: labs/jbossrules/trunk/documentation/manual/en/Chapter-Install/Section-Install.xml Log: Modified: labs/jbossrules/trunk/documentation/manual/en/Chapter-Install/Section-Install.xml =================================================================== --- labs/jbossrules/trunk/documentation/manual/en/Chapter-Install/Section-Install.xml 2006-05-04 04:19:50 UTC (rev 4079) +++ labs/jbossrules/trunk/documentation/manual/en/Chapter-Install/Section-Install.xml 2006-05-04 05:26:22 UTC (rev 4080) @@ -127,7 +127,7 @@ Also, if you have previously installed the plug in manually, you will need to manually remove it from your plug in directory.</para> - <para>Step 1. Use the eclipse help menu to fine the feature installer. + <para>Step 1. Use the eclipse help menu to find the feature installer. <screenshot> <screeninfo>Access the software updates menu</screeninfo> |
From: <jbo...@li...> - 2006-05-04 04:20:06
|
Author: mic...@jb... Date: 2006-05-04 00:19:50 -0400 (Thu, 04 May 2006) New Revision: 4079 Added: labs/jbossrules/trunk/drools-decisiontables/src/test/resources/data/TeamAllocationExample_TYPICAL_EXAMPLE.xls Log: from drools 2.5 Added: labs/jbossrules/trunk/drools-decisiontables/src/test/resources/data/TeamAllocationExample_TYPICAL_EXAMPLE.xls =================================================================== (Binary files differ) Property changes on: labs/jbossrules/trunk/drools-decisiontables/src/test/resources/data/TeamAllocationExample_TYPICAL_EXAMPLE.xls ___________________________________________________________________ Name: svn:mime-type + application/octet-stream |
From: <jbo...@li...> - 2006-05-04 01:57:43
|
Author: mar...@jb... Date: 2006-05-03 21:57:37 -0400 (Wed, 03 May 2006) New Revision: 4078 Added: labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/integrationtests/test_EmptyRule.drl labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/integrationtests/test_NoColumns.drl Modified: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/IntegrationCases.java Log: JBRULES-253 Allow rules with no columns Modified: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/IntegrationCases.java =================================================================== --- labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/IntegrationCases.java 2006-05-04 01:57:33 UTC (rev 4077) +++ labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/IntegrationCases.java 2006-05-04 01:57:37 UTC (rev 4078) @@ -1737,6 +1737,42 @@ assertEquals("Rules have not fired (looped) expected number of times", 10, l.size()); } + public void testEmptyRule() throws Exception { + PackageBuilder builder = new PackageBuilder(); + builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_EmptyRule.drl" ) ) ); + Package pkg = builder.getPackage(); + + RuleBase ruleBase = getRuleBase(); + ruleBase.addPackage( pkg ); + WorkingMemory workingMemory = ruleBase.newWorkingMemory(); + + List list = new ArrayList(); + workingMemory.setGlobal( "list", list ); + + workingMemory.fireAllRules(); + + assertTrue( list.contains("fired1") ); + assertTrue( list.contains("fired2") ); + } + + public void testjustEval() throws Exception { + PackageBuilder builder = new PackageBuilder(); + builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_NoColumns.drl" ) ) ); + Package pkg = builder.getPackage(); + + RuleBase ruleBase = getRuleBase(); + ruleBase.addPackage( pkg ); + WorkingMemory workingMemory = ruleBase.newWorkingMemory(); + + List list = new ArrayList(); + workingMemory.setGlobal( "list", list ); + + workingMemory.fireAllRules(); + + assertTrue( list.contains("fired1") ); + assertTrue( list.contains("fired3") ); + } + private Object serializeIn(byte[] bytes) throws IOException, ClassNotFoundException { ObjectInput in = new ObjectInputStream( new ByteArrayInputStream( bytes ) ); Added: labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/integrationtests/test_EmptyRule.drl =================================================================== --- labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/integrationtests/test_EmptyRule.drl 2006-05-04 01:57:33 UTC (rev 4077) +++ labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/integrationtests/test_EmptyRule.drl 2006-05-04 01:57:37 UTC (rev 4078) @@ -0,0 +1,16 @@ +package org.drools.test + +global java.util.List list + +rule "empty lhs1" + when + then + list.add("fired1"); +end + +rule "empty lhs2" + when + then + list.add("fired2"); +end + Added: labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/integrationtests/test_NoColumns.drl =================================================================== --- labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/integrationtests/test_NoColumns.drl 2006-05-04 01:57:33 UTC (rev 4077) +++ labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/integrationtests/test_NoColumns.drl 2006-05-04 01:57:37 UTC (rev 4078) @@ -0,0 +1,35 @@ +package org.drools.test + +global java.util.List list + +rule "no columns1" + when + eval(true); + then + list.add("fired1"); +end + +rule "no columns2" + when + eval(false); + then + list.add("fired2"); +end + +rule "no columns3" + when + eval(true); + eval(1==1); + then + list.add("fired3"); +end + + +rule "no columns4" + when + eval(false); + eval(true); + eval(1==1); + then + list.add("fired4"); +end \ No newline at end of file |
From: <jbo...@li...> - 2006-05-04 01:57:38
|
Author: mar...@jb... Date: 2006-05-03 21:57:33 -0400 (Wed, 03 May 2006) New Revision: 4077 Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ReteooBuilder.java Log: JBRULES-253 Allow rules with no columns Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ReteooBuilder.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ReteooBuilder.java 2006-05-03 23:08:16 UTC (rev 4076) +++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ReteooBuilder.java 2006-05-04 01:57:33 UTC (rev 4077) @@ -35,6 +35,7 @@ import org.drools.common.InstanceEqualsConstraint; import org.drools.rule.And; import org.drools.rule.Column; +import org.drools.rule.ConditionalElement; import org.drools.rule.Declaration; import org.drools.rule.EvalCondition; import org.drools.rule.Exists; @@ -66,31 +67,31 @@ // ------------------------------------------------------------ /** The RuleBase */ - private transient RuleBaseImpl ruleBase; + private transient RuleBaseImpl ruleBase; /** Rete network to build against. */ - private transient Rete rete; + private transient Rete rete; - private transient WorkingMemoryImpl[] workingMemories; + private transient WorkingMemoryImpl[] workingMemories; - private final ObjectTypeResolver resolver; + private final ObjectTypeResolver resolver; /** Nodes that have been attached. */ - private final Map attachedNodes; + private final Map attachedNodes; - private TupleSource tupleSource; + private TupleSource tupleSource; - private ObjectSource objectSource; + private ObjectSource objectSource; - private Map declarations; + private Map declarations; - private int id; + private int id; - private Map rules; + private Map rules; - private Map objectType; + private Map objectType; - private int currentOffsetAdjustment; + private int currentOffsetAdjustment; // ------------------------------------------------------------ // Constructors @@ -111,7 +112,7 @@ //Set to 1 as Rete node is set to 0 this.id = 1; } - + /** * Allow this to be settable, otherwise we get infinite recursion on serialisation * @param ruleBase @@ -119,13 +120,13 @@ void setRuleBase(RuleBaseImpl ruleBase) { this.ruleBase = ruleBase; } - + /** * Allow this to be settable, otherwise we get infinite recursion on serialisation * @param ruleBase - */ + */ void setRete(Rete rete) { - + } // ------------------------------------------------------------ @@ -150,7 +151,12 @@ List nodes = new ArrayList(); And[] and = rule.getTransformedLhs(); + for ( int i = 0; i < and.length; i++ ) { + if ( !hasColumns( and[i] ) ) { + addInitialFactMatch( and[i] ); + } + addRule( and[i], rule ); BaseNode node = null; @@ -185,6 +191,34 @@ (BaseNode[]) nodes.toArray( new BaseNode[nodes.size()] ) ); } + private boolean hasColumns(GroupElement ge) { + for ( Iterator it = ge.getChildren().iterator(); it.hasNext(); ) { + Object object = it.next(); + if ( object instanceof Column || (object instanceof GroupElement && hasColumns( (GroupElement) object )) ) { + return true; + } + } + return false; + } + + private void addInitialFactMatch(And and) { + And temp = null; + + // If we have children we know there are no columns but we need to make sure that InitialFact is first + if ( !and.getChildren().isEmpty() ) { + temp = (And) and.clone(); + and.getChildren().clear(); + } + Column column = new Column( 0, + new ClassObjectType( InitialFact.class ) ); + and.addChild( column ); + + // now we know InitialFact is first add all the previous constrains + if ( temp != null ) { + and.getChildren().addAll( temp.getChildren() ); + } + } + private void addRule(And and, Rule rule) throws InvalidPatternException { this.objectSource = null; |
From: <jbo...@li...> - 2006-05-03 22:49:35
|
Author: mar...@jb... Date: 2006-05-03 18:49:30 -0400 (Wed, 03 May 2006) New Revision: 4075 Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/EvalConditionNode.java Log: JBRULES-237 Eval throws exception on modify -Check that LinkedTuples is not just null, but that its also empty. Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/EvalConditionNode.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/EvalConditionNode.java 2006-05-03 22:14:34 UTC (rev 4074) +++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/EvalConditionNode.java 2006-05-03 22:49:30 UTC (rev 4075) @@ -145,7 +145,7 @@ LinkedList memory = (LinkedList) workingMemory.getNodeMemory( this ); // checks if the tuple is attach to tuple - if ( tuple.getLinkedTuples() != null ) { + if (tuple.getLinkedTuples() != null && !tuple.getLinkedTuples().isEmpty()) { memory.remove( tuple ); propagateRetractTuple( tuple, @@ -158,7 +158,7 @@ PropagationContext context, WorkingMemoryImpl workingMemory) { LinkedList memory = (LinkedList) workingMemory.getNodeMemory( this ); - boolean exists = (tuple.getLinkedTuples() != null); + boolean exists = (tuple.getLinkedTuples() != null && !tuple.getLinkedTuples().isEmpty()); if ( exists ) { // Remove the tuple so it can be readded to the top of the list |