You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by ta...@apache.org on 2005/05/23 22:22:26 UTC
cvs commit: jakarta-jetspeed/torque-om/src .cvsignore
taylor 2005/05/23 13:22:26
Added: torque-om/src/java/org/apache/jetspeed/om/security/turbine
TurbinePermission.java TurbineGroup.java
TurbineRole.java TurbineUserPeer.java
torque-om/src/java/org/apache/jetspeed/om/dbpsml
JetspeedGroupProfilePeer.java
JetspeedUserProfilePeer.java
JetspeedRoleProfilePeer.java
torque-om/src/java/org/apache/jetspeed/om/dbregistry
SecurityDbEntryPeer.java PortletDbEntryPeer.java
torque-om/src/java/org/apache/jetspeed/om/apps/email
EmailInbox.java
torque-om/src .cvsignore
Log:
moving overriden torque files to torque-om subproject
seems we had two copies of the overriden files
the empty ones were being used instead of the overriden
hopefully this will clear up some errors
Revision Changes Path
1.1 jakarta-jetspeed/torque-om/src/java/org/apache/jetspeed/om/security/turbine/TurbinePermission.java
Index: TurbinePermission.java
===================================================================
package org.apache.jetspeed.om.security.turbine;
import org.apache.torque.om.Persistent;
/**
* The skeleton for this class was autogenerated by Torque on:
*
* [Mon Jun 03 20:14:05 PDT 2002]
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*/
public class TurbinePermission
extends org.apache.jetspeed.om.security.turbine.BaseTurbinePermission
implements Persistent, org.apache.jetspeed.om.security.Permission
{
public String getName()
{
return getPermissionName();
}
public void setName(String name)
{
setPermissionName(name);
}
public String getId()
{
return String.valueOf(this.getPermissionId());
}
public void setId(String id)
{
}
}
1.1 jakarta-jetspeed/torque-om/src/java/org/apache/jetspeed/om/security/turbine/TurbineGroup.java
Index: TurbineGroup.java
===================================================================
package org.apache.jetspeed.om.security.turbine;
import org.apache.torque.om.Persistent;
/**
* The skeleton for this class was autogenerated by Torque on:
*
* [Mon Jun 03 20:14:05 PDT 2002]
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*/
public class TurbineGroup
extends org.apache.jetspeed.om.security.turbine.BaseTurbineGroup
implements Persistent, org.apache.jetspeed.om.security.Group
{
public String getName()
{
return getGroupName();
}
public void setName(String name)
{
setGroupName(name);
}
public String getId()
{
return String.valueOf(this.getGroupId());
}
public void setId(String id)
{
}
}
1.1 jakarta-jetspeed/torque-om/src/java/org/apache/jetspeed/om/security/turbine/TurbineRole.java
Index: TurbineRole.java
===================================================================
package org.apache.jetspeed.om.security.turbine;
import org.apache.torque.om.Persistent;
/**
* The skeleton for this class was autogenerated by Torque on:
*
* [Mon Jun 03 20:14:05 PDT 2002]
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*/
public class TurbineRole
extends org.apache.jetspeed.om.security.turbine.BaseTurbineRole
implements Persistent, org.apache.jetspeed.om.security.Role
{
public String getName()
{
return getRoleName();
}
public void setName(String name)
{
setRoleName(name);
}
public String getId()
{
return String.valueOf(this.getRoleId());
}
public void setId(String id)
{
}
}
1.1 jakarta-jetspeed/torque-om/src/java/org/apache/jetspeed/om/security/turbine/TurbineUserPeer.java
Index: TurbineUserPeer.java
===================================================================
/*
* Copyright 2000-2001,2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.jetspeed.om.security.turbine;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List;
import org.apache.jetspeed.om.security.JetspeedUser;
import org.apache.jetspeed.om.security.JetspeedUserFactory;
import org.apache.torque.TorqueException;
import org.apache.torque.om.NumberKey;
import org.apache.torque.util.Criteria;
import org.apache.turbine.util.ObjectUtils;
import com.workingdogs.village.Record;
import com.workingdogs.village.Schema;
import com.workingdogs.village.Value;
// Local classes
/**
* The skeleton for this class was autogenerated by Torque on:
*
* [Wed May 29 23:45:25 PDT 2002]
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*/
public class TurbineUserPeer
extends org.apache.jetspeed.om.security.turbine.BaseTurbineUserPeer
{
/** The schema. */
private static Schema schema = initTableSchema(TABLE_NAME);
/** The columns. */
private static com.workingdogs.village.Column[] columns =
initTableColumns(schema);
/** The names of the columns. */
public static String[] columnNames = initColumnNames(columns);
/**
* Selects Jetspeed Users or a derived class there of, creating the
* JetspeedUsers, and populating each user's hashtable of attributes
* from the result set of the query
*
* @param criteria the query criteria.
* @return a List of JetspeedUsers
*/
public static List doSelectUsers( Criteria criteria ) throws TorqueException
{
return populateUserObjects( doSelectVillageRecords(criteria) );
}
/**
* The returned list will contain objects of the default type or
* objects that inherit from the default.
*/
public static List populateUserObjects(List records)
throws TorqueException
{
List results = new ArrayList(records.size());
// populate the object(s)
for ( int i=0; i<records.size(); i++ )
{
Record row = (Record)records.get(i);
results.add(TurbineUserPeer.row2UserObject(row, 1, TurbineUserPeer.getOMClass()));
}
return results;
}
/**
* Create a new object of type cls from a resultset row starting
* from a specified offset. This is done so that you can select
* other rows than just those needed for this object. You may
* for example want to create two objects from the same row.
*/
public static JetspeedUser row2UserObject (Record row,
int offset,
Class cls )
throws TorqueException
{
try
{
//TurbineUser obj = (TurbineUser)cls.newInstance();
//populateObject(row, offset, obj);
//obj.setModified(false);
//obj.setNew(false);
JetspeedUser user = JetspeedUserFactory.getInstance(false);
populateUserObject(row, offset, user);
return user;
}
catch (Exception e)
{
throw new TorqueException(e);
}
}
protected static final String TURBINE_OBJECTDATA = "OBJECTDATA";
/*
* Populates a JetspeedUser from a single row in the result set.
* The hashtable of attributes for each user is populated with columns
* from the result set.
*
* @param row a row containing a single user's attributes.
* @param user the JetspeedUser object to be populated.
*
*/
protected static void populateUserObject(Record row, int offset, JetspeedUser user)
throws Exception
{
// Set values are where columns are expected. They are not
// required to be in these positions, as we set the positions
// immediately following.
int idPosition = 1;
int objectDataPosition = columnNames.length;
for( int i=0; i<columnNames.length; i++ )
{
if (columnNames[i].equals(USER_ID))
idPosition = i+1;
if (columnNames[i].equals(TURBINE_OBJECTDATA))
objectDataPosition = i+1;
}
// Restore the Permanent Storage Hashtable. First the
// Hashtable is restored, then any explicit table columns
// which should be included in the Hashtable are added.
byte[] objectData = (byte[])row.getValue(objectDataPosition).asBytes();
Hashtable tempHash = (Hashtable)ObjectUtils.deserialize(objectData);
if (tempHash == null)
{
tempHash = new Hashtable(10);
}
for( int j=0; j<columnNames.length; j++ )
{
if (! columnNames[j].equalsIgnoreCase( TURBINE_OBJECTDATA ) )
{
Object obj2 = null;
Value value = row.getValue(j+1);
if (value.isString())
obj2 = value.asString();
else if (value.isBigDecimal())
obj2 = value.asBigDecimal();
else if (value.isBytes())
obj2 = value.asBytes();
else if (value.isDate())
obj2 = value.asDate();
else if (value.isShort())
obj2 = new Short(value.asShort());
else if (value.isInt())
obj2 = new Integer(value.asInt());
else if (value.isLong())
obj2 = new Long(value.asLong());
else if (value.isDouble())
obj2 = new Double(value.asDouble());
else if (value.isFloat())
obj2 = new Float(value.asFloat());
else if (value.isBoolean())
obj2 = new Boolean(value.asBoolean());
else if (value.isTime())
obj2 = value.asTime();
else if (value.isTimestamp())
obj2 = value.asTimestamp();
else if (value.isUtilDate())
obj2 = value.asUtilDate();
else if (value.isByte())
obj2 = new Byte(value.asByte());
if ( obj2 != null )
{
if (columnNames[j].equalsIgnoreCase( JetspeedUser.USER_ID ))
{
obj2 = value.toString();
}
tempHash.put( columnNames[j], obj2 );
}
}
}
user.setPermStorage( tempHash );
}
/*
* Populates a JetspeedUser from a single row in the result set.
* The hashtable of attributes for each user is populated with columns
* from the result set.
*
* @param row a row containing a single user's attributes.
* @param user the JetspeedUser object to be populated.
*
*/
/*
DST: COMMITTED 8/19 FROM AMIT AMTE - IT HAS SOME BUGS, GOING TO REMOVE UNTIL RESOLVED
protected static void populateUserObject(Record row, int offset, JetspeedUser user)
throws Exception
{
// Restore the Permanent Storage Hashtable. First the
// Hashtable is restored, then any explicit table columns
// which should be included in the Hashtable are added.
byte[] objectData = (byte[])row.getValue(OBJECTDATA).asBytes();
Hashtable tempHash = (Hashtable)ObjectUtils.deserialize(objectData);
if (tempHash == null)
{
tempHash = new Hashtable(10);
}
for( int j=0; j<columnNames.length; j++ )
{
if (! columnNames[j].equalsIgnoreCase( OBJECTDATA ) )
{
Object obj2 = null;
Value value = null;
try {
value = row.getValue(columnNames[j]);
} catch (Exception ex) {
// Column missing from the torque record ..
// Probable/intentional mis-match between the
// torque schema and db table
continue;
}
if (value.isString())
obj2 = value.asString();
else if (value.isBigDecimal())
obj2 = value.asBigDecimal();
else if (value.isBytes())
obj2 = value.asBytes();
else if (value.isDate())
obj2 = value.asDate();
else if (value.isShort())
obj2 = new Short(value.asShort());
else if (value.isInt())
obj2 = new Integer(value.asInt());
else if (value.isLong())
obj2 = new Long(value.asLong());
else if (value.isDouble())
obj2 = new Double(value.asDouble());
else if (value.isFloat())
obj2 = new Float(value.asFloat());
else if (value.isBoolean())
obj2 = new Boolean(value.asBoolean());
else if (value.isTime())
obj2 = value.asTime();
else if (value.isTimestamp())
obj2 = value.asTimestamp();
else if (value.isUtilDate())
obj2 = value.asUtilDate();
else if (value.isByte())
obj2 = new Byte(value.asByte());
if ( obj2 != null )
{
if (columnNames[j].equalsIgnoreCase( JetspeedUser.USER_ID ))
{
obj2 = value.toString();
}
System.out.println(columnNames[j] + ": " + obj2.toString());
tempHash.put( columnNames[j], obj2 );
}
}
}
user.setPermStorage( tempHash );
}
*/
/**
* Builds a criteria object based upon an User object
*/
public static Criteria buildCriteria(JetspeedUser user)
{
Hashtable permData = (Hashtable) user.getPermStorage().clone();
Criteria criteria = new Criteria();
if ( !user.isNew() )
{
criteria.add(USER_ID, new NumberKey(user.getUserId()));
}
for (int i=1; i < columnNames.length; i++ )
{
if ( permData.containsKey(columnNames[i]) )
{
String key = new StringBuffer(TABLE_NAME)
.append('.').append(columnNames[i]).toString();
criteria.add( key,
permData.remove(TurbineUserPeer.columnNames[i]) );
}
}
String dataKey = new StringBuffer(TABLE_NAME).append('.').append(TURBINE_OBJECTDATA).toString();
criteria.add( dataKey, permData );
return criteria;
}
}
1.1 jakarta-jetspeed/torque-om/src/java/org/apache/jetspeed/om/dbpsml/JetspeedGroupProfilePeer.java
Index: JetspeedGroupProfilePeer.java
===================================================================
package org.apache.jetspeed.om.dbpsml;
// JDK classes
import java.sql.Connection;
import java.util.List;
import org.apache.jetspeed.om.profile.Profile;
import org.apache.jetspeed.om.profile.ProfileLocator;
import org.apache.jetspeed.om.security.Group;
import org.apache.jetspeed.services.Profiler;
import org.apache.jetspeed.services.PsmlManager;
import org.apache.jetspeed.services.psmlmanager.db.DBOperations;
import org.apache.jetspeed.services.psmlmanager.db.DBUtils;
import org.apache.jetspeed.services.psmlmanager.db.DatabasePsmlManager;
import org.apache.torque.util.BasePeer;
import org.apache.torque.util.Criteria;
/**
* The skeleton for this class was autogenerated by Torque on:
*
* [Mon Sep 10 13:30:53 PDT 2001]
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @author <a href="mailto:adambalk@cisco.com">Atul Dambalkar</a>
* @version $Id: JetspeedGroupProfilePeer.java,v 1.1 2005/05/23 20:22:25 taylor Exp $
*/
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.
*
* @param profile Profile object that will be inserted in the database
* @param connection A database connection to use
*/
public void insert(Profile profile, Connection connection) throws Exception
{
doInsertOrUpdate(profile, INSERT, connection);
}
/**
* Update 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 update(Profile profile, Connection connection) throws Exception
{
doInsertOrUpdate(profile, UPDATE, connection);
}
private void doInsertOrUpdate(Profile profile, int operation, Connection connection)
throws Exception
{
JetspeedGroupProfile groupProfile = new JetspeedGroupProfile();
DatabasePsmlManager service = (DatabasePsmlManager)PsmlManager.getService();
groupProfile.setGroupName(profile.getGroup().getName());
groupProfile.setMediaType(profile.getMediaType());
String language = profile.getLanguage();
if(language != null && (!language.equals("-1")))
{
groupProfile.setLanguage(language);
}
else
{
groupProfile.setLanguage(null);
}
String country = profile.getCountry();
if(country != null && (!country.equals("-1")))
{
groupProfile.setCountry(country);
}
else
{
groupProfile.setCountry(null);
}
String name = profile.getName();
if (name == null || name.equals(""))
{
profile.setName(Profiler.FULL_DEFAULT_PROFILE);
}
else if (!name.endsWith(Profiler.DEFAULT_EXTENSION))
{
profile.setName(name + Profiler.DEFAULT_EXTENSION);
}
groupProfile.setPage(profile.getName());
groupProfile.setProfile(DBUtils.portletsToBytes(
profile.getDocument().getPortlets(), service.getMapping()));
if (operation == INSERT)
{
super.doInsert(groupProfile, connection);
}
else if (operation == UPDATE)
{
Criteria values = buildCriteria(groupProfile);
Criteria select = buildCriteria(groupProfile);
select.remove(PROFILE);
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, Connection connection) throws Exception
{
super.doDelete(buildCriteria(locator), connection);
}
/**
* Select group profile record from the database table for the given
* locator object.
*
* @param locator ProfileLocator object that will be used to select required
* profile from the database
* @param connection A database connection to use
* @return List of records that statisfy the given locator criteria.
*/
public List select(ProfileLocator locator, Connection connection) throws Exception
{
return super.doSelect(buildCriteria(locator), connection);
}
/**
* Select group profile record from the database table for the given
* locator object and return list ordered by primary key..
*
* @param locator ProfileLocator object that will be used to select required
* profile from the database
* @param connection A database connection to use
* @return List of records that statisfy the given locator criteria.
*/
public List selectOrdered(ProfileLocator locator, Connection connection) throws Exception
{
Criteria criteria = buildCriteria(locator);
criteria.addAscendingOrderByColumn(GROUP_NAME);
criteria.addAscendingOrderByColumn(MEDIA_TYPE);
criteria.addAscendingOrderByColumn(LANGUAGE);
criteria.addAscendingOrderByColumn(COUNTRY);
criteria.addAscendingOrderByColumn(PAGE);
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, Connection connection) throws Exception
{
Criteria criteria = new Criteria();
criteria.add(GROUP_NAME, group.getName());
super.doDelete(criteria, connection);
}
/*
* Build criteria for selecting, deleting groups
*
*/
protected Criteria buildCriteria(ProfileLocator locator)
{
Criteria criteria = new Criteria();
String mediaType = locator.getMediaType();
String language = locator.getLanguage();
String country = locator.getCountry();
String pageName = locator.getName();
String groupName = null;
Group group = locator.getGroup();
if (group != null) {
groupName = group.getName();
}
if (groupName != null && groupName.length() > 0)
{
criteria.add(GROUP_NAME, groupName);
}
if (pageName != null && pageName.length() > 0)
{
criteria.add(PAGE, pageName);
}
if (mediaType != null && mediaType.length() > 0)
{
criteria.add(MEDIA_TYPE, locator.getMediaType());
}
if (language != null && language.length() > 0 && (!language.equals("-1")))
{
criteria.add(LANGUAGE, language);
}
else if(language != null && language.equals("-1"))
{
criteria.add(LANGUAGE, null);
}
if (country != null && country.length() > 0 && (!country.equals("-1")))
{
criteria.add(COUNTRY, country);
}
else if(country != null && country.equals("-1"))
{
criteria.add(COUNTRY, null);
}
return criteria;
}
}
1.1 jakarta-jetspeed/torque-om/src/java/org/apache/jetspeed/om/dbpsml/JetspeedUserProfilePeer.java
Index: JetspeedUserProfilePeer.java
===================================================================
package org.apache.jetspeed.om.dbpsml;
// JDK classes
import java.sql.Connection;
import java.util.List;
import org.apache.jetspeed.om.profile.Profile;
import org.apache.jetspeed.om.profile.ProfileLocator;
import org.apache.jetspeed.om.security.JetspeedUser;
import org.apache.jetspeed.services.Profiler;
import org.apache.jetspeed.services.PsmlManager;
import org.apache.jetspeed.services.psmlmanager.db.DBOperations;
import org.apache.jetspeed.services.psmlmanager.db.DBUtils;
import org.apache.jetspeed.services.psmlmanager.db.DatabasePsmlManager;
import org.apache.torque.util.BasePeer;
import org.apache.torque.util.Criteria;
/**
* The skeleton for this class was autogenerated by Torque on:
*
* [Mon Sep 10 13:30:53 PDT 2001]
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @author <a href="mailto:adambalk@cisco.com">Atul Dambalkar</a>
* @version $Id: JetspeedUserProfilePeer.java,v 1.1 2005/05/23 20:22:25 taylor Exp $
*/
public class JetspeedUserProfilePeer
extends org.apache.jetspeed.om.dbpsml.BaseJetspeedUserProfilePeer
implements DBOperations
{
/**
* Default constructor.
*/
public JetspeedUserProfilePeer() {}
/**
* Insert a user profile record in the database table.
*
* @param profile Profile object that will be inserted in the database
* @param connection A database connection to use
*/
public void insert(Profile profile, Connection connection) throws Exception
{
doInsertOrUpdate(profile, INSERT, connection);
}
/**
* Insert a user profile record in the database table.
*
* @param profile Profile object that will be inserted in the database
* @param connection A database connection to use
*/
public void update(Profile profile, Connection connection) throws Exception
{
doInsertOrUpdate(profile, UPDATE, connection);
}
private void doInsertOrUpdate(Profile profile, int operation, Connection connection)
throws Exception
{
JetspeedUserProfile userProfile = new JetspeedUserProfile();
DatabasePsmlManager service = (DatabasePsmlManager)PsmlManager.getService();
userProfile.setUserName(profile.getUser().getUserName());
userProfile.setMediaType(profile.getMediaType());
String language = profile.getLanguage();
if(language != null && (!language.equals("-1")))
{
userProfile.setLanguage(language);
}
else
{
userProfile.setLanguage(null);
}
String country = profile.getCountry();
if(country != null && (!country.equals("-1")))
{
userProfile.setCountry(country);
}
else
{
userProfile.setCountry(null);
}
String name = profile.getName();
if (name == null || name.equals(""))
{
profile.setName(Profiler.FULL_DEFAULT_PROFILE);
}
else if (!name.endsWith(Profiler.DEFAULT_EXTENSION))
{
profile.setName(name + Profiler.DEFAULT_EXTENSION);
}
userProfile.setPage(profile.getName());
userProfile.setProfile(DBUtils.portletsToBytes(
profile.getDocument().getPortlets(), service.getMapping()));
if (operation == INSERT)
{
super.doInsert(userProfile, connection);
}
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, Connection connection) throws Exception
{
super.doDelete(buildCriteria(locator), connection);
}
/**
* Select user profile record from the database table for the given
* locator object.
*
* @param locator ProfileLocator object that will be used to select required
* profile from the database
* @param connection A database connection to use
* @return List of records that statisfy the given locator criteria.
*/
public List select(ProfileLocator locator, Connection connection) throws Exception
{
Criteria criteria = buildCriteria(locator);
return super.doSelect(criteria, connection); // buildCriteria(locator));
}
/**
* Select user profile record from the database table for the given
* locator object and return list ordered by primary key.
*
* @param locator ProfileLocator object that will be used to select required
* profile from the database
* @param connection A database connection to use
* @return List of records that statisfy the given locator criteria.
*/
public List selectOrdered(ProfileLocator locator, Connection connection) throws Exception
{
Criteria criteria = buildCriteria(locator);
criteria.addAscendingOrderByColumn(USER_NAME);
criteria.addAscendingOrderByColumn(MEDIA_TYPE);
criteria.addAscendingOrderByColumn(LANGUAGE);
criteria.addAscendingOrderByColumn(COUNTRY);
criteria.addAscendingOrderByColumn(PAGE);
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, Connection connection) throws Exception
{
Criteria criteria = new Criteria();
criteria.add(USER_NAME, user.getUserName());
super.doDelete(criteria, connection);
}
/*
* Build criteria for selecting, deleting groups
*
*/
protected Criteria buildCriteria(ProfileLocator locator)
{
Criteria criteria = new Criteria();
String mediaType = locator.getMediaType();
String language = locator.getLanguage();
String country = locator.getCountry();
String pageName = locator.getName();
String userName = null;
JetspeedUser user= locator.getUser();
if (user != null) {
userName = user.getUserName();
}
if (userName != null && userName.length() > 0)
{
criteria.add(USER_NAME, userName) ;
}
if (pageName != null && pageName.length() > 0)
{
criteria.add(PAGE, pageName);
}
if (mediaType != null && mediaType.length() > 0)
{
criteria.add(MEDIA_TYPE, mediaType);
}
if (language != null && language.length() > 0 && (!language.equals("-1")))
{
criteria.add(LANGUAGE, language);
}
else if(language != null && language.equals("-1"))
{
criteria.add(LANGUAGE, null);
}
if (country != null && country.length() > 0 && (!country.equals("-1")))
{
criteria.add(COUNTRY, country);
}
else if(country != null && country.equals("-1"))
{
criteria.add(COUNTRY, null);
}
return criteria;
}
}
1.1 jakarta-jetspeed/torque-om/src/java/org/apache/jetspeed/om/dbpsml/JetspeedRoleProfilePeer.java
Index: JetspeedRoleProfilePeer.java
===================================================================
package org.apache.jetspeed.om.dbpsml;
// JDK classes
import java.sql.Connection;
import java.util.List;
import org.apache.jetspeed.om.profile.Profile;
import org.apache.jetspeed.om.profile.ProfileLocator;
import org.apache.jetspeed.om.security.Role;
import org.apache.jetspeed.services.Profiler;
import org.apache.jetspeed.services.PsmlManager;
import org.apache.jetspeed.services.psmlmanager.db.DBOperations;
import org.apache.jetspeed.services.psmlmanager.db.DBUtils;
import org.apache.jetspeed.services.psmlmanager.db.DatabasePsmlManager;
import org.apache.torque.util.BasePeer;
import org.apache.torque.util.Criteria;
/**
* The skeleton for this class was autogenerated by Torque on:
*
* [Mon Sep 10 13:30:53 PDT 2001]
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @author <a href="mailto:adambalk@cisco.com">Atul Dambalkar</a>
* @version $Id: JetspeedRoleProfilePeer.java,v 1.1 2005/05/23 20:22:25 taylor Exp $
*/
public class JetspeedRoleProfilePeer
extends org.apache.jetspeed.om.dbpsml.BaseJetspeedRoleProfilePeer
implements DBOperations
{
/**
* 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
*/
public void insert(Profile profile, Connection connection) throws Exception
{
doInsertOrUpdate(profile, INSERT, connection);
}
/**
* Update 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 update(Profile profile, Connection connection) throws Exception
{
doInsertOrUpdate(profile, UPDATE, connection);
}
private void doInsertOrUpdate(Profile profile, int operation, Connection connection)
throws Exception
{
JetspeedRoleProfile roleProfile = new JetspeedRoleProfile();
DatabasePsmlManager service = (DatabasePsmlManager)PsmlManager.getService();
roleProfile.setRoleName(profile.getRole().getName());
roleProfile.setMediaType(profile.getMediaType());
String language = profile.getLanguage();
if(language != null && (!language.equals("-1")))
{
roleProfile.setLanguage(language);
}
else
{
roleProfile.setLanguage(null);
}
String country = profile.getCountry();
if(country != null && (!country.equals("-1")))
{
roleProfile.setCountry(country);
}
else
{
roleProfile.setCountry(null);
}
String name = profile.getName();
if (name == null || name.equals(""))
{
profile.setName(Profiler.FULL_DEFAULT_PROFILE);
}
else if (!name.endsWith(Profiler.DEFAULT_EXTENSION))
{
profile.setName(name + Profiler.DEFAULT_EXTENSION);
}
roleProfile.setPage(profile.getName());
roleProfile.setProfile(DBUtils.portletsToBytes(
profile.getDocument().getPortlets(), service.getMapping()));
if (operation == INSERT)
{
super.doInsert(roleProfile, connection);
}
else if (operation == UPDATE)
{
Criteria values = buildCriteria(roleProfile);
Criteria select = buildCriteria(roleProfile);
select.remove(PROFILE);
BasePeer.doUpdate( select, values, connection );
}
}
/**
* 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, Connection connection) throws Exception
{
super.doDelete(buildCriteria(locator), connection);
}
/**
* Select role profile record from the database table for the given
* locator object.
*
* @param locator ProfileLocator object that will be used to select required
* profile from the database
* @param connection A database connection to use
* @return List of records that statisfy the given locator criteria.
*/
public List select(ProfileLocator locator, Connection connection) throws Exception
{
return super.doSelect(buildCriteria(locator), connection);
}
/**
* Select role profile record from the database table for the given
* locator object and return list ordered by primary key.
*
* @param locator ProfileLocator object that will be used to select required
* profile from the database
* @param connection A database connection to use
* @return List of records that statisfy the given locator criteria.
*/
public List selectOrdered(ProfileLocator locator, Connection connection) throws Exception
{
Criteria criteria = buildCriteria(locator);
criteria.addAscendingOrderByColumn(ROLE_NAME);
criteria.addAscendingOrderByColumn(MEDIA_TYPE);
criteria.addAscendingOrderByColumn(LANGUAGE);
criteria.addAscendingOrderByColumn(COUNTRY);
criteria.addAscendingOrderByColumn(PAGE);
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, Connection connection) throws Exception
{
Criteria criteria = new Criteria();
criteria.add(ROLE_NAME, role.getName());
super.doDelete(criteria, connection);
}
/*
* Build criteria for selecting, deleting groups
*
*/
protected Criteria buildCriteria(ProfileLocator locator)
{
Criteria criteria = new Criteria();
String mediaType = locator.getMediaType();
String language = locator.getLanguage();
String country = locator.getCountry();
String pageName = locator.getName();
String roleName = null;
Role role = locator.getRole();
if (role != null) {
roleName = role.getName();
}
if (roleName != null && roleName.length() > 0)
{
criteria.add(ROLE_NAME, roleName);
}
if (pageName != null && pageName.length() > 0)
{
criteria.add(PAGE, pageName);
}
if (mediaType != null && mediaType.length() > 0)
{
criteria.add(MEDIA_TYPE, locator.getMediaType());
}
if (language != null && language.length() > 0 && (!language.equals("-1")))
{
criteria.add(LANGUAGE, language);
}
else if(language != null && language.equals("-1"))
{
criteria.add(LANGUAGE, null);
}
if (country != null && country.length() > 0 && (!country.equals("-1")))
{
criteria.add(COUNTRY, country);
}
else if(country != null && country.equals("-1"))
{
criteria.add(COUNTRY, null);
}
return criteria;
}
}
1.1 jakarta-jetspeed/torque-om/src/java/org/apache/jetspeed/om/dbregistry/SecurityDbEntryPeer.java
Index: SecurityDbEntryPeer.java
===================================================================
/*
* Copyright 2000-2001,2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.jetspeed.om.dbregistry;
import java.sql.Connection;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.apache.jetspeed.om.registry.RegistryException;
import org.apache.jetspeed.om.registry.SecurityAccess;
import org.apache.jetspeed.om.registry.SecurityAllow;
import org.apache.jetspeed.om.registry.SecurityEntry;
import org.apache.jetspeed.om.registry.base.BaseSecurityAccess;
import org.apache.jetspeed.om.registry.base.BaseSecurityAllow;
import org.apache.jetspeed.om.registry.base.BaseSecurityAllowOwner;
import org.apache.jetspeed.om.registry.base.BaseSecurityEntry;
import org.apache.jetspeed.services.logging.JetspeedLogFactoryService;
import org.apache.jetspeed.services.logging.JetspeedLogger;
import org.apache.torque.Torque;
import org.apache.torque.TorqueException;
import org.apache.torque.util.Criteria;
/**
* Implements the Security Registry database operations
*
* @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
* @version $Id: SecurityDbEntryPeer.java,v 1.1 2005/05/23 20:22:25 taylor Exp $
*/
public class SecurityDbEntryPeer
extends org.apache.jetspeed.om.dbregistry.BaseSecurityDbEntryPeer
{
public static final String ALLOW_OWNER = "owner";
public static final String ALLOW_ROLE = "role";
public static final String ALLOW_GROUP = "group";
public static final String ALLOW_USER = "user";
public static final String ALLOW_BOTH = "rolegroup";
private static final JetspeedLogger logger = JetspeedLogFactoryService.getLogger(SecurityDbEntryPeer.class.getName());
public static SecurityEntry lookupSecurityEntry(String entryName)
{
SecurityEntry se = null;
try
{
SecurityDbEntry sde = lookup(entryName);
if(sde != null)
{
se = mapDatabaseToEntry(sde);
}
}
catch (Exception e)
{
logger.error("Exception retrieving Security Entry: " + entryName, e);
}
return se;
}
private static SecurityDbEntry lookup(String entryName)
throws TorqueException
{
Criteria criteria = new Criteria();
criteria.add(SecurityDbEntryPeer.NAME, entryName);
List result = SecurityDbEntryPeer.doSelect(criteria);
if (null == result || result.isEmpty())
{
return null;
}
return (SecurityDbEntry)result.get(0);
}
public static void storeSecurityEntry(SecurityEntry se)
throws RegistryException
{
Connection conn = null;
boolean autoCommit = false;
try
{
// get fresh copy in case its changed on another node
SecurityDbEntry sde = lookup(se.getName());
if (null != sde)
{
SecurityDbEntryPeer.removeSecurityEntryAccess(sde.getId());
}
else
{
sde = new SecurityDbEntry();
}
conn = Torque.getConnection(DATABASE_NAME);
autoCommit = conn.getAutoCommit();
conn.setAutoCommit(false);
sde.setName(se.getName());
sde.setTitle(se.getTitle());
sde.setDescription(se.getDescription());
sde.save(conn);
Iterator accesses = se.getAccesses().iterator();
while (accesses.hasNext())
{
SecurityAccess access = (SecurityAccess)accesses.next();
SecurityAccessDbEntry sade = new SecurityAccessDbEntry();
sade.setAction(access.getAction());
sade.setEntryId(sde.getId());
sade.save(conn);
Iterator allows = access.getAllAllows().iterator();
while (allows.hasNext())
{
SecurityAllow allow = (SecurityAllow)allows.next();
SecurityAllowDbEntry sa = new SecurityAllowDbEntry();
if (allow.isOwner())
{
sa.setAllowType(ALLOW_OWNER);
sa.setAllowValue(ALLOW_OWNER);
}
else if (allow.getRole() != null && allow.getGroup() != null)
{
sa.setAllowType(ALLOW_BOTH);
sa.setAllowValue(allow.getRole());
sa.setAllowGroup(allow.getGroup());
}
else if (allow.getRole() != null)
{
sa.setAllowType(ALLOW_ROLE);
sa.setAllowValue(allow.getRole());
}
else if (allow.getGroup() != null)
{
sa.setAllowType(ALLOW_GROUP);
sa.setAllowValue(allow.getGroup());
}
else
{
sa.setAllowType(ALLOW_USER);
sa.setAllowValue(allow.getUser());
}
sa.setAccessId(sade.getId());
sa.save(conn);
}
}
}
catch (Exception e)
{
try
{
conn.rollback();
}
catch (Exception e2)
{
logger.error("Failed to rollback", e2);
}
logger.error("Exception storing Security Entry: " + se.getName(), e);
throw new RegistryException("Exception storing Security Entry: " + se.getName() + ", " + e.toString());
}
finally
{
// make sure to release the database connection
Torque.closeConnection(conn);
try
{
conn.setAutoCommit(autoCommit);
}
catch (Exception e)
{
}
}
}
public static SecurityEntry mapDatabaseToEntry(SecurityDbEntry sde)
throws TorqueException
{
SecurityEntry se = new BaseSecurityEntry(sde.getId());
se.setName(sde.getName());
se.setTitle(sde.getTitle());
se.setDescription(sde.getDescription());
Iterator accesses = sde.getSecurityAccessDbEntrys().iterator();
while (accesses.hasNext())
{
SecurityAccessDbEntry sade = (SecurityAccessDbEntry)accesses.next();
SecurityAccess access = new BaseSecurityAccess(sade.getId());
access.setAction(sade.getAction());
Iterator allows = sade.getSecurityAllowDbEntrys().iterator();
while (allows.hasNext())
{
SecurityAllowDbEntry sa = (SecurityAllowDbEntry)allows.next();
if (sa.getAllowType().equals(ALLOW_OWNER))
{
SecurityAllow allow = new BaseSecurityAllowOwner(sa.getId());
allow.setOwner(true);
access.getOwnerAllows().add(allow);
}
else if (sa.getAllowType().equals(ALLOW_BOTH))
{
SecurityAllow allow = new BaseSecurityAllow(sa.getId());
allow.setRole(sa.getAllowValue());
allow.setGroup(sa.getAllowGroup());
access.getAllows().add(allow);
}
else if (sa.getAllowType().equals(ALLOW_ROLE))
{
SecurityAllow allow = new BaseSecurityAllow(sa.getId());
allow.setRole(sa.getAllowValue());
access.getAllows().add(allow);
}
else if (sa.getAllowType().equals(ALLOW_GROUP))
{
SecurityAllow allow = new BaseSecurityAllow(sa.getId());
allow.setGroup(sa.getAllowValue());
access.getAllows().add(allow);
}
else
{
SecurityAllow allow = new BaseSecurityAllow(sa.getId());
allow.setUser(sa.getAllowValue());
access.getAllows().add(allow);
}
}
se.getAccesses().add(access);
}
return se;
}
public static void removeSecurityEntry(String entryName)
throws RegistryException
{
try
{
Criteria criteria = new Criteria();
criteria.add(SecurityDbEntryPeer.NAME, entryName);
SecurityDbEntryPeer.doDelete(criteria);
}
catch (TorqueException e)
{
logger.error("Exception Removing Security Entry: " + entryName, e);
throw new RegistryException("Exception Removing Security Entry: " + entryName + ", " + e.toString());
}
}
public static void removeSecurityEntryAccess(long id)
throws RegistryException
{
try
{
Criteria criteria = new Criteria();
criteria.add(SecurityAccessDbEntryPeer.ENTRY_ID, id);
SecurityDbEntryPeer.doDelete(criteria);
}
catch (TorqueException e)
{
logger.error("Exception Removing Security Entry Accesses: " + id, e);
throw new RegistryException("Exception Removing Security Entry: " + id + ", " + e.toString());
}
}
public static List fetchExtent()
throws RegistryException
{
List extent = new ArrayList();
try
{
Iterator result = SecurityDbEntryPeer.doSelect(new Criteria()).iterator();
while (result.hasNext())
{
SecurityEntry se = mapDatabaseToEntry((SecurityDbEntry)result.next());
extent.add(se);
}
}
catch (TorqueException e)
{
String msg = "Exception Fetching Extent for Security ";
logger.error(msg , e);
throw new RegistryException(msg + e);
}
return extent;
}
}
1.1 jakarta-jetspeed/torque-om/src/java/org/apache/jetspeed/om/dbregistry/PortletDbEntryPeer.java
Index: PortletDbEntryPeer.java
===================================================================
/*
* Copyright 2000-2001,2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.jetspeed.om.dbregistry;
import java.sql.Connection;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.apache.jetspeed.om.BaseSecurityReference;
import org.apache.jetspeed.om.SecurityReference;
import org.apache.jetspeed.om.registry.CachedParameter;
import org.apache.jetspeed.om.registry.Category;
import org.apache.jetspeed.om.registry.MetaInfo;
import org.apache.jetspeed.om.registry.PortletEntry;
import org.apache.jetspeed.om.registry.RegistryException;
import org.apache.jetspeed.om.registry.base.BaseCachedParameter;
import org.apache.jetspeed.om.registry.base.BaseMetaInfo;
import org.apache.jetspeed.om.registry.base.BasePortletEntry;
import org.apache.jetspeed.services.logging.JetspeedLogFactoryService;
import org.apache.jetspeed.services.logging.JetspeedLogger;
import org.apache.torque.Torque;
import org.apache.torque.TorqueException;
import org.apache.torque.util.Criteria;
/**
* Implements the Portlet Registry database operations
*
* @author <a href="mailto:taylor@apache.org">David Sean Taylor </a>
* @version $Id: PortletDbEntryPeer.java,v 1.1 2005/05/23 20:22:25 taylor Exp $
*/
public class PortletDbEntryPeer extends
org.apache.jetspeed.om.dbregistry.BasePortletDbEntryPeer
{
private static final JetspeedLogger logger = JetspeedLogFactoryService
.getLogger(PortletDbEntryPeer.class.getName());
public static PortletEntry lookupPortletEntry(String entryName)
{
PortletEntry pe = null;
try
{
PortletDbEntry pde = lookup(entryName);
if (pde != null)
{
pe = mapDatabaseToEntry(pde);
}
} catch (Exception e)
{
logger.error("Exception retrieving Portlet Entry: " + entryName, e);
}
return pe;
}
private static PortletDbEntry lookup(String entryName)
throws TorqueException
{
Criteria criteria = new Criteria();
criteria.add(PortletDbEntryPeer.NAME, entryName);
List result = PortletDbEntryPeer.doSelect(criteria);
if (null == result || result.isEmpty())
{
return null;
}
return (PortletDbEntry) result.get(0);
}
public static PortletEntry mapDatabaseToEntry(PortletDbEntry pde)
throws TorqueException
{
PortletEntry pe = new BasePortletEntry(pde.getId());
pe.setApplication(pde.getApplication());
pe.setCachedOnURL(pde.getCachedOnUrl());
pe.setClassname(pde.getClassname());
pe.setDescription(pde.getDescription());
pe.setHidden(pde.getHidden());
MetaInfo meta = new BaseMetaInfo();
meta.setImage(pde.getImage());
meta.setDescription(pde.getDescription());
meta.setTitle(pde.getTitle());
pe.setMetaInfo(meta);
pe.setName(pde.getName());
pe.setParent(pde.getParent());
if(pde.getSecurityRef() != null)
{
SecurityReference ref = new BaseSecurityReference();
ref.setParent(pde.getSecurityRef());
pe.setSecurityRef(ref);
}
pe.setTitle(pde.getTitle());
pe.setType(pde.getType());
pe.setURL(pde.getURL());
// parameters
Iterator params = pde.getPortletParameters().iterator();
while (params.hasNext())
{
PortletParameter pp = (PortletParameter)params.next();
CachedParameter cp = new BaseCachedParameter(pp.getId());
cp.setCachedOnName(pp.getCachedOnName());
cp.setCachedOnValue(pp.getCachedOnValue());
cp.setDescription(pp.getDescription());
cp.setHidden(pp.getHidden());
cp.setName(pp.getName());
cp.setType(pp.getType());
cp.setValue(pp.getValue());
cp.setTitle(pp.getTitle());
if (pp.getDescription() != null || pp.getTitle() != null || pp.getImage() != null)
{
MetaInfo meta2 = new BaseMetaInfo();
meta2.setImage(pp.getImage());
meta2.setDescription(pp.getDescription());
meta2.setTitle(pp.getTitle());
cp.setMetaInfo(meta2);
}
if (pp.getSecurityRef() != null)
{
SecurityReference ref2 = new BaseSecurityReference();
ref2.setParent(pp.getSecurityRef());
cp.setSecurityRef(ref2);
}
pe.addParameter(cp);
}
// media types
Iterator mtypes = pde.getPortletMediatypes().iterator();
while (mtypes.hasNext())
{
PortletMediatype pm = (PortletMediatype)mtypes.next();
pe.addMediaType(pm.getName());
}
// categories
Iterator categories = pde.getPortletCategorys().iterator();
while (categories.hasNext())
{
PortletCategory pc = (PortletCategory)categories.next();
pe.addCategory(pc.getName(), pc.getGroup());
}
return pe;
}
public static void removePortletSubObjects(long id)
throws RegistryException
{
try
{
Criteria criteria = new Criteria();
criteria.add(PortletParameterPeer.PORTLET_ID, id);
PortletParameterPeer.doDelete(criteria);
criteria = new Criteria();
criteria.add(PortletMediatypePeer.PORTLET_ID, id);
PortletMediatypePeer.doDelete(criteria);
criteria = new Criteria();
criteria.add(PortletCategoryPeer.PORTLET_ID, id);
PortletCategoryPeer.doDelete(criteria);
}
catch (TorqueException e)
{
logger.error("Exception Removing Portlet Entry Accesses: " + id, e);
throw new RegistryException("Exception Removing Portlet Entry: "
+ id + ", " + e.toString());
}
}
public static List fetchExtent() throws RegistryException
{
List extent = new ArrayList();
try
{
Iterator result = PortletDbEntryPeer.doSelect(new Criteria())
.iterator();
while (result.hasNext())
{
PortletEntry se =
mapDatabaseToEntry((PortletDbEntry) result.next());
extent.add(se);
}
} catch (TorqueException e)
{
String msg = "Exception Fetching Extent for Portlet ";
logger.error(msg, e);
throw new RegistryException(msg + e);
}
return extent;
}
public static void storePortletEntry(PortletEntry pe)
throws RegistryException
{
Connection conn = null;
boolean autoCommit = false;
try
{
// get fresh copy in case its changed on another node
PortletDbEntry pde = lookup(pe.getName());
if (null != pde)
{
PortletDbEntryPeer.removePortletSubObjects(pde.getId());
} else
{
pde = new PortletDbEntry();
}
conn = Torque.getConnection(DATABASE_NAME);
autoCommit = conn.getAutoCommit();
conn.setAutoCommit(false);
pde.setApplication(pe.isApplication());
pde.setCachedOnUrl(pe.isCachedOnURL());
pde.setClassname(pe.getClassname());
pde.setDescription(pe.getDescription());
pde.setHidden(pe.isHidden());
if (pe.getMetaInfo() != null)
{
pde.setImage(pe.getMetaInfo().getImage());
}
pde.setName(pe.getName());
pde.setParent(pe.getParent());
if (pe.getSecurityRef() != null)
{
pde.setSecurityRef(pe.getSecurityRef().getParent());
}
pde.setTitle(pe.getTitle());
pde.setType(pe.getType());
pde.setURL(pe.getURL());
pde.save(conn);
// parameters
Iterator parameters = pe.getParameterNames();
while (parameters.hasNext())
{
String name = (String)parameters.next();
CachedParameter cp = (CachedParameter)pe.getParameter(name);
PortletParameter pp = new PortletParameter();
pp.setCachedOnName(cp.isCachedOnName());
pp.setCachedOnValue(cp.isCachedOnValue());
pp.setDescription(cp.getDescription());
pp.setHidden(cp.isHidden());
pp.setName(cp.getName());
pp.setPortletId(pde.getId());
pp.setTitle(cp.getTitle());
pp.setType(cp.getType());
pp.setValue(cp.getValue());
MetaInfo meta = cp.getMetaInfo();
if (meta != null)
{
pp.setImage(meta.getImage());
pp.setDescription(meta.getDescription());
pp.setTitle(meta.getTitle());
}
SecurityReference ref = cp.getSecurityRef();
if (ref != null)
{
pp.setSecurityRef(ref.getParent());
}
pp.save(conn);
}
// media types
Iterator mtypes = pe.listMediaTypes();
while (mtypes.hasNext())
{
String name = (String)mtypes.next();
PortletMediatype pm = new PortletMediatype();
pm.setName(name);
pm.setPortletId(pde.getId());
pm.save(conn);
}
// categories
Iterator categories = pe.listCategories();
while (categories.hasNext())
{
Category category = (Category)categories.next();
PortletCategory pc = new PortletCategory();
pc.setName(category.getName());
pc.setGroup(category.getGroup());
pc.setPortletId(pde.getId());
pc.save(conn);
}
}
catch (Exception e)
{
try
{
conn.rollback();
} catch (Exception e2)
{
logger.error("Failed to rollback", e2);
}
e.printStackTrace();
logger.error("Exception storing Portlet Entry: " + pe.getName(), e);
throw new RegistryException("Exception storing Portlet Entry: "
+ pe.getName() + ", " + e.toString());
} finally
{
// make sure to release the database connection
Torque.closeConnection(conn);
try
{
conn.setAutoCommit(autoCommit);
} catch (Exception e)
{
}
}
}
public static void removePortletEntry(String entryName)
throws RegistryException
{
try
{
Criteria criteria = new Criteria();
criteria.add(PortletDbEntryPeer.NAME, entryName);
PortletDbEntryPeer.doDelete(criteria);
} catch (TorqueException e)
{
logger.error("Exception Removing Portlet Entry: " + entryName, e);
throw new RegistryException("Exception Removing Portlet Entry: "
+ entryName + ", " + e.toString());
}
}
}
1.1 jakarta-jetspeed/torque-om/src/java/org/apache/jetspeed/om/apps/email/EmailInbox.java
Index: EmailInbox.java
===================================================================
/*
* Copyright 2000-2001,2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.jetspeed.om.apps.email;
import org.apache.commons.lang.ObjectUtils;
import org.apache.torque.om.Persistent;
/**
* The skeleton for this class was autogenerated by Torque on:
*
* [Wed Mar 10 18:18:45 PST 2004]
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
* @version $Id: EmailInbox.java,v 1.1 2005/05/23 20:22:26 taylor Exp $
*
*/
public class EmailInbox
extends org.apache.jetspeed.om.apps.email.BaseEmailInbox
implements Persistent
{
/**
* The value for the attachment field
*/
private byte[] attachment;
/**
* Get the Attachment
*
* @return byte[]
*/
public byte[] getAttachment()
{
return attachment;
}
/**
* Set the value of Attachment
*
* @param v new value
*/
public void setAttachment(byte[] v)
{
if (!ObjectUtils.equals(this.attachment, v))
{
this.attachment = v;
setModified(true);
}
}
}
1.1 jakarta-jetspeed/torque-om/src/.cvsignore
Index: .cvsignore
===================================================================
*.log
---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org