kom.gateway
Class KOMutil

java.lang.Object
  |
  +--kom.gateway.DBLow
        |
        +--kom.gateway.DBHigh
              |
              +--kom.gateway.KOMutil
Direct Known Subclasses:
Form

public class KOMutil
extends DBHigh

Common utility functions and data for the KOM system


Inner Class Summary
(package private)  class KOMutil.LookupTables
          Auxiliary class for tables and methods to up login ids, etc
(package private)  class KOMutil.UFtable
          Contains a table of users or forums, and a method to find an entry in the table
 
Field Summary
(package private) static java.lang.String ACT
           
(package private)  boolean anyAccess
          When set, allows any access to objects.
(package private)  java.lang.String arglist
          List of arguments from request URL
(package private)  java.lang.String argsep
          Argument separator in URLs
(package private)  java.util.Hashtable argtab
          Parsed list of arguments from request URL
(package private)  Upload[] attachments
          Attachments
(package private) static java.lang.String BOK
           
(package private) static java.lang.String BOUNDARYSTART
           
(package private) static java.lang.String CAT
          Object types
(package private) static java.lang.String CHA
           
(package private) static KomData cidTable
          Table of Content-Id vs local file ref
(package private) static java.lang.String CLO
           
(package private)  ServerConfig config
          Configuration data for this server
(package private) static NewsGroupData curNgd
          Data for current newsgroup (Usenet News)
(package private) static java.lang.String DIC
           
(package private)  Environment environment
          Data for the current client
(package private)  Gateway gateway
          Client supervisor
(package private) static java.util.Hashtable gavePassword
          Shows which users have access to specific items
(package private) static java.lang.String GEN
           
(package private) static java.lang.String GRA
           
(package private) static java.lang.String GRP
           
(package private)  java.lang.String inlineCurr
          List of files referred to as inline objects
(package private)  Upload[] inlines
          Inline files
(package private) static java.lang.String INT
           
(package private) static int LINE_CUTOFF
          Try to keep line length around this
(package private) static int LINE_FUDGE
          Allowed variation around LINE_CUTOFF
(package private) static java.lang.String LIS
           
(package private) static KOMutil.LookupTables lt
          Current lookup tables
(package private) static int MAILIT
           
(package private) static javax.mail.Message.RecipientType[] messageRecipientTypeCode
          Local recipient type code to JavaMail recipient type code
(package private) static java.lang.String MIM
           
(package private) static java.lang.String MOD
           
(package private) static int N_RECTY
          Number of ordinary recipient types
(package private) static int N_RECTYPECODE
          "rec", "cc", "bcc", plus "par"
(package private)  NewsClient newsclient
          Current NewsClient instance
(package private) static java.util.Hashtable newsClients
           
(package private)  KomData newsData
          News data for current user
(package private) static java.util.Hashtable nntpAuth
          Authentication data for NNTP servers
(package private) static java.lang.String NWS
           
(package private) static java.lang.String NWSART
           
(package private) static java.util.Hashtable objCache
          Cache for objects
(package private)  KomData oCurr
          Current object (usually a message to be sent or shown)
(package private) static MsgIdTable oldnews
          News msgids vs local refs
(package private) static int POSTIT
           
(package private) static java.lang.String RAT
           
(package private) static int REC_BCC
           
(package private) static int REC_CC
           
(package private) static int REC_TO
           
(package private) static java.lang.String[] recTypeCode
          Local recipient type code vs String representation
(package private) static java.lang.String REP
           
(package private)  HTTPResponse response
          Response data and methods
(package private)  java.lang.String rLoc
          Current "location" (object id, from request url)
(package private) static MsgIdTable savednews
          News msgids vs saved article text refs
(package private)  java.lang.String sCursor
          (Main) thread identifier
(package private)  java.lang.String servletBase
          Prefix in url denoting current servlet
(package private)  javax.servlet.http.HttpSession session
          HTTP session data
(package private) static java.lang.String THR
           
(package private)  KomData userData
          Data for current user
(package private) static java.lang.String USR
           
(package private) static java.lang.String VOT
           
 
Fields inherited from class kom.gateway.DBHigh
AdminURL, cache, HomeURL, UsersURL
 
Fields inherited from class kom.gateway.DBLow
absCDBpath, config, fSep, fSeparator, msgAuth, msgParts
 
Constructor Summary
KOMutil(ServerConfig config, HTTPResponse response, Gateway gateway)
          Class constructor
 
Method Summary
 java.lang.String a(java.lang.String ref, java.lang.String link)
          Constructs an HTML link
 boolean accessCont(java.lang.String ref)
          Checks if current user is allowed to access object contents.
 boolean accessCont(java.lang.String ref, KomData obj)
          Checks if current user is allowed to access object contents.
(package private)  boolean accessObj(java.lang.String ref, KomData obj)
          Checks if the reference is accessible
 void addInfoData(KomData data)
          Updates infoData
 KomData addrToLocal(javax.mail.internet.InternetAddress a)
          Converts an Address to a local reference, or leaves it as is
 void changeEnvironment()
          Changes environment (associates environment with new user data).
private  void cidReplace(java.lang.StringBuffer sb, int pos)
          If there is any img src=.../cid:xxx or a href=.../cid:xxx tag in the buffer, the cid:xxx part will be replaced by a local file name.
static java.lang.String contType(javax.mail.Part p, java.lang.String dflt, int part)
          Gets the primary or secondary type of a MIME part
(package private)  java.lang.String decodeText(java.lang.String s)
          Decodes strings encoded according to RFC 2047.
static boolean deleted(KomData ct)
          Checks if an item has been marked for deletion
(package private)  java.lang.String dispMailMessage(java.lang.String bodyref, KomData ht, java.lang.StringBuffer sb)
          Displays an email message.
private  void doAction()
          Adds a client to the gateway if there is no client for this connection.
static boolean equal(java.lang.String s1, java.lang.String s2)
          Compares strings, null-safe
private  boolean excluded(KomData obj)
          Finds out if current user has been excluded from an activity.
 java.lang.String fetchNews(java.lang.String act)
          Fetches news for the current user in the current activity.
protected  java.io.InputStream findId(java.lang.String id)
          Tries to find the object corresponding to a "mailbox" id.
protected  java.io.InputStream findId(java.lang.String id, boolean recurse)
          Tries to find the object corresponding to a "mailbox" id.
 KomData findlocal(java.lang.String email)
          Finds a local recipient
 java.lang.String findLogin(java.lang.String loginid)
          Finds a user from login id
(package private)  java.lang.String findOwner(java.lang.String id)
          Finds out "who owns" an object
 java.lang.String findUser(java.lang.String user)
          Finds info data for a user.
(package private)  java.lang.String getActId(java.lang.String id)
          Gets activity id from an object reference.
 KomData getcont(java.lang.String ref)
          Gets a contents table, no access control.
 KomData getcont(java.lang.String ref, KomData obj)
          Gets a contents table.
 java.util.Vector getcontV(java.lang.String ref)
          Gets a contents Vector, no access control.
 java.util.Vector getcontV(java.lang.String ref, KomData obj)
          Gets a contents Vector.
 NewsGroupData getCurNgd()
          Gets current NewsGroupData instance
 KomData getmemb(java.lang.String ref, KomData obj)
          Gets a member table.
(package private)  java.util.Vector getMsgParts(KomData obj)
           
(package private)  java.lang.String getMsgText(javax.mail.internet.MimePart part, int pn)
          Gets the text of the n-th part of a multipart.
 KomData getNews(java.lang.String ref)
          Gets news data from an (activity) object.
static java.lang.String[] getNewsAuth(java.lang.String nntp)
          Finds {user id, password} for access of an NNTP server.
 KomData getobj(java.lang.String ref)
          Gets data for an object.
 KomData getobject(java.lang.String ref)
          Gets data for an object, no access checking.
 KomData getold(java.lang.String ref)
          Gets old data for an object
 java.lang.String getParent(java.lang.String ref)
          Gets the next higher level from a reference string
 java.lang.String getPart(java.lang.String ref)
          Gets the last level from a reference string
 java.lang.String getSimpleFileName(javax.mail.Part p)
          Gets a filename for a (Message) Part, with directory information stripped.
 java.lang.String getSimpleFileName(java.lang.String fn)
          Strips directory information from a file path The name is converted to HTML-safe form
 java.io.InputStream getStream(java.lang.String s)
          Converts a String to a ByteArrayInputStream, updating the response headers in preparation to sending the data.
 java.lang.String getTail(java.lang.String ref)
          Gets the part after the last / in a path/ref
(package private)  java.lang.String getTextPart(KomData obj)
           
 java.lang.String getVal(java.lang.String key)
          Gets a value from arglist, a String of key=value pairs, delimited by && or end of string.
 java.lang.String getVal(java.lang.String list, java.lang.String key, java.lang.String delim)
          Gets a value from a String of key=value pairs, delimited by delim or end of string.
private  boolean isAllowed(KomData obj, java.lang.String type)
          Checks if current user is allowed to access an object, based on membership.
 boolean isarg(java.lang.String arg)
          Checks if a specific argument was given in the current URL argument list.
 boolean isMember(java.lang.String act)
          Finds out if current user is a member of an activity.
 boolean isOrganizer(KomData obj)
          Finds out if current user har organizer privileges for an object.
 boolean isOrganizer(java.lang.String ref)
          Finds out if current user har organizer privileges for an object.
(package private) static boolean ispunct(char c)
          Checks for "punctuation" characters
 boolean isType(KomData ht, java.lang.String type)
          Checks if an object is of a certain type
 boolean isValidEmailAddress(java.lang.String a)
          Attempts to check a purported e-mail address string for validity
 boolean loggedIn()
          Checks if current user is logged in.
 java.lang.String mailDate(java.util.Date d)
          Formats a Date according to standard mail date format.
 java.lang.String mailDate(java.util.Date d, java.lang.String fmt)
          Formats Date like "Wed, 7 Oct 1998 13:02:20 +0200" (standard e-mail format)
(package private)  javax.mail.internet.MimeMessage mimeMessage(java.lang.String id, java.lang.String part, java.io.File f)
          Creates a MimeMessage object from database data
(package private)  java.io.InputStream mimeMessageStream(java.lang.String id, java.lang.String part, java.io.File f)
          Gets an InputStream for a message from database data
 java.lang.String mkdate(java.lang.String longdate)
          Makes a formatted date/time of a time in decimal form
 java.lang.String mkdate(java.lang.String longdate, java.lang.String format)
          Makes a formatted date/time of a time in decimal form
(package private) static java.lang.String noQuote(java.lang.String s)
          Replaces any quote (") char by ".
(package private)  void parseArglist(java.lang.String sep)
          Parses arglist into argtab.
(package private)  java.util.Hashtable parseArgs(java.lang.String list, java.lang.String sep)
          Parses a String into key[=value] parts and places those in a Hashtable.
 void setCids(java.lang.String cid, java.lang.String pid, java.lang.String partName)
          Updates cidCurr table of Content-Id and/or Content-Location references and also the table in the current object.
static void setNewsAuth(java.lang.String nntp, java.lang.String user, java.lang.String pass)
          Sets up table of user/pass data per NNTP server.
(package private)  void setValidMsgPwd(java.lang.String id, java.lang.String uid)
          Records a user as having access to an object.
 void showBody(javax.mail.Part p, java.lang.String level, java.lang.StringBuffer sb, java.lang.String makeTag)
          Shows the body (text) of a Message (Part)
private  void showHeader(java.lang.String name, javax.mail.Address[] value, java.lang.StringBuffer sb)
          Shows a header line with an Address[] value
private  void showHeader(java.lang.String name, java.lang.String value, java.lang.StringBuffer sb)
          Shows a header line with a String value
private  int showHeaders(javax.mail.Part p, boolean top, java.lang.StringBuffer sb)
          Shows the header fields of a Part
 void showInputStream(javax.mail.Part p, java.io.InputStream b, java.lang.StringBuffer sb, java.lang.String makeTag, java.lang.String level)
          Shows a general simple body (InputStream of data)
 java.lang.String showMailMessage(javax.mail.internet.MimeMessage msg, java.lang.StringBuffer sb)
          Displays a message in the current buffer
 void showMessage(javax.mail.Message msg, java.lang.String level, java.lang.StringBuffer sb)
          Shows an embedded Message
 void showMultipart(javax.mail.Part pp, javax.mail.Multipart b, java.lang.String level, java.lang.StringBuffer sb)
          Shows a Multipart
(package private)  java.lang.String toString(java.io.InputStream inp)
          Creates a String from an InputStream
static java.lang.String transbody(java.lang.String body)
          Translates special characters in a string, usually a plain message text, to HTML entities.
private  void urlexpand(java.lang.StringBuffer sb, java.lang.String bt, int pos)
          Shows http://url as real link
(package private)  boolean userGavePassword(java.lang.String id)
          Checks if current user is recorded to have given the correct password for access of an object.
(package private)  boolean userGavePassword(java.lang.String id, java.lang.String uid)
          Checks if user is recorded to have given the correct password for access of an object.
(package private) static java.lang.String wrap(java.lang.String text, boolean cr_and_lf)
          Tries to wrap long lines into shorter lines.
 
Methods inherited from class kom.gateway.DBHigh
addContent, addContent, addDraft, addInfo, addLast, addMember, addNews, addObj, addObj, addObject, addObject, addQuery, cleanDrafts, contentCount, createNews, depth, expungeRef, findContent, findDraft, findDraftData, findInfo, findMemb, findNews, findObject, findObject, findQuery, getFormContents, getQryDefault, getQueries, getseq, getStringValues, getValues, invalidateCount, isEmpty, isStandard, listDraft, makeArea, modObject, msgExists, nextDraft, queryExists, ref2path, refExists, removeDraft, removeQuery, replaceObject, Stream2String, String2Stream, StringBuffer2Stream, updateCount, updCount, updref, updseq
 
Methods inherited from class kom.gateway.DBLow
accessPart, addFile, areaExists, basedRef, createArea, debugLog, errorLog, expungeFile, File2Stream, File2String, findPart, getFile, getFileContents, getFileStream, getPath, getStandard, isMailSpool, lastModified, length, listFiles, makePart, msgPartStream, partfile, partpath, printStackTrace, readObject, removeFile, replaceMime, updseq1, validate, validate, writeObject
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

CAT

static final java.lang.String CAT
Object types

ACT

static final java.lang.String ACT

USR

static final java.lang.String USR

GRP

static final java.lang.String GRP

THR

static final java.lang.String THR

REP

static final java.lang.String REP

CLO

static final java.lang.String CLO

BOK

static final java.lang.String BOK

MOD

static final java.lang.String MOD

CHA

static final java.lang.String CHA

GRA

static final java.lang.String GRA

RAT

static final java.lang.String RAT

DIC

static final java.lang.String DIC

VOT

static final java.lang.String VOT

GEN

static final java.lang.String GEN

INT

static final java.lang.String INT

LIS

static final java.lang.String LIS

NWS

static final java.lang.String NWS

NWSART

static final java.lang.String NWSART

MIM

static final java.lang.String MIM

MAILIT

static final int MAILIT

POSTIT

static final int POSTIT

argsep

java.lang.String argsep
Argument separator in URLs

attachments

Upload[] attachments
Attachments

inlines

Upload[] inlines
Inline files

objCache

static java.util.Hashtable objCache
Cache for objects

nntpAuth

static java.util.Hashtable nntpAuth
Authentication data for NNTP servers

cidTable

static KomData cidTable
Table of Content-Id vs local file ref

gavePassword

static java.util.Hashtable gavePassword
Shows which users have access to specific items

inlineCurr

java.lang.String inlineCurr
List of files referred to as inline objects

BOUNDARYSTART

static final java.lang.String BOUNDARYSTART

REC_TO

static final int REC_TO

REC_CC

static final int REC_CC

REC_BCC

static final int REC_BCC

N_RECTY

static final int N_RECTY
Number of ordinary recipient types

recTypeCode

static final java.lang.String[] recTypeCode
Local recipient type code vs String representation

N_RECTYPECODE

static final int N_RECTYPECODE
"rec", "cc", "bcc", plus "par"

messageRecipientTypeCode

static final javax.mail.Message.RecipientType[] messageRecipientTypeCode
Local recipient type code to JavaMail recipient type code

newsClients

static java.util.Hashtable newsClients

oldnews

static MsgIdTable oldnews
News msgids vs local refs

savednews

static MsgIdTable savednews
News msgids vs saved article text refs

newsclient

NewsClient newsclient
Current NewsClient instance

config

ServerConfig config
Configuration data for this server

servletBase

java.lang.String servletBase
Prefix in url denoting current servlet

response

HTTPResponse response
Response data and methods

session

javax.servlet.http.HttpSession session
HTTP session data

gateway

Gateway gateway
Client supervisor

environment

Environment environment
Data for the current client

sCursor

java.lang.String sCursor
(Main) thread identifier

userData

KomData userData
Data for current user

newsData

KomData newsData
News data for current user

lt

static KOMutil.LookupTables lt
Current lookup tables

rLoc

java.lang.String rLoc
Current "location" (object id, from request url)

arglist

java.lang.String arglist
List of arguments from request URL

argtab

java.util.Hashtable argtab
Parsed list of arguments from request URL

curNgd

static NewsGroupData curNgd
Data for current newsgroup (Usenet News)

oCurr

KomData oCurr
Current object (usually a message to be sent or shown)

anyAccess

boolean anyAccess
When set, allows any access to objects. Required in GetMail and SendMail

LINE_CUTOFF

static final int LINE_CUTOFF
Try to keep line length around this

LINE_FUDGE

static final int LINE_FUDGE
Allowed variation around LINE_CUTOFF
Constructor Detail

KOMutil

public KOMutil(ServerConfig config,
               HTTPResponse response,
               Gateway gateway)
Class constructor
Parameters:
config - Server configuration data
response - HTTP response object
gateway - Reference to client supervisor
Method Detail

getCurNgd

public NewsGroupData getCurNgd()
Gets current NewsGroupData instance
Returns:
value of curNgd

setNewsAuth

public static void setNewsAuth(java.lang.String nntp,
                               java.lang.String user,
                               java.lang.String pass)
Sets up table of user/pass data per NNTP server.
Parameters:
nntp - NNTP reference to server ("domain:port")
user - User name
pass - User password

getNewsAuth

public static java.lang.String[] getNewsAuth(java.lang.String nntp)
Finds {user id, password} for access of an NNTP server.
Parameters:
nntp - NNTP server reference ("domain:port")
Returns:
{user id, password} as a String array, or null

setValidMsgPwd

void setValidMsgPwd(java.lang.String id,
                    java.lang.String uid)
Records a user as having access to an object.
Parameters:
id - Object id
uid - User id

userGavePassword

boolean userGavePassword(java.lang.String id)
Checks if current user is recorded to have given the correct password for access of an object.
Parameters:
id - Object id
Returns:
true if current user is in access list for id of this object.

userGavePassword

boolean userGavePassword(java.lang.String id,
                         java.lang.String uid)
Checks if user is recorded to have given the correct password for access of an object.
Parameters:
id - Object id
uid - User id
Returns:
true if current user is in access list for id of this object.

isarg

public boolean isarg(java.lang.String arg)
Checks if a specific argument was given in the current URL argument list.
Parameters:
arg - Argument (key)
Returns:
true if arg was found in arglist (argtab)

getVal

public java.lang.String getVal(java.lang.String key)
Gets a value from arglist, a String of key=value pairs, delimited by && or end of string.
Parameters:
key - Key (name) of value
Returns:
value for key

getVal

public java.lang.String getVal(java.lang.String list,
                               java.lang.String key,
                               java.lang.String delim)
Gets a value from a String of key=value pairs, delimited by delim or end of string.
Parameters:
list - String of key=value pairs. Values may be quoted ("value")
key - Key (name) of value
delim - Delimiter string
Returns:
value for key

loggedIn

public boolean loggedIn()
Checks if current user is logged in.
Returns:
true if "Pself" is defined in userData.

doAction

private void doAction()
Adds a client to the gateway if there is no client for this connection.

changeEnvironment

public void changeEnvironment()
Changes environment (associates environment with new user data).

getobject

public KomData getobject(java.lang.String ref)
Gets data for an object, no access checking.
Parameters:
ref - Object reference
Returns:
Object data, no subtype

getobj

public KomData getobj(java.lang.String ref)
Gets data for an object.
Parameters:
ref - Object reference
Returns:
Object data, no subtype

accessObj

boolean accessObj(java.lang.String ref,
                  KomData obj)
Checks if the reference is accessible
Parameters:
ref - Reference
obj - Validating object
Returns:
true if access is allowed

getActId

java.lang.String getActId(java.lang.String id)
Gets activity id from an object reference.
Parameters:
id - Some reference
Returns:
Activity id for reference, if deep enough (/cat/act/...)

getmemb

public KomData getmemb(java.lang.String ref,
                       KomData obj)
Gets a member table.
Parameters:
ref - Object whose members are sought
obj - Access control object
Returns:
null, or a member list in KomData format.

getcont

public KomData getcont(java.lang.String ref)
Gets a contents table, no access control.
Parameters:
ref - Object whose contents are sought
Returns:
a contents list in KomData format, possibly empty

getcont

public KomData getcont(java.lang.String ref,
                       KomData obj)
Gets a contents table.
Parameters:
ref - Object whose contents are sought
obj - Access control object
Returns:
a contents list in KomData format, possibly empty

getcontV

public java.util.Vector getcontV(java.lang.String ref)
Gets a contents Vector, no access control.
Parameters:
ref - Object whose contents are sought
Returns:
a Vector of KomData, possibly empty.

getcontV

public java.util.Vector getcontV(java.lang.String ref,
                                 KomData obj)
Gets a contents Vector.
Parameters:
ref - Object whose contents are sought
obj - Access control object
Returns:
a Vector of KomData, maybe empty.

accessCont

public boolean accessCont(java.lang.String ref)
Checks if current user is allowed to access object contents.
Parameters:
ref - Object reference
Returns:
true if access is allowed to current user

accessCont

public boolean accessCont(java.lang.String ref,
                          KomData obj)
Checks if current user is allowed to access object contents.
Parameters:
ref - Object reference
obj - Access control object, or null
Returns:
true if access is allowed to current user

isAllowed

private boolean isAllowed(KomData obj,
                          java.lang.String type)
Checks if current user is allowed to access an object, based on membership.
Parameters:
obj - Reference object for membership control
type - Type of membership ("rec*" or "adm*")
Returns:
true if membership list checks out ok

isOrganizer

public boolean isOrganizer(java.lang.String ref)
Finds out if current user har organizer privileges for an object.
Parameters:
ref - Object reference
Returns:
true if user news file has user as an "org" member of the object, or in the case of a thread, of the forum containing the thread.

isOrganizer

public boolean isOrganizer(KomData obj)
Finds out if current user har organizer privileges for an object.
Parameters:
obj - Object reference
Returns:
true if obj is user's own, or user is the database administrator, or the user news file or the object itself has user registered as an "org" member of the object, or in the case of a thread, of the forum containing the thread.

getNews

public KomData getNews(java.lang.String ref)
Gets news data from an (activity) object.
Parameters:
ref - Object reference
Returns:
news table, or null

isMember

public boolean isMember(java.lang.String act)
Finds out if current user is a member of an activity.
Parameters:
act - Activity reference
Returns:
true if user appears to be a member (not excluded)

fetchNews

public java.lang.String fetchNews(java.lang.String act)
Fetches news for the current user in the current activity. Takes the data from newsData, the news structure for the current user.
Parameters:
act - Activity reference
Returns:
Current user news data for activity

getold

public KomData getold(java.lang.String ref)
Gets old data for an object
Parameters:
ref - Object reference
Returns:
Object data, no subtype, or null if not saved before

excluded

private boolean excluded(KomData obj)
Finds out if current user has been excluded from an activity.
Parameters:
obj - Activity object
Returns:
true if current user is no longer a member

deleted

public static boolean deleted(KomData ct)
Checks if an item has been marked for deletion
Parameters:
ct - A contents record
Returns:
true if "Pnr" has been set to "-1" to signify deletetion, or if "Ptype" starts with "-".

getParent

public java.lang.String getParent(java.lang.String ref)
Gets the next higher level from a reference string
Parameters:
ref - Reference string of the form /.../xxx/
Returns:
Parameter string with the last level ("xxx/") removed, or null

getPart

public java.lang.String getPart(java.lang.String ref)
Gets the last level from a reference string
Parameters:
ref - Reference string of the form /.../ppp/
Returns:
ref, or the "ppp" part of the parameter.

getTail

public java.lang.String getTail(java.lang.String ref)
Gets the part after the last / in a path/ref
Parameters:
ref - Reference string of the form /.../tail
Returns:
"", or the "tail" part of the parameter.

addInfoData

public void addInfoData(KomData data)
Updates infoData
Parameters:
data - Encoded value pairs

findLogin

public java.lang.String findLogin(java.lang.String loginid)
Finds a user from login id
Parameters:
loginid - Login id ("short name")
Returns:
Info entry for user, or null

findUser

public java.lang.String findUser(java.lang.String user)
Finds info data for a user.
Parameters:
user - User reference String
Returns:
info record for user, or null

findId

protected final java.io.InputStream findId(java.lang.String id)
Tries to find the object corresponding to a "mailbox" id.
Parameters:
id - Short id, the "mailbox" part of a presumed local mail address, possibly with "-owner" or "-request" appended.
Returns:
An InputStream containing "NONE" or a local id like "/1/15" referring to a local person or activity

findId

protected final java.io.InputStream findId(java.lang.String id,
                                           boolean recurse)
Tries to find the object corresponding to a "mailbox" id.
Parameters:
id - Short id, the "mailbox" part of a presumed local mail address
recurse - True if id should be checked with any trailing "-owner" or "-request" removed
Returns:
An InputStream containing "NONE" or a local id like "/1/15" referring to a local person or activity

findOwner

java.lang.String findOwner(java.lang.String id)
Finds out "who owns" an object
Parameters:
id - Object id
Returns:
Owner id (author, organizer)

getStream

public java.io.InputStream getStream(java.lang.String s)
Converts a String to a ByteArrayInputStream, updating the response headers in preparation to sending the data.
Parameters:
s - String to be converted
Returns:
InputStream reference to the new stream

isType

public boolean isType(KomData ht,
                      java.lang.String type)
Checks if an object is of a certain type
Parameters:
ht - Object data
type - Type string
Returns:
true if type is a substring of any "Ptype" attribute of the object

transbody

public static java.lang.String transbody(java.lang.String body)
Translates special characters in a string, usually a plain message text, to HTML entities. Also renders cited text (lines that start with a '>' character) in a different colour, to make the new material stand out.
Parameters:
body - String to be translated
Returns:
Translated string - HTML-safe

wrap

static java.lang.String wrap(java.lang.String text,
                             boolean cr_and_lf)
Tries to wrap long lines into shorter lines.
Parameters:
text - String containing one or more lines
cr_and_lf - If true, use CRLF for end of line, otherwise just LF
Returns:
Possibly re-formatted text with no line longer than LINE_CUTOFF+ LINE_FUDGE

ispunct

static final boolean ispunct(char c)
Checks for "punctuation" characters
Parameters:
c - Character
Returns:
true if c is regarded as a punctuation character

dispMailMessage

java.lang.String dispMailMessage(java.lang.String bodyref,
                                 KomData ht,
                                 java.lang.StringBuffer sb)
Displays an email message.
Parameters:
bodyref - Reference to message
ht - Internal (KOMmsg) representation of message
sb - StringBuffer where message text will be appended
Returns:
message text String, suitable to be used for citation

showMailMessage

public java.lang.String showMailMessage(javax.mail.internet.MimeMessage msg,
                                        java.lang.StringBuffer sb)
Displays a message in the current buffer
Parameters:
msg - MimeMessage object
sb - String buffer to update
Returns:
Text of message, without headers.

getMsgParts

java.util.Vector getMsgParts(KomData obj)

getMsgText

java.lang.String getMsgText(javax.mail.internet.MimePart part,
                            int pn)
Gets the text of the n-th part of a multipart.
Parameters:
part - MimePart
pn - Part #
Returns:
Text of the part (if a text/sometype)

getTextPart

java.lang.String getTextPart(KomData obj)

mimeMessage

javax.mail.internet.MimeMessage mimeMessage(java.lang.String id,
                                            java.lang.String part,
                                            java.io.File f)
Creates a MimeMessage object from database data
Parameters:
id - Base ref for message
part - E g "text" for the full message text
f - If defined, retrieve data from this file
Returns:
A MimeMessage object, or null

mimeMessageStream

java.io.InputStream mimeMessageStream(java.lang.String id,
                                      java.lang.String part,
                                      java.io.File f)
Gets an InputStream for a message from database data
Parameters:
id - Base ref for message
part - E g "text" for the full message text
f - If defined, retrieve data from this file
Returns:
InputStream for message, or null

cidReplace

private void cidReplace(java.lang.StringBuffer sb,
                        int pos)
If there is any img src=.../cid:xxx or a href=.../cid:xxx tag in the buffer, the cid:xxx part will be replaced by a local file name. Also for body background=, though that is controversial(?).
Parameters:
sb - StringBuffer
pos - Where substitution may begin

showBody

public void showBody(javax.mail.Part p,
                     java.lang.String level,
                     java.lang.StringBuffer sb,
                     java.lang.String makeTag)
Shows the body (text) of a Message (Part)
Parameters:
p - Part reference
level - String of the form "0[.m[.n...]", example: "2.3" for third part of a Multipart message which is part 2 of the main message.
sb - String buffer to update
makeTag - If it has a value, make a reference tag if relevant

urlexpand

private void urlexpand(java.lang.StringBuffer sb,
                       java.lang.String bt,
                       int pos)
Shows http://url as real link
Parameters:
sb - StringBuffer for appending text
bt - Text
pos - Position in text of "://"

showHeaders

private int showHeaders(javax.mail.Part p,
                        boolean top,
                        java.lang.StringBuffer sb)
Shows the header fields of a Part
Parameters:
p - Part reference
top - true if top level
sb - String buffer to update

showHeader

private void showHeader(java.lang.String name,
                        java.lang.String value,
                        java.lang.StringBuffer sb)
Shows a header line with a String value
Parameters:
name - Header name
value - Header value
sb - String buffer to update

showHeader

private void showHeader(java.lang.String name,
                        javax.mail.Address[] value,
                        java.lang.StringBuffer sb)
Shows a header line with an Address[] value
Parameters:
name - Header name
value - Header value
sb - String buffer to update

addrToLocal

public KomData addrToLocal(javax.mail.internet.InternetAddress a)
Converts an Address to a local reference, or leaves it as is
Parameters:
a - javax.mail.InternetAddress
Returns:
KomData with Pself, Pemail, and Cname

findlocal

public KomData findlocal(java.lang.String email)
Finds a local recipient
Parameters:
email - E-mail address
Returns:
KomData for recipient, or null

showMultipart

public void showMultipart(javax.mail.Part pp,
                          javax.mail.Multipart b,
                          java.lang.String level,
                          java.lang.StringBuffer sb)
Shows a Multipart
Parameters:
pp - Part reference
b - Multipart body
level - String of the form "0[.m[.n...]", example: "2.3" for third part of a Multipart message which is part 2 of the main message.
sb - String buffer to update

contType

public static final java.lang.String contType(javax.mail.Part p,
                                              java.lang.String dflt,
                                              int part)
Gets the primary or secondary type of a MIME part
Parameters:
p - Part
dflt - Default subtype value
part - 1 for first part, 2 for second part
Returns:
Lowercase value of main type or subtype (Should really return a String[2]...)

showMessage

public void showMessage(javax.mail.Message msg,
                        java.lang.String level,
                        java.lang.StringBuffer sb)
Shows an embedded Message
Parameters:
msg - Message
level - String of the form "0[.m[.n...]", example: "2.3" for third part of a Multipart message which is part 2 of the main message.
sb - String buffer to update

showInputStream

public void showInputStream(javax.mail.Part p,
                            java.io.InputStream b,
                            java.lang.StringBuffer sb,
                            java.lang.String makeTag,
                            java.lang.String level)
Shows a general simple body (InputStream of data)
Parameters:
p - Part reference
b - InputStream representing the body
sb - String buffer to update
makeTag - If it has a value, make a reference tag if relevant
level - String of the form "0[.m[.n...]", example: "2.3" for third part of a Multipart message which is part 2 of the main message.

setCids

public void setCids(java.lang.String cid,
                    java.lang.String pid,
                    java.lang.String partName)
Updates cidCurr table of Content-Id and/or Content-Location references and also the table in the current object. Either Content-Id or Content-Location may be used in the actual html code to refer to the part denoted by partName.
Parameters:
cid - Content-Id value
pid - Content-Location value
partName - (File) name (url) to go with either.

a

public java.lang.String a(java.lang.String ref,
                          java.lang.String link)
Constructs an HTML link
Parameters:
ref - URL
link - Link text
Returns:
"<a href=ref>link</a>", or if ref == null, just "link", followed by new line

mkdate

public java.lang.String mkdate(java.lang.String longdate,
                               java.lang.String format)
Makes a formatted date/time of a time in decimal form
Parameters:
longdate - Date and time in internal form, string representation, seconds since epoch start
format - Code for time format: "m" for standard mail format, "sm" for short mail format, empty for default format.
Returns:
Date and time, example: "Thu Feb 11 16:18 1999" ("Thu, 11 Feb 1999 16:18:00 +0100" if standard mail format).

mkdate

public java.lang.String mkdate(java.lang.String longdate)
Makes a formatted date/time of a time in decimal form
Parameters:
longdate - Date and time in internal form, string representation, seconds since epoch start
Returns:
Date and time, example: "Thu Feb 11 16:18 1999"

mailDate

public java.lang.String mailDate(java.util.Date d,
                                 java.lang.String fmt)
Formats Date like "Wed, 7 Oct 1998 13:02:20 +0200" (standard e-mail format)
Parameters:
d - Date to be formatted
fmt - Format code

mailDate

public java.lang.String mailDate(java.util.Date d)
Formats a Date according to standard mail date format.
Parameters:
d - Date
Returns:
Formatted String representing the Date info

isValidEmailAddress

public boolean isValidEmailAddress(java.lang.String a)
Attempts to check a purported e-mail address string for validity
Parameters:
a - An e-mail address string, if valid
Returns:
true if the string passes the test.

decodeText

java.lang.String decodeText(java.lang.String s)
Decodes strings encoded according to RFC 2047. Tries to handle even strings that do not exactly conform, but are often produced by e-mail and news clients.
Parameters:
s - String with possible encoding (=?ISO-xxx ... =)

getSimpleFileName

public java.lang.String getSimpleFileName(javax.mail.Part p)
Gets a filename for a (Message) Part, with directory information stripped. The name is converted to HTML-safe form
Returns:
HTML-safe form of simple file name, or null

getSimpleFileName

public java.lang.String getSimpleFileName(java.lang.String fn)
Strips directory information from a file path The name is converted to HTML-safe form
Parameters:
fn - File path
Returns:
HTML-safe form of simple file name, or null

toString

java.lang.String toString(java.io.InputStream inp)
Creates a String from an InputStream
Parameters:
inp - InputStream
Returns:
String containing all the data from the InputStream

equal

public static final boolean equal(java.lang.String s1,
                                  java.lang.String s2)
Compares strings, null-safe
Parameters:
s1 - First String
s2 - Second String
Returns:
true if both are non-null and s1.equals(s2)

parseArglist

final void parseArglist(java.lang.String sep)
Parses arglist into argtab.
Parameters:
sep - Argument separator

parseArgs

java.util.Hashtable parseArgs(java.lang.String list,
                              java.lang.String sep)
Parses a String into key[=value] parts and places those in a Hashtable. If there is no '=' sign, set value = "".
Parameters:
list - String of key=value or just key, separated by sep
sep - Delimiter between keys or key=value pairs.
Returns:
Hashtable containing key/value pairs (value == "" if not given)

noQuote

static java.lang.String noQuote(java.lang.String s)
Replaces any quote (") char by ".
Parameters:
s - String
Returns:
Same string, or the string with all "-s replaced