corinis
Class Core

java.lang.Object
  extended by corinis.Core

public class Core
extends java.lang.Object

Core initialises and provides core functionality


Field Summary
static int ADMINGROUP
           
static int ADMINUSER
           
static int ALLGROUP
           
static int CMSEDITGROUP
           
static int CMSQMGROUP
           
static int FORUMMODERATOR
           
static int GUESTGROUP
           
static int GUESTUSER
           
 corinis.modules.core.UserRightCacher rights
           
 
Constructor Summary
Core(java.lang.ClassLoader cl, javax.servlet.jsp.PageContext pcontext)
           
Core(javax.servlet.http.HttpServletRequest srequest, javax.servlet.http.HttpServletResponse sresponse, javax.servlet.ServletContext scontext)
           
Core(javax.servlet.jsp.PageContext pcontext)
           
Core(java.lang.String locationPath, java.lang.String appName, javax.servlet.http.HttpServletRequest srequest, javax.servlet.http.HttpServletResponse sresponse, javax.servlet.ServletContext scontext)
          Inits the core class providing user and session managment also puts some stuff into the servlet context for faster use.
 
Method Summary
 void activateMe(java.lang.String name, java.lang.String id)
          activate the user
 void addDom(org.w3c.dom.Node tree)
          Adds a domtree from any function to the current one in the core module for later processing.
 boolean checkAuthority(java.lang.String authCode)
          Checks if a user has a authority
 boolean checkAuthority(java.lang.String authCode, corinis.modules.abstracts.Module mod)
          Checks if a user has a authority
 java.lang.String encryptString(java.lang.String s)
          Ecrypt Strings for password checking
 void fakeGuest()
          Call this function fakes the current user as guest until called again.
 java.lang.String getApp()
          Get the application name
 java.lang.String getAuthorityGroupByID(long id)
           
 corinis.modules.cache.Cache getCache()
           
 corinis.modules.core.CorinisContext getConfigurator()
          Used to retrieve the core Context out of the Servlet Context
 dbConnectionBroker getConnectionPool()
          Get the connection pool
 java.util.Hashtable getContextHashtable()
           
 org.w3c.dom.Node getCoreTree()
          Generates a core tree segment, with ip, username, userid, url
 corinis.modules.interfaces.IDataStore getDataStore(java.lang.Class dsClass)
           
 org.w3c.dom.Document getDoc()
           
 javax.xml.parsers.DocumentBuilder getDocumentBuilder()
          A helper function that Returns the cached DocumentBuilder object from the core Context
 org.w3c.dom.Element getLanguageTree(java.lang.String lang, corinis.modules.abstracts.Module module, org.w3c.dom.Document doc)
          Returns a tree containing the language strings of the requested module.
 corinis.modules.abstracts.Module getModule(java.lang.Class moduleClass)
          Retrieve a module from the internal cache
 long getOfflineTime()
           
 java.lang.String getProfilerField(long userid, java.lang.String fieldname)
           
 org.w3c.dom.Element getRoot()
           
 javax.servlet.ServletContext getServletContext()
          Get the servlet context
 javax.servlet.http.HttpServletRequest getServletRequest()
          Get the servlet request class
 javax.servlet.http.HttpServletResponse getServletResponse()
          Get the servlet response class
 corinis.modules.core.CorinisSession getSession()
          Get the session class
 java.lang.String getSessionId()
          A helper function to retrieve the current users Session ID.
 java.lang.String getTemplatePath()
          Get the template path
 javax.xml.transform.Transformer getTransformer(java.lang.String xslfile)
          Cache the XSL Transformers for greater Speed
 java.lang.String getURI()
          A helper Function to return the URI from the request Object
 java.lang.String getUserActiveStatus(long id)
          Get the ActiveStatus an id
 java.lang.String getUserById(long id)
          Get the Username by an id
 java.lang.String getUserEmail()
          Retrieve the current users email
 java.lang.String getUserEmail(long userid)
          Retrieve the email of a user.
 long getUserId()
          Get the user id.
 long getUserIdbyName(java.lang.String name)
          Get the User ID by its name.
 java.lang.String getUserIP()
          Get the user ip
 java.lang.String getUserName()
          Get the user name
 org.w3c.dom.Element getUsers(dbConnectionBroker pool, org.w3c.dom.Document doc)
          Returns a list of users.
 corinis.modules.abstracts.data.DataView getView(java.lang.Class viewClass)
          Retrieve a dataview from the internal cache
 boolean isAdmin()
           
 boolean isDebug()
           
 boolean isLoggedOn()
          Checks if the current user is logged on
 boolean isUserActive(long id)
          Checks if a given User is currently active
 boolean isUserOnline(java.lang.String id)
          Checks the DB if a certain user is online
 boolean mAvail(java.lang.String module)
          Checks if a module is available
 java.lang.String parseDom(org.w3c.dom.Node tree, java.lang.String xslfile)
          Parses a dom tree, without adding it to the core tree
 java.lang.String parseDom(java.lang.String xslfile)
          Parses a saved dom that is stored in the core module.
 java.lang.String parseDomHtml(org.w3c.dom.Node tree, java.lang.String xslfile)
          Parses a dom tree, without adding it to the core tree.
 java.lang.String parseDomHtml(java.lang.String xslfile)
          Parses a saved dom that is stored in the core module.
 java.lang.String parseXML(org.w3c.dom.Element root, java.lang.String xslfile)
          this function takes a document object and parses it with an xsl file.
 void printLog(java.lang.String what)
          output an error to the logfile
 void printLog(java.lang.String what, java.lang.Exception e)
          output an error to the logfile
 long printTimeLog(java.lang.String what, long last)
          output a timestamp to the logfile
 void redirect(java.lang.String online, java.lang.String offline, java.lang.String timedout)
          Redirects to a certain page based on the user state
 boolean reload()
          This function reloads the Context.
 void reloadRights()
          Reinitialise the right cachers
 boolean[] rightArray(long elementid, java.lang.String module)
          Returns an array of all rights the user has for the given element.
 boolean rightCreate(long elementid, java.lang.String module)
          Checks if the current user has the right to create the given element.
 boolean rightDelete(long elementid, java.lang.String module)
          Checks if the current user has the right to delete the given element.
 boolean rightModify(long elementid, java.lang.String module)
          Checks if the current user has the right to modify the given element.
 boolean rightQm(long elementid, java.lang.String module)
          Checks if the current user has the right to quality manage the given element.
 boolean rightSpecial1(long elementid, java.lang.String module)
          Checks if the current user has the special right 1 for the given element.
 boolean rightSpecial2(long elementid, java.lang.String module)
          Checks if the current user has the special right 2 for the given element.
 boolean rightSpecial3(long elementid, java.lang.String module)
          Checks if the current user has the special right 3 for the given element.
 boolean rightSpecial4(long elementid, java.lang.String module)
          Checks if the current user has the special right 4 for the given element.
 boolean rightSpecial5(long elementid, java.lang.String module)
          Checks if the current user has the special right 5 for the given element.
 org.w3c.dom.Element rightTree(long elementid, java.lang.String module)
          Create a nice right tree out of the element rights.
 boolean rightView(long elementid, java.lang.String module)
          Checks if the current user has the right to view the given element.
 boolean sendMessage(long toUser, java.lang.String message, java.lang.String addmessage, int messagetype)
          Creates the new message.
 boolean sendMessage(java.lang.String toname, java.lang.String message, java.lang.String addmessage, int messagetype)
          Creates the new entry (internal)
 void setAdmin(boolean isAdmin)
           
 void setDoc(org.w3c.dom.Document doc)
          Deprecated. YOU SHOULD NOT USE THIS :P
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GUESTUSER

public static final int GUESTUSER
See Also:
Constant Field Values

ADMINUSER

public static final int ADMINUSER
See Also:
Constant Field Values

GUESTGROUP

public static final int GUESTGROUP
See Also:
Constant Field Values

ALLGROUP

public static final int ALLGROUP
See Also:
Constant Field Values

ADMINGROUP

public static final int ADMINGROUP
See Also:
Constant Field Values

CMSEDITGROUP

public static final int CMSEDITGROUP
See Also:
Constant Field Values

CMSQMGROUP

public static final int CMSQMGROUP
See Also:
Constant Field Values

FORUMMODERATOR

public static final int FORUMMODERATOR
See Also:
Constant Field Values

rights

public corinis.modules.core.UserRightCacher rights
Constructor Detail

Core

public Core(javax.servlet.jsp.PageContext pcontext)

Core

public Core(java.lang.ClassLoader cl,
            javax.servlet.jsp.PageContext pcontext)

Core

public Core(javax.servlet.http.HttpServletRequest srequest,
            javax.servlet.http.HttpServletResponse sresponse,
            javax.servlet.ServletContext scontext)

Core

public Core(java.lang.String locationPath,
            java.lang.String appName,
            javax.servlet.http.HttpServletRequest srequest,
            javax.servlet.http.HttpServletResponse sresponse,
            javax.servlet.ServletContext scontext)
Inits the core class providing user and session managment also puts some stuff into the servlet context for faster use.
The appName value is important. It has to be the name of the community configuration file (xxx.xml) without the .xml (xxx). On each server this has to be unique (has to be anyways since you cant have 2 files with the same name). Be carefull with upper/lowercase. The name is case sensetive!

Parameters:
locationPath - the path of there to find the .xml and .dat file
appName - the name of the app (unique!)
srequest - the request header
sresponse - the servlet response
scontext - the servlet context
Method Detail

getOfflineTime

public long getOfflineTime()
Returns:
the time in seconds when the user is set offline

getView

public corinis.modules.abstracts.data.DataView getView(java.lang.Class viewClass)
Retrieve a dataview from the internal cache

Parameters:
viewClass - the class to get
Returns:
the dataview instance

getModule

public corinis.modules.abstracts.Module getModule(java.lang.Class moduleClass)
Retrieve a module from the internal cache

Parameters:
moduleClass - the class to load
Returns:
the instance of the class

printLog

public void printLog(java.lang.String what)
output an error to the logfile

Parameters:
what - the log line to print (timestamped)

printLog

public void printLog(java.lang.String what,
                     java.lang.Exception e)
output an error to the logfile

Parameters:
what - the log line to print (timestamped)

printTimeLog

public long printTimeLog(java.lang.String what,
                         long last)
output a timestamp to the logfile

Parameters:
what - the log line to print (timestamped)

getDocumentBuilder

public javax.xml.parsers.DocumentBuilder getDocumentBuilder()
A helper function that Returns the cached DocumentBuilder object from the core Context

Returns:
the cached document builder

getContextHashtable

public java.util.Hashtable getContextHashtable()
Returns:
A hashtable from the Servlet Context

getTransformer

public javax.xml.transform.Transformer getTransformer(java.lang.String xslfile)
Cache the XSL Transformers for greater Speed

Parameters:
xslfile - the xsl file the transformer is for
Returns:
the transformer

parseXML

public java.lang.String parseXML(org.w3c.dom.Element root,
                                 java.lang.String xslfile)
this function takes a document object and parses it with an xsl file.

Parameters:
root - the tree part to parse
xslfile - the xsl to parse with
Returns:
the resulting tree as string

getLanguageTree

public org.w3c.dom.Element getLanguageTree(java.lang.String lang,
                                           corinis.modules.abstracts.Module module,
                                           org.w3c.dom.Document doc)
Returns a tree containing the language strings of the requested module.
 <MODULENAME>
  <STRINGNAME> - the converted language string
  ...
 </MODULENAME>
 

Parameters:
lang - the language to get
module - the name of the module
doc - the document object
Returns:
a tree as shown above

encryptString

public java.lang.String encryptString(java.lang.String s)
Ecrypt Strings for password checking

Parameters:
s - the password to encrypt
Returns:
the encrypted

sendMessage

public boolean sendMessage(java.lang.String toname,
                           java.lang.String message,
                           java.lang.String addmessage,
                           int messagetype)
Creates the new entry (internal)

Parameters:
toname - user name of the receiver
message - the message that is sent
addmessage - additional message data (can be used for special messages)
messagetype - a type for the message (to identify f.e. forum alert; system alert;...)
Returns:
false if unsuccessfull
Throws:
java.lang.Exception - on fatal errors

sendMessage

public boolean sendMessage(long toUser,
                           java.lang.String message,
                           java.lang.String addmessage,
                           int messagetype)
Creates the new message.

Parameters:
toUser - user name of the receiver
message - the message that is sent
addmessage - additional message data (can be used for special messages)
messagetype - a type for the message (to identify f.e. forum alert; system alert;...)
Returns:
false if unsuccessfull

getCoreTree

public org.w3c.dom.Node getCoreTree()
Generates a core tree segment, with ip, username, userid, url

Returns:
core tree

getURI

public java.lang.String getURI()
A helper Function to return the URI from the request Object

Returns:
the current uri

getConfigurator

public corinis.modules.core.CorinisContext getConfigurator()
Used to retrieve the core Context out of the Servlet Context

Returns:
the core Context

mAvail

public boolean mAvail(java.lang.String module)
Checks if a module is available

Parameters:
module - the module Name/Class
Returns:
true if available

getSession

public corinis.modules.core.CorinisSession getSession()
Get the session class

Returns:
the session class

getServletRequest

public javax.servlet.http.HttpServletRequest getServletRequest()
Get the servlet request class

Returns:
the servlet request

getServletResponse

public javax.servlet.http.HttpServletResponse getServletResponse()
Get the servlet response class

Returns:
the servlet response

getConnectionPool

public dbConnectionBroker getConnectionPool()
Get the connection pool

Returns:
the connection pool

getServletContext

public javax.servlet.ServletContext getServletContext()
Get the servlet context

Returns:
the servlet context

getApp

public java.lang.String getApp()
Get the application name

Returns:
the application name

getUserName

public java.lang.String getUserName()
Get the user name

Returns:
the user name of the current user

getUserIP

public java.lang.String getUserIP()
Get the user ip

Returns:
the user name of the current user

getSessionId

public java.lang.String getSessionId()
A helper function to retrieve the current users Session ID. Useful if you plan to use URL-Rewriting within JSP

Returns:
the session id

getUserId

public long getUserId()
Get the user id.
1 .. guest
2 .. admin

Returns:
the user name of the current user

fakeGuest

public void fakeGuest()
Call this function fakes the current user as guest until called again. This allows better caching performance in f.e. the cms


getUserById

public java.lang.String getUserById(long id)
Get the Username by an id

Parameters:
id - The id of the user
Returns:
the Username by an id, null if none found

getProfilerField

public java.lang.String getProfilerField(long userid,
                                         java.lang.String fieldname)
Parameters:
userid - the userid of the user to get the profilerfield for
fieldname - the name of the field to get
Returns:
the value of this field

getUserActiveStatus

public java.lang.String getUserActiveStatus(long id)
Get the ActiveStatus an id

Parameters:
id - The id of the user
Returns:
the Username by an id, null if none found

isUserActive

public boolean isUserActive(long id)
Checks if a given User is currently active

Parameters:
id - The id of the user
Returns:
true if this user is active

isLoggedOn

public boolean isLoggedOn()
Checks if the current user is logged on

Returns:
true if the User is logged on

getUserIdbyName

public long getUserIdbyName(java.lang.String name)
Get the User ID by its name. If the user does not exist the id is -1.

Parameters:
name - The users name
Returns:
the user id, -1 if not found

getTemplatePath

public java.lang.String getTemplatePath()
Get the template path

Returns:
the template path

activateMe

public void activateMe(java.lang.String name,
                       java.lang.String id)
activate the user

Parameters:
name - the name od the user
id - the id of the user

redirect

public void redirect(java.lang.String online,
                     java.lang.String offline,
                     java.lang.String timedout)
Redirects to a certain page based on the user state

Parameters:
online - url to redirect when user is online
offline - url to redirect when user is offline
timedout - url to redirect when user is timed out

checkAuthority

public boolean checkAuthority(java.lang.String authCode)
Checks if a user has a authority

Parameters:
authCode - the authority to check for
Returns:
true if the authority exists for this user, false if not

checkAuthority

public boolean checkAuthority(java.lang.String authCode,
                              corinis.modules.abstracts.Module mod)
Checks if a user has a authority

Parameters:
authCode - the authority to check for
Returns:
true if the authority exists for this user, false if not

getUsers

public org.w3c.dom.Element getUsers(dbConnectionBroker pool,
                                    org.w3c.dom.Document doc)
Returns a list of users.

Parameters:
pool - the connection pool
doc - the document object
Returns:
a list of users

isUserOnline

public boolean isUserOnline(java.lang.String id)
Checks the DB if a certain user is online

Parameters:
id - the user id
Returns:
true if the user is online

reload

public boolean reload()
This function reloads the Context. By this all caches and connections are reset and reinitialized. The configuration is also reloaded.


reloadRights

public void reloadRights()
Reinitialise the right cachers


getDoc

public org.w3c.dom.Document getDoc()
Returns:
Document the document element

setDoc

public void setDoc(org.w3c.dom.Document doc)
Deprecated. YOU SHOULD NOT USE THIS :P


getRoot

public org.w3c.dom.Element getRoot()
Returns:
Element the root element to append new subtrees

addDom

public void addDom(org.w3c.dom.Node tree)
Adds a domtree from any function to the current one in the core module for later processing.

Parameters:
tree - a dom-tree (normally returned from a function)

parseDom

public java.lang.String parseDom(java.lang.String xslfile)
Parses a saved dom that is stored in the core module. Remember that a core-saved dom-tree starts with CORINIS as root node!

Parameters:
xslfile - The xsl document to parse
Returns:
the parsed dom

parseDomHtml

public java.lang.String parseDomHtml(java.lang.String xslfile)
Parses a saved dom that is stored in the core module. Remember that a core-saved dom-tree starts with CORINIS as root node!

Parameters:
xslfile - The xsl document to parse
Returns:
the parsed dom

parseDom

public java.lang.String parseDom(org.w3c.dom.Node tree,
                                 java.lang.String xslfile)
Parses a dom tree, without adding it to the core tree

Parameters:
xslfile - The xsl document to parse
tree - a dom-tree (normally returned from a function)
Returns:
the parsed dom

parseDomHtml

public java.lang.String parseDomHtml(org.w3c.dom.Node tree,
                                     java.lang.String xslfile)
Parses a dom tree, without adding it to the core tree. This function should be used when there is html within the dom tree that should be displayed as it is.

Parameters:
xslfile - The xsl document to parse
tree - a dom-tree (normally returned from a function)
Returns:
the parsed dom

rightModify

public boolean rightModify(long elementid,
                           java.lang.String module)
Checks if the current user has the right to modify the given element.

Parameters:
elementid - the id of the element to check the right for
module - the module where to look for the element
Returns:
true if the current user has the right

rightView

public boolean rightView(long elementid,
                         java.lang.String module)
Checks if the current user has the right to view the given element.

Parameters:
elementid - the id of the element to check the right for
module - the module where to look for the element
Returns:
true if the current user has the right

rightCreate

public boolean rightCreate(long elementid,
                           java.lang.String module)
Checks if the current user has the right to create the given element.

Parameters:
elementid - the id of the element to check the right for
module - the module where to look for the element
Returns:
true if the current user has the right

rightDelete

public boolean rightDelete(long elementid,
                           java.lang.String module)
Checks if the current user has the right to delete the given element.

Parameters:
elementid - the id of the element to check the right for
module - the module where to look for the element
Returns:
true if the current user has the right

rightQm

public boolean rightQm(long elementid,
                       java.lang.String module)
Checks if the current user has the right to quality manage the given element.

Parameters:
elementid - the id of the element to check the right for
module - the module where to look for the element
Returns:
true if the current user has the right

rightSpecial1

public boolean rightSpecial1(long elementid,
                             java.lang.String module)
Checks if the current user has the special right 1 for the given element.

Parameters:
elementid - the id of the element to check the right for
module - the module where to look for the element
Returns:
true if the current user has the right

rightSpecial2

public boolean rightSpecial2(long elementid,
                             java.lang.String module)
Checks if the current user has the special right 2 for the given element.

Parameters:
elementid - the id of the element to check the right for
module - the module where to look for the element
Returns:
true if the current user has the right

rightSpecial3

public boolean rightSpecial3(long elementid,
                             java.lang.String module)
Checks if the current user has the special right 3 for the given element.

Parameters:
elementid - the id of the element to check the right for
module - the module where to look for the element
Returns:
true if the current user has the right

rightSpecial4

public boolean rightSpecial4(long elementid,
                             java.lang.String module)
Checks if the current user has the special right 4 for the given element.

Parameters:
elementid - the id of the element to check the right for
module - the module where to look for the element
Returns:
true if the current user has the right

rightSpecial5

public boolean rightSpecial5(long elementid,
                             java.lang.String module)
Checks if the current user has the special right 5 for the given element.

Parameters:
elementid - the id of the element to check the right for
module - the module where to look for the element
Returns:
true if the current user has the right

rightArray

public boolean[] rightArray(long elementid,
                            java.lang.String module)
Returns an array of all rights the user has for the given element. Check the constants in UserRightCacher for which element is assigned to which right.

Parameters:
elementid - the id of the element to check the right for
module - the module where to look for the element
Returns:
an boolean array with the length 10

rightTree

public org.w3c.dom.Element rightTree(long elementid,
                                     java.lang.String module)
Create a nice right tree out of the element rights.
Return tree:
 <right>
   <rightcreate>T/F
   <rightview>T/F
   <rightmodify>T/F
   <rightdelete>T/F
   <rightqm>T/F
   <specialright1>T/F
   <specialright2>T/F
   <specialright3>T/F
   <specialright4>T/F
   <specialright5>T/F
 </right>
 

Parameters:
elementid - the id of the element to check the right for
module - the module where to look for the element
Returns:
a tree with all rights attached

isDebug

public boolean isDebug()
Returns:
true if we want debug information

getAuthorityGroupByID

public java.lang.String getAuthorityGroupByID(long id)
Parameters:
id - the id of the group
Returns:
the name of the group

isAdmin

public boolean isAdmin()

setAdmin

public void setAdmin(boolean isAdmin)

getUserEmail

public java.lang.String getUserEmail(long userid)
Retrieve the email of a user.

Parameters:
userid - the user to get the email for
Returns:
the email address or null if not found

getUserEmail

public java.lang.String getUserEmail()
Retrieve the current users email

Returns:
the email (if any)

getDataStore

public corinis.modules.interfaces.IDataStore getDataStore(java.lang.Class dsClass)

getCache

public corinis.modules.cache.Cache getCache()
Returns:
the cache instance