info.aduna.gee.publication.servlets
Class ServiceServlet

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by info.aduna.gee.publication.servlets.ServiceServlet
All Implemented Interfaces:
FileNames, LocalNames, Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

public class ServiceServlet
extends javax.servlet.http.HttpServlet
implements LocalNames, FileNames

ServiceServlet handles all requests for Zpad Owner Services.

See Also:
Serialized Form

Field Summary
protected  Properties _aliasToService
          For some services it is handy to have aliases for them.
protected  ExpiringCache _emailPasswordQuota
           
protected static long _lastTimeUserNameGenerated
           
protected  Properties _methodToConf
          zpad.conf contains names for methods, map method names to these names.
protected  Properties _methodToImage
          For "ownerServices", each method should have its own visual identifier.
 
Fields inherited from interface info.aduna.gee.publication.servlets.LocalNames
ADDED, ALL_CLABELS, ANY_COVER_OPTION, CLABEL, CLABELS, DELETE, DELETED, EMAIL_SUBJECT, IS_ALIAS_FOR, LABEL_CART, LABEL_PRODUCT_CONFIGURATOR, MODIFY, OPTION, OPTIONLIST, OPTIONVALUE, PRODUCT, SERVICE_ADD_ALIAS, SERVICE_CATEGORIES, SERVICE_CHANGE_COVER, SERVICE_FIND_ZPAD, SERVICE_REMOVE_ALIAS, SERVICE_REMOVE_FILE, SERVICE_REMOVE_IMAGE, SERVICE_SEARCHENGINES_INFO, SERVICE_STATISTICS, SERVICE_UPLOAD_FILE, SERVICE_UPLOAD_IMAGE, SUBSCRIPTION, SUBSCRIPTIONS, UPDATED, ZPAD_LOGINS, ZPAD_VISITS
 
Fields inherited from interface info.aduna.gee.publication.net.FileNames
ASA_FILE_NAME, BAK_FILE_NAME, CAT_FILE_NAME, CFG_FILE_NAME, CHS_FILE_NAME, DAT_FILE_NAME, HLP_FILE_NAME, LOCAL_FILE_PREFIX, SBS_FILE_NAME, SSS_FILE_NAME, WIF_FILE_NAME
 
Constructor Summary
ServiceServlet()
           
 
Method Summary
protected  boolean _authorizedForService(String host, String username, String storename, String password, String methodName)
          Check whether a service is available for someone.
protected  String _doChangeCover(javax.servlet.http.HttpServletRequest request, HashMap formData, HashMap stubsMap, String storename, String password)
          Used by changeCover and by joinCustomized.
protected  String _doJoin(javax.servlet.http.HttpServletRequest request, HashMap formData, HashMap stubsMap, String username, String email, boolean checkEmail, String password, int timeToLive)
          Does the real join.
protected  String _doSetCategories(javax.servlet.http.HttpServletRequest request, HashMap formData, HashMap stubsMap, String storename, String password)
          used by setCategories and joinCustomized
protected  String _getCoverOptions(javax.servlet.http.HttpServletRequest request, UserInfo userInfo, boolean addAnyOption, String cover)
          Get a categories dependent list of Covers (HTML format).
protected  void _getFindUsersReplyStubs(javax.servlet.http.HttpServletRequest request, HashMap stubsMap)
          Since findUsers can be fine-tuned by a queryString, we have a shared method to handle it.
protected  int _getTotalSize(javax.servlet.http.HttpServletRequest request, UserInfo userInfo)
           
protected  boolean _isServiceAvailable(String host, String methodName, boolean realOwner, boolean associatedOwner)
          Check whether a service is available for a realOwner or associatedOwner.
protected  String _upload(javax.servlet.http.HttpServletRequest request, HashMap formData, HashMap stubsMap, String objectType)
           
 String addAlias(javax.servlet.http.HttpServletRequest request, HashMap formData, HashMap stubsMap)
           
 String changeCover(javax.servlet.http.HttpServletRequest request, HashMap formData, HashMap stubsMap)
           
 String changeCustomized(javax.servlet.http.HttpServletRequest request, HashMap formData, HashMap stubsMap)
          changeCustomized set both the Categories and the Cover.
 String changeEmail(javax.servlet.http.HttpServletRequest request, HashMap formData, HashMap stubsMap)
           
 String changePassword(javax.servlet.http.HttpServletRequest request, HashMap formData, HashMap stubsMap)
           
 String checkjoin(javax.servlet.http.HttpServletRequest request, HashMap formData, HashMap stubsMap)
           
 String create(javax.servlet.http.HttpServletRequest request, HashMap formData, HashMap stubsMap)
          This is the api's join.
 String delAlias(javax.servlet.http.HttpServletRequest request, HashMap formData, HashMap stubsMap)
           
 void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
           
 void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
           
 String emailPassword(javax.servlet.http.HttpServletRequest request, HashMap formData, HashMap stubsMap)
           
 String findUsers(javax.servlet.http.HttpServletRequest request, HashMap formData, HashMap stubsMap)
          Note: this function is used as /findUsers too.
static String generatePassword(String host)
          Generate a password.
static String generateUserName(String host)
          Generate a unique username.
 String getOwnerService(javax.servlet.http.HttpServletRequest request, HashMap formData, HashMap stubsMap)
           
 String getOwnerServices(javax.servlet.http.HttpServletRequest request, HashMap formData, HashMap stubsMap)
           
 String getServletInfo()
           
 void init(javax.servlet.ServletConfig config)
           
 String join(javax.servlet.http.HttpServletRequest request, HashMap formData, HashMap stubsMap)
           
 String joinCustomized(javax.servlet.http.HttpServletRequest request, HashMap formData, HashMap stubsMap)
           
 String removeFile(javax.servlet.http.HttpServletRequest request, HashMap formData, HashMap stubsMap)
           
 String searchEngines(javax.servlet.http.HttpServletRequest request, HashMap formData, HashMap stubsMap)
           
 String setCategories(javax.servlet.http.HttpServletRequest request, HashMap formData, HashMap stubsMap)
          setCategories is the method as used from within the Owner Services.
 String toString()
           
 String unjoin(javax.servlet.http.HttpServletRequest request, HashMap formData, HashMap stubsMap)
           
 String uploadFile(javax.servlet.http.HttpServletRequest request, HashMap formData, HashMap stubsMap)
           
 String uploadFile2(javax.servlet.http.HttpServletRequest request, HashMap formData, HashMap stubsMap)
           
 String uploadImage(javax.servlet.http.HttpServletRequest request, HashMap formData, HashMap stubsMap)
           
 String uploadImage2(javax.servlet.http.HttpServletRequest request, HashMap formData, HashMap stubsMap)
           
 String userIndex(javax.servlet.http.HttpServletRequest request, HashMap formData, HashMap stubsMap)
          Note: this function is used as /userIndex only.
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, service
 
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletName, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_emailPasswordQuota

protected ExpiringCache _emailPasswordQuota

_methodToConf

protected Properties _methodToConf
zpad.conf contains names for methods, map method names to these names.


_methodToImage

protected Properties _methodToImage
For "ownerServices", each method should have its own visual identifier.


_aliasToService

protected Properties _aliasToService
For some services it is handy to have aliases for them.


_lastTimeUserNameGenerated

protected static long _lastTimeUserNameGenerated
Constructor Detail

ServiceServlet

public ServiceServlet()
Method Detail

init

public void init(javax.servlet.ServletConfig config)
          throws javax.servlet.ServletException
Specified by:
init in interface javax.servlet.Servlet
Overrides:
init in class javax.servlet.GenericServlet
Throws:
javax.servlet.ServletException

getServletInfo

public String getServletInfo()
Specified by:
getServletInfo in interface javax.servlet.Servlet
Overrides:
getServletInfo in class javax.servlet.GenericServlet

doPost

public void doPost(javax.servlet.http.HttpServletRequest request,
                   javax.servlet.http.HttpServletResponse response)
            throws javax.servlet.ServletException,
                   IOException
Overrides:
doPost in class javax.servlet.http.HttpServlet
Throws:
javax.servlet.ServletException
IOException

doGet

public void doGet(javax.servlet.http.HttpServletRequest request,
                  javax.servlet.http.HttpServletResponse response)
           throws javax.servlet.ServletException,
                  IOException
Overrides:
doGet in class javax.servlet.http.HttpServlet
Throws:
javax.servlet.ServletException
IOException

getOwnerServices

public String getOwnerServices(javax.servlet.http.HttpServletRequest request,
                               HashMap formData,
                               HashMap stubsMap)

_authorizedForService

protected boolean _authorizedForService(String host,
                                        String username,
                                        String storename,
                                        String password,
                                        String methodName)
Check whether a service is available for someone. This function can NOT be used for passwords "as-is".


_isServiceAvailable

protected boolean _isServiceAvailable(String host,
                                      String methodName,
                                      boolean realOwner,
                                      boolean associatedOwner)
Check whether a service is available for a realOwner or associatedOwner.


getOwnerService

public String getOwnerService(javax.servlet.http.HttpServletRequest request,
                              HashMap formData,
                              HashMap stubsMap)

findUsers

public String findUsers(javax.servlet.http.HttpServletRequest request,
                        HashMap formData,
                        HashMap stubsMap)
                 throws IOException
Note: this function is used as /findUsers too.

Throws:
IOException

userIndex

public String userIndex(javax.servlet.http.HttpServletRequest request,
                        HashMap formData,
                        HashMap stubsMap)
                 throws IOException
Note: this function is used as /userIndex only. It generates an ugly list of all users, pointing to each user's ZpadIndex.html.

Throws:
IOException

emailPassword

public String emailPassword(javax.servlet.http.HttpServletRequest request,
                            HashMap formData,
                            HashMap stubsMap)
                     throws IOException
Throws:
IOException

checkjoin

public String checkjoin(javax.servlet.http.HttpServletRequest request,
                        HashMap formData,
                        HashMap stubsMap)
                 throws FileNotFoundException,
                        IOException
Throws:
FileNotFoundException
IOException

join

public String join(javax.servlet.http.HttpServletRequest request,
                   HashMap formData,
                   HashMap stubsMap)
            throws FileNotFoundException,
                   IOException
Throws:
FileNotFoundException
IOException

create

public String create(javax.servlet.http.HttpServletRequest request,
                     HashMap formData,
                     HashMap stubsMap)
              throws FileNotFoundException,
                     IOException
This is the api's join.

Throws:
FileNotFoundException
IOException

_doJoin

protected String _doJoin(javax.servlet.http.HttpServletRequest request,
                         HashMap formData,
                         HashMap stubsMap,
                         String username,
                         String email,
                         boolean checkEmail,
                         String password,
                         int timeToLive)
                  throws FileNotFoundException,
                         IOException
Does the real join.

Throws:
FileNotFoundException
IOException

generatePassword

public static String generatePassword(String host)
Generate a password.


generateUserName

public static String generateUserName(String host)
Generate a unique username.


unjoin

public String unjoin(javax.servlet.http.HttpServletRequest request,
                     HashMap formData,
                     HashMap stubsMap)
              throws IOException
Throws:
IOException

addAlias

public String addAlias(javax.servlet.http.HttpServletRequest request,
                       HashMap formData,
                       HashMap stubsMap)

delAlias

public String delAlias(javax.servlet.http.HttpServletRequest request,
                       HashMap formData,
                       HashMap stubsMap)

changeCover

public String changeCover(javax.servlet.http.HttpServletRequest request,
                          HashMap formData,
                          HashMap stubsMap)

_doChangeCover

protected String _doChangeCover(javax.servlet.http.HttpServletRequest request,
                                HashMap formData,
                                HashMap stubsMap,
                                String storename,
                                String password)
Used by changeCover and by joinCustomized.


changePassword

public String changePassword(javax.servlet.http.HttpServletRequest request,
                             HashMap formData,
                             HashMap stubsMap)
                      throws IOException
Throws:
IOException

changeEmail

public String changeEmail(javax.servlet.http.HttpServletRequest request,
                          HashMap formData,
                          HashMap stubsMap)
                   throws IOException
Throws:
IOException

searchEngines

public String searchEngines(javax.servlet.http.HttpServletRequest request,
                            HashMap formData,
                            HashMap stubsMap)
                     throws IOException
Throws:
IOException

removeFile

public String removeFile(javax.servlet.http.HttpServletRequest request,
                         HashMap formData,
                         HashMap stubsMap)

setCategories

public String setCategories(javax.servlet.http.HttpServletRequest request,
                            HashMap formData,
                            HashMap stubsMap)
setCategories is the method as used from within the Owner Services.


_doSetCategories

protected String _doSetCategories(javax.servlet.http.HttpServletRequest request,
                                  HashMap formData,
                                  HashMap stubsMap,
                                  String storename,
                                  String password)
used by setCategories and joinCustomized


uploadFile2

public String uploadFile2(javax.servlet.http.HttpServletRequest request,
                          HashMap formData,
                          HashMap stubsMap)
                   throws IOException
Throws:
IOException

uploadFile

public String uploadFile(javax.servlet.http.HttpServletRequest request,
                         HashMap formData,
                         HashMap stubsMap)
                  throws IOException
Throws:
IOException

uploadImage2

public String uploadImage2(javax.servlet.http.HttpServletRequest request,
                           HashMap formData,
                           HashMap stubsMap)
                    throws IOException
Throws:
IOException

uploadImage

public String uploadImage(javax.servlet.http.HttpServletRequest request,
                          HashMap formData,
                          HashMap stubsMap)
                   throws IOException
Throws:
IOException

_upload

protected String _upload(javax.servlet.http.HttpServletRequest request,
                         HashMap formData,
                         HashMap stubsMap,
                         String objectType)
                  throws IOException
Throws:
IOException

toString

public String toString()
Overrides:
toString in class Object

_getTotalSize

protected int _getTotalSize(javax.servlet.http.HttpServletRequest request,
                            UserInfo userInfo)

_getCoverOptions

protected String _getCoverOptions(javax.servlet.http.HttpServletRequest request,
                                  UserInfo userInfo,
                                  boolean addAnyOption,
                                  String cover)
Get a categories dependent list of Covers (HTML format).

Parameters:
request - the request
userInfo - a user info OR null
addAnyOption - if true, insert "Any Cover" at the top of the list.
cover - a preferred cover OR null

changeCustomized

public String changeCustomized(javax.servlet.http.HttpServletRequest request,
                               HashMap formData,
                               HashMap stubsMap)
changeCustomized set both the Categories and the Cover.


joinCustomized

public String joinCustomized(javax.servlet.http.HttpServletRequest request,
                             HashMap formData,
                             HashMap stubsMap)
                      throws FileNotFoundException,
                             IOException
Throws:
FileNotFoundException
IOException

_getFindUsersReplyStubs

protected void _getFindUsersReplyStubs(javax.servlet.http.HttpServletRequest request,
                                       HashMap stubsMap)
Since findUsers can be fine-tuned by a queryString, we have a shared method to handle it.



Copyright © 1997-2008 Aduna. All Rights Reserved.