taylor 2002/09/20 10:38:08 Modified: src/java/org/apache/jetspeed/om/dbpsml JetspeedGroupProfilePeer.java JetspeedRoleProfilePeer.java JetspeedUserProfilePeer.java src/java/org/apache/jetspeed/services/psmlmanager/db DatabasePsmlManagerService.java Added: src/java/org/apache/jetspeed/services/psmlmanager/db DatabasePsmlManager.java Log: Added interface for DB PSML Manager. This is necessary for a delegating PSML that I wrote, which stores some of its PSML resources in the webapp, and others in the database. Revision Changes Path 1.8 +25 -25 jakarta-jetspeed/src/java/org/apache/jetspeed/om/dbpsml/JetspeedGroupProfilePeer.java Index: JetspeedGroupProfilePeer.java =================================================================== RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/om/dbpsml/JetspeedGroupProfilePeer.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- JetspeedGroupProfilePeer.java 12 Sep 2002 13:38:00 -0000 1.7 +++ JetspeedGroupProfilePeer.java 20 Sep 2002 17:38:07 -0000 1.8 @@ -20,11 +20,11 @@ import org.apache.jetspeed.om.profile.ProfileLocator; import org.apache.jetspeed.services.psmlmanager.db.DBOperations; import org.apache.jetspeed.services.psmlmanager.db.DBUtils; -import org.apache.jetspeed.services.psmlmanager.db.DatabasePsmlManagerService; +import org.apache.jetspeed.services.psmlmanager.db.DatabasePsmlManager; import org.apache.jetspeed.services.PsmlManager; import org.apache.jetspeed.services.Profiler; -/** +/** * The skeleton for this class was autogenerated by Torque on: * * [Mon Sep 10 13:30:53 PDT 2001] @@ -34,19 +34,19 @@ * long as it does not already exist in the output directory. * * @author <a href="mailto:[EMAIL PROTECTED]">Atul Dambalkar</a> - * @version $Id$ + * @version $Id$ */ -public class JetspeedGroupProfilePeer +public class JetspeedGroupProfilePeer extends org.apache.jetspeed.om.dbpsml.BaseJetspeedGroupProfilePeer implements DBOperations { - + /** * Default constructor. */ public JetspeedGroupProfilePeer() {} - - + + /** * Insert a group profile record in the database table. * @@ -74,7 +74,7 @@ throws Exception { JetspeedGroupProfile groupProfile = new JetspeedGroupProfile(); - DatabasePsmlManagerService service = (DatabasePsmlManagerService)PsmlManager.getService(); + DatabasePsmlManager service = (DatabasePsmlManager)PsmlManager.getService(); groupProfile.setGroupName(profile.getGroup().getName()); groupProfile.setMediaType(profile.getMediaType()); @@ -93,28 +93,28 @@ groupProfile.setProfile(DBUtils.portletsToBytes( profile.getDocument().getPortlets(), service.getMapping())); - if (operation == INSERT) + if (operation == INSERT) { super.doInsert(groupProfile, connection); } - else if (operation == UPDATE) + else if (operation == UPDATE) { Criteria values = buildCriteria(groupProfile); Criteria select = buildCriteria(groupProfile); select.remove(PROFILE); - BasePeer.doUpdate( select, values, connection ); + BasePeer.doUpdate( select, values, connection ); } } /** * Delete group profile record from the database table. - * + * * @param profile Profile object that will be deleted from the database * @param connection A database connection to use - */ + */ public void delete(ProfileLocator locator, DBConnection connection) throws Exception - { + { super.doDelete(buildCriteria(locator), connection); } @@ -154,16 +154,16 @@ return super.doSelect(criteria, connection); } - /** + /** * Delete all records from the database table for a group. - * + * * @param group Group object for which all the records will be deleted from the database * @param connection A database connection to use - */ + */ public void delete(Group group, DBConnection connection) throws Exception - { + { Criteria criteria = new Criteria(); - + criteria.add(GROUP_NAME, group.getName()); super.doDelete(criteria, connection); @@ -189,27 +189,27 @@ groupName = group.getName(); } - if (groupName != null && groupName.length() > 0) + if (groupName != null && groupName.length() > 0) { criteria.add(GROUP_NAME, groupName); } - if (pageName != null && pageName.length() > 0) + if (pageName != null && pageName.length() > 0) { criteria.add(PAGE, pageName); } - - if (mediaType != null && mediaType.length() > 0) + + if (mediaType != null && mediaType.length() > 0) { criteria.add(MEDIA_TYPE, locator.getMediaType()); } - if (language != null && language.length() > 0) + if (language != null && language.length() > 0) { criteria.add(LANGUAGE, locator.getLanguage()); } - if (country != null && country.length() > 0) + if (country != null && country.length() > 0) { criteria.add(COUNTRY, locator.getCountry()); } 1.8 +39 -39 jakarta-jetspeed/src/java/org/apache/jetspeed/om/dbpsml/JetspeedRoleProfilePeer.java Index: JetspeedRoleProfilePeer.java =================================================================== RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/om/dbpsml/JetspeedRoleProfilePeer.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- JetspeedRoleProfilePeer.java 12 Sep 2002 13:38:00 -0000 1.7 +++ JetspeedRoleProfilePeer.java 20 Sep 2002 17:38:07 -0000 1.8 @@ -21,11 +21,11 @@ import org.apache.jetspeed.om.profile.ProfileLocator; import org.apache.jetspeed.services.psmlmanager.db.DBOperations; import org.apache.jetspeed.services.psmlmanager.db.DBUtils; -import org.apache.jetspeed.services.psmlmanager.db.DatabasePsmlManagerService; +import org.apache.jetspeed.services.psmlmanager.db.DatabasePsmlManager; import org.apache.jetspeed.services.PsmlManager; import org.apache.jetspeed.services.Profiler; -/** +/** * The skeleton for this class was autogenerated by Torque on: * * [Mon Sep 10 13:30:53 PDT 2001] @@ -35,22 +35,22 @@ * long as it does not already exist in the output directory. * * @author <a href="mailto:[EMAIL PROTECTED]">Atul Dambalkar</a> - * @version $Id$ + * @version $Id$ */ -public class JetspeedRoleProfilePeer +public class JetspeedRoleProfilePeer extends org.apache.jetspeed.om.dbpsml.BaseJetspeedRoleProfilePeer implements DBOperations { - - /** - * Default constructor. - */ - public JetspeedRoleProfilePeer() {} - - - /** + + /** + * Default constructor. + */ + public JetspeedRoleProfilePeer() {} + + + /** * Insert a role profile record in the database table. - * + * * @param profile Profile object that will be inserted in the database * @param connection A database connection to use */ @@ -75,12 +75,12 @@ throws Exception { JetspeedRoleProfile roleProfile = new JetspeedRoleProfile(); - DatabasePsmlManagerService service = (DatabasePsmlManagerService)PsmlManager.getService(); - + DatabasePsmlManager service = (DatabasePsmlManager)PsmlManager.getService(); + roleProfile.setRoleName(profile.getRole().getName()); - roleProfile.setMediaType(profile.getMediaType()); - roleProfile.setLanguage(profile.getLanguage()); - roleProfile.setCountry(profile.getCountry()); + roleProfile.setMediaType(profile.getMediaType()); + roleProfile.setLanguage(profile.getLanguage()); + roleProfile.setCountry(profile.getCountry()); String name = profile.getName(); if (name == null || name.equals("")) { @@ -103,20 +103,20 @@ Criteria values = buildCriteria(roleProfile); Criteria select = buildCriteria(roleProfile); select.remove(PROFILE); - BasePeer.doUpdate( select, values, connection ); + BasePeer.doUpdate( select, values, connection ); } - } - - /** - * Delete role profile record from the database table. - * + } + + /** + * Delete role profile record from the database table. + * * @param profile Profile object that will be deleted from the database * @param connection A database connection to use - */ + */ public void delete(ProfileLocator locator, DBConnection connection) throws Exception - { - super.doDelete(buildCriteria(locator), connection); - } + { + super.doDelete(buildCriteria(locator), connection); + } /** * Select role profile record from the database table for the given @@ -144,7 +144,7 @@ public Vector selectOrdered(ProfileLocator locator, DBConnection connection) throws Exception { Criteria criteria = buildCriteria(locator); - + criteria.addAscendingOrderByColumn(ROLE_NAME); criteria.addAscendingOrderByColumn(MEDIA_TYPE); criteria.addAscendingOrderByColumn(LANGUAGE); @@ -154,16 +154,16 @@ return super.doSelect(criteria, connection); } - /** + /** * Delete all records from the database table for a role. - * + * * @param role Role object for which all the records will be deleted from the database * @param connection A database connection to use - */ + */ public void delete(Role role, DBConnection connection) throws Exception - { + { Criteria criteria = new Criteria(); - + criteria.add(ROLE_NAME, role.getName()); super.doDelete(criteria, connection); @@ -187,27 +187,27 @@ roleName = role.getName(); } - if (roleName != null && roleName.length() > 0) + if (roleName != null && roleName.length() > 0) { criteria.add(ROLE_NAME, roleName); } - if (pageName != null && pageName.length() > 0) + if (pageName != null && pageName.length() > 0) { criteria.add(PAGE, pageName); } - if (mediaType != null && mediaType.length() > 0) + if (mediaType != null && mediaType.length() > 0) { criteria.add(MEDIA_TYPE, locator.getMediaType()); } - if (language != null && language.length() > 0) + if (language != null && language.length() > 0) { criteria.add(LANGUAGE, locator.getLanguage()); } - if (country != null && country.length() > 0) + if (country != null && country.length() > 0) { criteria.add(COUNTRY, locator.getCountry()); } 1.9 +38 -38 jakarta-jetspeed/src/java/org/apache/jetspeed/om/dbpsml/JetspeedUserProfilePeer.java Index: JetspeedUserProfilePeer.java =================================================================== RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/om/dbpsml/JetspeedUserProfilePeer.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- JetspeedUserProfilePeer.java 12 Sep 2002 13:38:00 -0000 1.8 +++ JetspeedUserProfilePeer.java 20 Sep 2002 17:38:07 -0000 1.9 @@ -29,10 +29,10 @@ import org.apache.jetspeed.om.profile.ProfileLocator; import org.apache.jetspeed.services.psmlmanager.db.DBOperations; import org.apache.jetspeed.services.psmlmanager.db.DBUtils; -import org.apache.jetspeed.services.psmlmanager.db.DatabasePsmlManagerService; +import org.apache.jetspeed.services.psmlmanager.db.DatabasePsmlManager; import org.apache.jetspeed.services.PsmlManager; -/** +/** * The skeleton for this class was autogenerated by Torque on: * * [Mon Sep 10 13:30:53 PDT 2001] @@ -42,18 +42,18 @@ * long as it does not already exist in the output directory. * * @author <a href="mailto:[EMAIL PROTECTED]">Atul Dambalkar</a> - * @version $Id$ + * @version $Id$ */ -public class JetspeedUserProfilePeer - extends org.apache.jetspeed.om.dbpsml.BaseJetspeedUserProfilePeer +public class JetspeedUserProfilePeer + extends org.apache.jetspeed.om.dbpsml.BaseJetspeedUserProfilePeer implements DBOperations { /** - * Default constructor. + * Default constructor. */ public JetspeedUserProfilePeer() {} - + /** * Insert a user profile record in the database table. @@ -64,7 +64,7 @@ public void insert(Profile profile, DBConnection connection) throws Exception { doInsertOrUpdate(profile, INSERT, connection); - } + } /** * Insert a user profile record in the database table. @@ -75,13 +75,13 @@ public void update(Profile profile, DBConnection connection) throws Exception { doInsertOrUpdate(profile, UPDATE, connection); - } + } - private void doInsertOrUpdate(Profile profile, int operation, DBConnection connection) - throws Exception + private void doInsertOrUpdate(Profile profile, int operation, DBConnection connection) + throws Exception { JetspeedUserProfile userProfile = new JetspeedUserProfile(); - DatabasePsmlManagerService service = (DatabasePsmlManagerService)PsmlManager.getService(); + DatabasePsmlManager service = (DatabasePsmlManager)PsmlManager.getService(); userProfile.setUserName(profile.getUser().getUserName()); userProfile.setMediaType(profile.getMediaType()); @@ -100,29 +100,29 @@ userProfile.setPage(profile.getName()); userProfile.setProfile(DBUtils.portletsToBytes( profile.getDocument().getPortlets(), service.getMapping())); - - if (operation == INSERT) + + if (operation == INSERT) { super.doInsert(userProfile, connection); - } - else if (operation == UPDATE) + } + else if (operation == UPDATE) { Criteria values = buildCriteria(userProfile); Criteria select = buildCriteria(userProfile); select.remove(PROFILE); BasePeer.doUpdate( select, values, connection ); - } - } - - - /** + } + } + + + /** * Delete user profile record from the database table. - * + * * @param profile Profile object that will be deleted from the database * @param connection A database connection to use - */ + */ public void delete(ProfileLocator locator, DBConnection connection) throws Exception - { + { super.doDelete(buildCriteria(locator), connection); } @@ -138,7 +138,7 @@ public Vector select(ProfileLocator locator, DBConnection connection) throws Exception { Criteria criteria = buildCriteria(locator); - return super.doSelect(criteria, connection); // buildCriteria(locator)); + return super.doSelect(criteria, connection); // buildCriteria(locator)); } /** @@ -160,22 +160,22 @@ criteria.addAscendingOrderByColumn(COUNTRY); criteria.addAscendingOrderByColumn(PAGE); - return super.doSelect(criteria, connection); + return super.doSelect(criteria, connection); } - /** + /** * Delete all records from the database table for a user. - * + * * @param user User object for which all the records will be deleted from the database * @param connection A database connection to use - */ + */ public void delete(JetspeedUser user, DBConnection connection) throws Exception - { - Criteria criteria = new Criteria(); + { + Criteria criteria = new Criteria(); criteria.add(USER_NAME, user.getUserName()); - + super.doDelete(criteria, connection); } @@ -186,7 +186,7 @@ protected Criteria buildCriteria(ProfileLocator locator) { Criteria criteria = new Criteria(); - + String mediaType = locator.getMediaType(); String language = locator.getLanguage(); String country = locator.getCountry(); @@ -198,27 +198,27 @@ userName = user.getUserName(); } - if (userName != null && userName.length() > 0) + if (userName != null && userName.length() > 0) { criteria.add(USER_NAME, userName) ; } - if (pageName != null && pageName.length() > 0) + if (pageName != null && pageName.length() > 0) { criteria.add(PAGE, pageName); } - if (mediaType != null && mediaType.length() > 0) + if (mediaType != null && mediaType.length() > 0) { criteria.add(MEDIA_TYPE, mediaType); } - if (language != null && language.length() > 0) + if (language != null && language.length() > 0) { criteria.add(LANGUAGE, language); } - if (country != null && country.length() > 0) + if (country != null && country.length() > 0) { criteria.add(COUNTRY, country); } 1.25 +116 -116 jakarta-jetspeed/src/java/org/apache/jetspeed/services/psmlmanager/db/DatabasePsmlManagerService.java Index: DatabasePsmlManagerService.java =================================================================== RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/psmlmanager/db/DatabasePsmlManagerService.java,v retrieving revision 1.24 retrieving revision 1.25 diff -u -r1.24 -r1.25 --- DatabasePsmlManagerService.java 20 Sep 2002 02:00:40 -0000 1.24 +++ DatabasePsmlManagerService.java 20 Sep 2002 17:38:07 -0000 1.25 @@ -51,7 +51,7 @@ * information on the Apache Software Foundation, please see * <http://www.apache.org/>. */ - + package org.apache.jetspeed.services.psmlmanager.db; // PSML Manager Service interface @@ -62,7 +62,7 @@ // Jetspeed Security service import org.apache.jetspeed.services.JetspeedSecurity; -// Profile and ProfileLocator interface +// Profile and ProfileLocator interface import org.apache.jetspeed.om.profile.Profile; import org.apache.jetspeed.om.profile.ProfileLocator; import org.apache.jetspeed.om.profile.BaseProfileLocator; @@ -73,7 +73,7 @@ import org.apache.jetspeed.om.profile.Portlets; import org.apache.jetspeed.om.profile.PSMLDocument; import org.apache.jetspeed.om.profile.BasePSMLDocument; - + //turbine stuff import org.apache.turbine.util.Log; import org.apache.turbine.services.TurbineBaseService; @@ -98,7 +98,7 @@ //Servlet API import javax.servlet.ServletConfig; - + //castor support import org.exolab.castor.xml.MarshalException; import org.exolab.castor.xml.ValidationException; @@ -141,18 +141,18 @@ * * @author <a href="mailto:[EMAIL PROTECTED]">Atul Dambalkar</a> * @author <a href="mailto:[EMAIL PROTECTED]">Medha Vaidya</a> - * @author <a href="mailto:[EMAIL PROTECTED]">David Sean Taylor</a> + * @author <a href="mailto:[EMAIL PROTECTED]">David Sean Taylor</a> * @version $Id$ */ -public class DatabasePsmlManagerService extends TurbineBaseService - implements PsmlManagerService, DBOperations +public class DatabasePsmlManagerService extends TurbineBaseService + implements DatabasePsmlManager { private Map psmlCache = new HashMap(); /** The watcher for the document locations */ private CacheRefresher refresher = null; - + /** the base refresh rate for documents */ private long refreshRate; // default will be 8 hours @@ -175,7 +175,7 @@ String mapFile = null; /** the Castor mapping file name */ private Mapping mapping = null; - + /** The pool name to use for database requests. */ private String poolName = null; @@ -183,7 +183,7 @@ * This is the early initialization method called by the * Turbine <code>Service</code> framework */ - public void init(ServletConfig conf) throws InitializationException + public void init(ServletConfig conf) throws InitializationException { if (getInit()) { @@ -204,7 +204,7 @@ * @exception throws a <code>InitializationException</code> if the service * fails to initialize */ - private void initConfiguration(ServletConfig conf) + private void initConfiguration(ServletConfig conf) throws InitializationException { ResourceService serviceConf = @@ -248,7 +248,7 @@ } catch (Throwable t) { - Log.error(this + ".init:" , t); + Log.error(this + ".init:" , t); throw new InitializationException("Exception initializing DatabasePsmlManagerService" + t); } @@ -261,7 +261,7 @@ /** Late init method from Turbine Service model */ public void init() throws InitializationException - { + { //Mark that we are done setInit(true); /* @@ -281,7 +281,7 @@ throws InitializationException { // test the mapping file and create the mapping object - + if (mapFile != null) { File map = new File(mapFile); @@ -318,21 +318,21 @@ this.refresher.setDone(true); } - + /** * A thread implementation of cache refreshing mechanism for database - * persisted PSMLs. We have to refresh the cache after specific intervals + * persisted PSMLs. We have to refresh the cache after specific intervals * if someone manually updates the PSML database. * * @author <a href="mailto:[EMAIL PROTECTED]">Atul Dambalkar</a> - */ + */ class CacheRefresher extends Thread { private boolean done = false; - + /** * Constructor to to set the priority. - */ + */ CacheRefresher() { setDaemon(true); @@ -341,7 +341,7 @@ /** * We are all done, system is shutting down. - */ + */ void setDone(boolean done) { this.done = done; @@ -349,7 +349,7 @@ /** * Method as needed for a Thread to run - */ + */ public void run() { try @@ -367,14 +367,14 @@ synchronized (this) { Iterator i = psmlCache.keySet().iterator(); - + while(i.hasNext()) { String locator = (String)i.next(); - + // do refresh for the locator - PSMLDocument doc = - refresh(stringToLocator(locator)); + PSMLDocument doc = + refresh(stringToLocator(locator)); // over write the existing document in cache psmlCache.put(locator, doc); @@ -392,16 +392,16 @@ if (Log.getLogger().isDebugEnabled()) Log.debug("DatabasePsmlManagerService.CacheRefresher: recieved interruption, aborting."); } - } + } } - /** + /** * Return a unique string identifying this object. */ private String locatorToString(ProfileLocator locator) { StringBuffer keybuf = new StringBuffer(); - + JetspeedUser user = locator.getUser(); Role role = locator.getRole(); Group group = locator.getGroup(); @@ -409,7 +409,7 @@ String mediaType = locator.getMediaType(); String country = locator.getCountry(); String language = locator.getLanguage(); - + synchronized (this) { if (user != null) @@ -424,7 +424,7 @@ { keybuf.append("Role:").append(role.getName()); } - + if (name != null) { keybuf.append('$').append("Page:").append(name); @@ -449,7 +449,7 @@ return keybuf.toString(); } - private ProfileLocator stringToLocator(String locstr) throws Exception + private ProfileLocator stringToLocator(String locstr) throws Exception { ProfileLocator locator = new BaseProfileLocator(); String entity = null; @@ -462,7 +462,7 @@ { String dollarToken = dollarTokens.nextToken().trim(); - StringTokenizer colonTokens = new StringTokenizer(dollarToken, ":"); + StringTokenizer colonTokens = new StringTokenizer(dollarToken, ":"); String colonToken = colonTokens.nextToken(); if (colonToken.equals("User")) { @@ -502,7 +502,7 @@ } if (Log.getLogger().isDebugEnabled()) Log.debug("DatabasePsmlManagerService: Returning locator for string: " + locatorToString(locator)); - + return locator; } @@ -510,7 +510,7 @@ public PSMLDocument getDocument(String name) { // do nothing, deprecated - Log.warn("*** NOT SUPPORTED: GETDOC FROM DATABASE PSML MANAGER!!!"); + Log.warn("*** NOT SUPPORTED: GETDOC FROM DATABASE PSML MANAGER!!!"); return null; } @@ -521,10 +521,10 @@ return false; } - public boolean saveDocument(PSMLDocument doc) + public boolean saveDocument(PSMLDocument doc) { - // do nothing, will be deprecated - Log.warn("*** NOT SUPPORTED: SAVING DOC FROM DATABASE PSML MANAGER!!!"); + // do nothing, will be deprecated + Log.warn("*** NOT SUPPORTED: SAVING DOC FROM DATABASE PSML MANAGER!!!"); return false; } @@ -532,11 +532,11 @@ /** * Returns a PSML document for the given locator * - * @param locator The locator descriptor(ProfileLocator object) of the + * @param locator The locator descriptor(ProfileLocator object) of the * document to be retrieved. * @return psmldoc The PSMLDocument object */ - public PSMLDocument getDocument(ProfileLocator locator) + public PSMLDocument getDocument(ProfileLocator locator) { // check the cache for the req'e document if not available in cache // get the document from database @@ -560,7 +560,7 @@ // if we have seached and found nothing, this is cached as a null value // so check to see if the key is there inCache = psmlCache.containsKey(locStr); - if (inCache) + if (inCache) { psmldoc = (PSMLDocument)psmlCache.get(locStr); } @@ -568,7 +568,7 @@ // if (Log.getLogger().isDebugEnabled()) // Log.info("DatabasePsmlManagerService.getDocument(): psmlcache: " + // (inCache ? ((psmldoc == null) ? "null present" : "doc present") : "not in cache") + " : " + locStr); - + // if in the cache, doc or null, return what's in the cache if (inCache) { @@ -594,7 +594,7 @@ * @param profile The profile that holds the PSMLDocument. * @return PSMLDocument The PSMLDocument that got created in DB. */ - public PSMLDocument createDocument(Profile profile) + public PSMLDocument createDocument(Profile profile) { return createOrSaveDocument(profile, INSERT); } @@ -604,16 +604,16 @@ * * @param profile The profile that holds the PSMLDocument. * @return PSMLDocument The PSMLDocument that got created in DB. - */ - public boolean store(Profile profile) + */ + public boolean store(Profile profile) { return createOrSaveDocument(profile, UPDATE) != null; } private PSMLDocument createOrSaveDocument(Profile profile, int operation) { - // create record in the database for Portlets for the given - // profile/PSMLDocuemnt,use marsheller to create Portlets + // create record in the database for Portlets for the given + // profile/PSMLDocuemnt,use marsheller to create Portlets // object and then put it in database, update the cache if (profile == null) { @@ -629,12 +629,12 @@ DBConnection dbCon = getDbConnection(); - try + try { if (user != null) - { + { tableName = "JETSPEED_USER_PROFILE"; - if (operation == INSERT) + if (operation == INSERT) { new JetspeedUserProfilePeer().insert(profile, dbCon); } @@ -646,7 +646,7 @@ else if (role != null) { tableName = "JETSPEED_ROLE_PROFILE"; - if (operation == INSERT) + if (operation == INSERT) { new JetspeedRoleProfilePeer().insert(profile, dbCon); } @@ -654,11 +654,11 @@ { new JetspeedRoleProfilePeer().update(profile, dbCon); } - } + } else if (group != null) { tableName = "JETSPEED_GROUP_PROFILE"; - if (operation == INSERT) + if (operation == INSERT) { new JetspeedGroupProfilePeer().insert(profile, dbCon); } @@ -666,8 +666,8 @@ { new JetspeedGroupProfilePeer().update(profile, dbCon); } - } - + } + if (cachingOn) { // insert successful @@ -695,9 +695,9 @@ } - /** + /** * Remove the PSMLDocument/profile for given locator object. - * + * * @param locator The profile locator criteria for profile to be removed. */ public void removeDocument(ProfileLocator locator) @@ -717,24 +717,24 @@ // get a database connection DBConnection dbCon = getDbConnection(); - try - { + try + { if (user != null) - { + { new JetspeedUserProfilePeer().delete(locator, dbCon); tableName = "JETSPEED_USER_PROFILE"; } else if (role != null) - { + { new JetspeedRoleProfilePeer().delete(locator, dbCon); tableName = "JETSPEED_ROLE_PROFILE"; - } + } else if (group != null) { new JetspeedGroupProfilePeer().delete(locator, dbCon); tableName = "JETSPEED_GROUP_PROFILE"; - } - + } + if (cachingOn) { // Delete successful @@ -757,10 +757,10 @@ } } - /** + /** * Query for a collection of profiles given a profile locator criteria. * Use SQL engine to get the required profiles. - * + * * @param locator The profile locator criteria. * @return Iterator object with the PSMLDocuments satisfying query */ @@ -775,19 +775,19 @@ DBConnection dbCon = getDbConnection(); - try - { + try + { Vector userData = null; Vector groupData = null; Vector roleData = null; - + int queryMode = locator.getQueryMode(); - + List list = new ArrayList(); - + switch (queryMode) { - case QueryLocator.QUERY_USER: + case QueryLocator.QUERY_USER: userData = new JetspeedUserProfilePeer().selectOrdered(locator, dbCon); if (userData != null) { @@ -802,15 +802,15 @@ list = getProfiles(groupData); } break; - - case QueryLocator.QUERY_ROLE: + + case QueryLocator.QUERY_ROLE: roleData = new JetspeedRoleProfilePeer().selectOrdered(locator, dbCon); if (roleData != null) { list = getProfiles(roleData); } break; - + default: //QUERY_ALL userData = new JetspeedUserProfilePeer().selectOrdered(locator, dbCon); @@ -833,7 +833,7 @@ break; } - + return list.iterator(); } catch (Exception e) @@ -847,12 +847,12 @@ } return new ArrayList().iterator(); // return empty non-null iterator - } + } /** * Get profile iterator from given vector of objects. * - * @param data Vector of JetspeedUserProfile, JetspeedGroupProfile, + * @param data Vector of JetspeedUserProfile, JetspeedGroupProfile, * JetspeedRoleProfile, objects * @return List of profiles */ @@ -860,55 +860,55 @@ { List list = new ArrayList(); - for (int i = 0; i < data.size(); i++) + for (int i = 0; i < data.size(); i++) { Object obj = data.get(i); Portlets portlets = null; - if (obj instanceof JetspeedUserProfile) + if (obj instanceof JetspeedUserProfile) { portlets = DBUtils.bytesToPortlets(((JetspeedUserProfile)obj).getProfile(), this.mapping); list.add(createUserProfile((JetspeedUserProfile)obj, portlets)); } - else if (obj instanceof JetspeedGroupProfile) + else if (obj instanceof JetspeedGroupProfile) { portlets = DBUtils.bytesToPortlets(((JetspeedGroupProfile)obj).getProfile(), this.mapping); list.add(createGroupProfile((JetspeedGroupProfile)obj, portlets)); } - else if (obj instanceof JetspeedRoleProfile) + else if (obj instanceof JetspeedRoleProfile) { portlets = DBUtils.bytesToPortlets(((JetspeedRoleProfile)obj).getProfile(), this.mapping); list.add(createRoleProfile((JetspeedRoleProfile)obj, portlets)); } - + } return list; } - + /** * Get PSMLDocument object for given pagename and portlets. * * @param portlets Portlets for the given page name * @param page page name for this resource - * @return PSMLDocument object for given page and portlets - */ + * @return PSMLDocument object for given page and portlets + */ private PSMLDocument getPSMLDocument(String page, Portlets portlets) { PSMLDocument psmldoc = new BasePSMLDocument(); psmldoc.setName(page); psmldoc.setPortlets(portlets); return psmldoc; - } + } - /** + /** * Given ordered list of locators, find the first document matching * a profile locator, starting from the beginning of the list and working * to the end. * * @param locator The ordered list of profile locators. - * @return PSMLDocument object for the first document matching a locator + * @return PSMLDocument object for the first document matching a locator */ public PSMLDocument getDocument(List locators) { @@ -920,10 +920,10 @@ } // iterate over the list and invoke getDocument(locator) method - for (int i = 0; i < locators.size(); i++) + for (int i = 0; i < locators.size(); i++) { PSMLDocument psmldoc = getDocument((ProfileLocator)locators.get(i)); - if (psmldoc != null) + if (psmldoc != null) { return psmldoc; } @@ -934,8 +934,8 @@ /** * Returns a PSML document for the given locator, it is called by the cache * refresher - * - * @param locator The locator descriptor(ProfileLocator object) of the + * + * @param locator The locator descriptor(ProfileLocator object) of the * document to be retrieved. * @return psmldoc The PSMLDocument object */ @@ -967,43 +967,43 @@ { tableName = "JETSPEED_USER_PROFILE"; records = new JetspeedUserProfilePeer().select(locator, dbCon); - Iterator iterator = records.iterator(); + Iterator iterator = records.iterator(); while (iterator.hasNext()) { - JetspeedUserProfile uprofile = + JetspeedUserProfile uprofile = (JetspeedUserProfile)iterator.next(); page = uprofile.getPage(); portlets = DBUtils.bytesToPortlets(uprofile.getProfile(), this.mapping); } } else if (role != null) - { + { tableName = "JETSPEED_ROLE_PROFILE"; records = new JetspeedRoleProfilePeer().select(locator, dbCon); - Iterator iterator = records.iterator(); + Iterator iterator = records.iterator(); while (iterator.hasNext()) { - JetspeedRoleProfile rprofile = + JetspeedRoleProfile rprofile = (JetspeedRoleProfile)iterator.next(); page = rprofile.getPage(); portlets = DBUtils.bytesToPortlets(rprofile.getProfile(), this.mapping); } - } + } else if (group != null) { tableName = "JETSPEED_GROUP_PROFILE"; records = new JetspeedGroupProfilePeer().select(locator, dbCon); - Iterator iterator = records.iterator(); + Iterator iterator = records.iterator(); while (iterator.hasNext()) { - JetspeedGroupProfile gprofile = + JetspeedGroupProfile gprofile = (JetspeedGroupProfile)iterator.next(); page = gprofile.getPage(); portlets = DBUtils.bytesToPortlets(gprofile.getProfile(), this.mapping); } - } + } - if (page != null && portlets != null) + if (page != null && portlets != null) { psmldoc = getPSMLDocument(page, portlets); if (cachingOn) @@ -1016,7 +1016,7 @@ } } return psmldoc; - } + } else { if (cachingOn) @@ -1054,10 +1054,10 @@ { DBConnection dbCon = getDbConnection(); - try - { + try + { if (user != null) - { + { new JetspeedUserProfilePeer().delete(user, dbCon); } } @@ -1087,7 +1087,7 @@ if (role != null) { new JetspeedRoleProfilePeer().delete(role, dbCon); - } + } } catch (Exception e) // delete failed { @@ -1114,7 +1114,7 @@ if (group != null) { new JetspeedGroupProfilePeer().delete(group, dbCon); - } + } } catch (Exception e) // delete failed { @@ -1142,14 +1142,14 @@ { this.consumer = consumer; profiles = query(locator); - + while (profiles.hasNext() ) { Profile profile = (Profile)profiles.next(); //dumpProfile(profile); try { - consumer.createDocument(profile); + consumer.createDocument(profile); count++; } catch (Exception ex) @@ -1203,12 +1203,12 @@ user.setUserName(entity.getUserName()); } profile.setUser(user); - + profile.setMediaType(entity.getMediaType()); profile.setLanguage(entity.getLanguage()); profile.setCountry(entity.getCountry()); profile.setName(entity.getPage()); - profile.setDocument(getPSMLDocument(entity.getPage(), portlets)); + profile.setDocument(getPSMLDocument(entity.getPage(), portlets)); } catch (JetspeedSecurityException e) { @@ -1239,7 +1239,7 @@ profile.setLanguage(entity.getLanguage()); profile.setCountry(entity.getCountry()); profile.setName(entity.getPage()); - profile.setDocument(getPSMLDocument(entity.getPage(), portlets)); + profile.setDocument(getPSMLDocument(entity.getPage(), portlets)); } catch (JetspeedSecurityException e) { @@ -1270,7 +1270,7 @@ profile.setLanguage(entity.getLanguage()); profile.setCountry(entity.getCountry()); profile.setName(entity.getPage()); - profile.setDocument(getPSMLDocument(entity.getPage(), portlets)); + profile.setDocument(getPSMLDocument(entity.getPage(), portlets)); } catch (JetspeedSecurityException e) { @@ -1291,7 +1291,7 @@ { return Torque.getConnection(); } - + // otherwise use the specified pool name else { 1.1 jakarta-jetspeed/src/java/org/apache/jetspeed/services/psmlmanager/db/DatabasePsmlManager.java Index: DatabasePsmlManager.java =================================================================== /* ==================================================================== * The Apache Software License, Version 1.1 * * Copyright (c) 2000-2001 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, * if any, must include the following acknowledgment: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowledgment may appear in the software itself, * if and wherever such third-party acknowledgments normally appear. * * 4. The names "Apache" and "Apache Software Foundation" and * "Apache Jetspeed" must not be used to endorse or promote products * derived from this software without prior written permission. For * written permission, please contact [EMAIL PROTECTED] * * 5. Products derived from this software may not be called "Apache" or * "Apache Jetspeed", nor may "Apache" appear in their name, without * prior written permission of the Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. */ package org.apache.jetspeed.services.psmlmanager.db; // PSML Manager Service interface import org.apache.jetspeed.services.psmlmanager.PsmlManagerService; import org.exolab.castor.mapping.Mapping; /** * This interface defines the Database PSML Manager service * * @author <a href="mailto:[EMAIL PROTECTED]">David Sean Taylor</a> * @version $Id: DatabasePsmlManager.java,v 1.1 2002/09/20 17:38:07 taylor Exp $ */ public interface DatabasePsmlManager extends PsmlManagerService, DBOperations { public Mapping getMapping(); }
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>