1 package com
.interrupt
.bookkeeping
.http
;
3 import javax
.servlet
.ServletException
;
4 import javax
.servlet
.SingleThreadModel
;
5 import javax
.servlet
.http
.HttpServlet
;
6 import javax
.servlet
.http
.HttpServletRequest
;
7 import javax
.servlet
.http
.HttpServletResponse
;
9 import org
.apache
.log4j
.Logger
;
10 import org
.exist
.EXistException
;
11 import org
.exist
.storage
.BrokerPool
;
12 import org
.exist
.util
.Configuration
;
13 import org
.exist
.util
.DatabaseConfigurationException
;
16 import java
.io
.FileReader
;
17 import java
.io
.BufferedReader
;
18 import java
.io
.PrintWriter
;
19 import java
.io
.IOException
;
20 import java
.util
.List
;
23 import java
.util
.Iterator
;
25 import com
.interrupt
.bob
.base
.Bob
;
26 import com
.interrupt
.bob
.base
.IBob
;
27 import com
.interrupt
.bookkeeping
.ISystem
;
28 import com
.interrupt
.bookkeeping
.account
.IAccount
;
29 import com
.interrupt
.bookkeeping
.account
.IAccounts
;
30 import com
.interrupt
.bookkeeping
.cc
.ExpressionVisitor
;
31 import com
.interrupt
.bookkeeping
.cc
.ReplaceVisitor
;
32 import com
.interrupt
.bookkeeping
.cc
.analysis
.DepthFirstAdapter
;
33 import com
.interrupt
.bookkeeping
.cc
.bkell
.Bkell
;
34 import com
.interrupt
.bookkeeping
.cc
.bkell
.aauth
.Aauthentication
;
35 import com
.interrupt
.bookkeeping
.cc
.bkell
.command
.AddCommand
;
36 import com
.interrupt
.bookkeeping
.cc
.bkell
.command
.GOption
;
37 import com
.interrupt
.bookkeeping
.cc
.bkell
.command
.GOptions
;
38 import com
.interrupt
.bookkeeping
.cc
.bkell
.command
.GResult
;
39 import com
.interrupt
.bookkeeping
.cc
.bkell
.command
.GToken
;
40 import com
.interrupt
.bookkeeping
.cc
.bkell
.command
.ICommand
;
41 import com
.interrupt
.bookkeeping
.cc
.bkell
.command
.IResult
;
42 import com
.interrupt
.bookkeeping
.cc
.bkell
.command
.ITokens
;
43 import com
.interrupt
.bookkeeping
.cc
.bkell
.command
.ListCommand
;
44 import com
.interrupt
.bookkeeping
.cc
.bkell
.command
.RemoveCommand
;
45 import com
.interrupt
.bookkeeping
.http
.BookkeepingSystemFacade
;
46 import com
.interrupt
.bookkeeping
.http
.ServletInputParams
;
47 import com
.interrupt
.bookkeeping
.journal
.IEntries
;
48 import com
.interrupt
.bookkeeping
.journal
.IEntry
;
49 import com
.interrupt
.bookkeeping
.journal
.IJournal
;
50 import com
.interrupt
.bookkeeping
.journal
.IJournals
;
51 import com
.interrupt
.bookkeeping
.system
.BookkeepingSystem
;
52 import com
.interrupt
.bookkeeping
.users
.IUserSession
;
53 import com
.interrupt
.bookkeeping
.users
.UserSession
;
54 import com
.interrupt
.util
.IdGenerator
;
57 public class BookkeepingServlet
extends HttpServlet
{
60 private Logger logger
= Logger
.getLogger(BookkeepingServlet
.class);
64 * Initialise the bookkeeping system
66 public void init() throws ServletException
{
69 //** initialising the servlet
70 String valueDBUrl
= getServletConfig().getInitParameter("db.url");
71 String valueExistInit
= getServletConfig().getInitParameter("exist.initdb");
72 String valueExistHome
= getServletConfig().getInitParameter("exist.home");
73 String valueSaxValidation
= getServletConfig().getInitParameter("org.xml.sax.features.validation");
74 String valueEndorsedDirs
= getServletConfig().getInitParameter("java.endorsed.dirs");
75 String valueConfFile
= getServletConfig().getInitParameter("configuration");
78 logger
.debug("db.url > "+ valueDBUrl
);
79 logger
.debug("exist.initdb > "+ valueExistInit
);
80 logger
.debug("exist.home > "+ valueExistHome
);
81 logger
.debug("org.xml.sax.features.validation > "+ valueSaxValidation
);
82 logger
.debug("java.endorsed.dirs > "+ valueEndorsedDirs
);
84 if(valueDBUrl
!= null)
85 System
.getProperties().setProperty("db.url", valueDBUrl
);
87 if(valueExistInit
!= null)
88 System
.getProperties().setProperty("exist.initdb", valueExistInit
);
90 if(valueExistHome
!= null)
91 System
.getProperties().setProperty("exist.home", valueExistHome
);
93 if(valueSaxValidation
!= null)
94 System
.getProperties().setProperty("org.xml.sax.features.validation", valueSaxValidation
);
96 if(valueEndorsedDirs
!= null)
97 System
.getProperties().setProperty("java.endorsed.dirs", valueEndorsedDirs
);
102 public void doGet(HttpServletRequest req
, HttpServletResponse resp
)
103 throws ServletException
, IOException
{
105 logger
.debug( "doGet CALLED >>> " );
108 public void doPost(HttpServletRequest req
, HttpServletResponse resp
)
109 throws ServletException
, IOException
{
111 logger
.debug( "doPost CALLED >>> " );
112 //ServletInputParams siparams = new ServletInputParams();
113 //siparams.req = req;
114 //siparams.res = resp;
118 if(req
.getSession(false) == null) {
120 logger
.debug( "CREATING a new session" );
122 BookkeepingSystemFacade bsfacade
=
123 (BookkeepingSystemFacade
)(req
.getSession(true).getAttribute(BookkeepingSystemFacade
.FACADE_NAME
));
124 if(bsfacade
== null) {
126 logger
.debug( "CREATING a new bsfacade" );
127 bsfacade
= new BookkeepingSystemFacade();
128 bsfacade
.initialise();
131 bsfacade
.perform(req
, resp
);
132 String xmlResult
= null;
134 xmlResult
= bsfacade
.getBkell().getPreviousCommandResult().toXML(false);
136 catch(NullPointerException e
) {
138 logger
.error("BookkeepingServlet.doPost > NullPointerException while referencing 'bkell.getPreviousCommandResult()' > ERROR while processing");
139 return; //** there must be an error if there's an empty previous command
142 logger
.debug( "END BookkeepingServlet RESULT: " + xmlResult
);
144 req
.getSession().setAttribute(BookkeepingSystemFacade
.FACADE_NAME
, bsfacade
);
147 catch(InterruptedException e
) {
148 throw new ServletException(e
);