Author: ajaquith
Date: Sun Aug 24 09:28:30 2008
New Revision: 688524
URL: http://svn.apache.org/viewvc?rev=688524&view=rev
Log:
Changed method signature for UserProfile.get/setUid() to use Strings rather
than long integers. Test and XML/JDBC UserDatabase implementations changed
also. This change was made for forward compatibility with JCR storage in 3.0.
Modified:
incubator/jspwiki/trunk/ChangeLog
incubator/jspwiki/trunk/UPGRADING
incubator/jspwiki/trunk/etc/db/hsql/userdb-setup.ddl
incubator/jspwiki/trunk/etc/db/postgresql/userdb-setup.ddl
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/Release.java
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/UserManager.java
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/user/AbstractUserDatabase.java
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/user/DefaultUserProfile.java
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/user/JDBCUserDatabase.java
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/user/UserDatabase.java
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/user/UserProfile.java
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/user/XMLUserDatabase.java
incubator/jspwiki/trunk/tests/com/ecyrd/jspwiki/auth/user/JDBCUserDatabaseTest.java
incubator/jspwiki/trunk/tests/com/ecyrd/jspwiki/auth/user/UserProfileTest.java
incubator/jspwiki/trunk/tests/com/ecyrd/jspwiki/auth/user/XMLUserDatabaseTest.java
Modified: incubator/jspwiki/trunk/ChangeLog
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/ChangeLog?rev=688524&r1=688523&r2=688524&view=diff
==============================================================================
--- incubator/jspwiki/trunk/ChangeLog (original)
+++ incubator/jspwiki/trunk/ChangeLog Sun Aug 24 09:28:30 2008
@@ -1,3 +1,11 @@
+2008-08-24 Andrew Jaquith <ajaquith AT apache DOT org>
+
+ * 2.7.0-alpha-29
+
+ * Changed method signature for UserProfile.get/setUid() to use Strings
rather
+ than long integers. Test and XML/JDBC UserDatabase implementations
changed
+ also. This change was made for forward compatibility with JCR storage
in 3.0.
+
2008-08-24 Dirk Frederickx <[EMAIL PROTECTED]>
* 2.7.0-alpha-28
Modified: incubator/jspwiki/trunk/UPGRADING
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/UPGRADING?rev=688524&r1=688523&r2=688524&view=diff
==============================================================================
--- incubator/jspwiki/trunk/UPGRADING (original)
+++ incubator/jspwiki/trunk/UPGRADING Sun Aug 24 09:28:30 2008
@@ -142,7 +142,7 @@
column name type
--------------------------------------------------------------------------------------------
- uid bigint (or other long integer
equivalent)
+ uid varchar (100)
lockExpiry timestamp
attributes longvarchar (or other large text/memo
field)
@@ -182,7 +182,7 @@
-> User profiles now have a unique identifier associated with them. These
are stored by the XML and JDBC UserDatabase implementations. UIDs are
- long integers. They are transparently added to any profiles that do
+ Strings. They are transparently added to any profiles that do
not have them, on the fly, as users log in. The UID property is not
widely used yet, but we expect it to be useful for security logging
in future releases of JSPWiki.
Modified: incubator/jspwiki/trunk/etc/db/hsql/userdb-setup.ddl
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/etc/db/hsql/userdb-setup.ddl?rev=688524&r1=688523&r2=688524&view=diff
==============================================================================
--- incubator/jspwiki/trunk/etc/db/hsql/userdb-setup.ddl (original)
+++ incubator/jspwiki/trunk/etc/db/hsql/userdb-setup.ddl Sun Aug 24 09:28:30
2008
@@ -5,7 +5,7 @@
drop user @jdbc.user.id@;
create table @jspwiki.userdatabase.table@ (
- @jspwiki.userdatabase.uid@ bigint,
+ @jspwiki.userdatabase.uid@ varchar(100),
@jspwiki.userdatabase.email@ varchar(100),
@jspwiki.userdatabase.fullName@ varchar(100),
@jspwiki.userdatabase.loginName@ varchar(100) not null,
Modified: incubator/jspwiki/trunk/etc/db/postgresql/userdb-setup.ddl
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/etc/db/postgresql/userdb-setup.ddl?rev=688524&r1=688523&r2=688524&view=diff
==============================================================================
--- incubator/jspwiki/trunk/etc/db/postgresql/userdb-setup.ddl (original)
+++ incubator/jspwiki/trunk/etc/db/postgresql/userdb-setup.ddl Sun Aug 24
09:28:30 2008
@@ -5,13 +5,16 @@
drop user @jdbc.user.id@;
create table @jspwiki.userdatabase.table@ (
+ @jspwiki.userdatabase.uid@ varchar(100),
@jspwiki.userdatabase.email@ varchar(100),
@jspwiki.userdatabase.fullName@ varchar(100),
@jspwiki.userdatabase.loginName@ varchar(100) not null primary key,
@jspwiki.userdatabase.password@ varchar(100),
@jspwiki.userdatabase.wikiName@ varchar(100),
@jspwiki.userdatabase.created@ timestamp,
- @jspwiki.userdatabase.modified@ timestamp
+ @jspwiki.userdatabase.modified@ timestamp,
+ @jspwiki.userdatabase.lockExpiry@ timestamp,
+ @jspwiki.userdatabase.attributes@ longvarchar,
);
create table @jspwiki.userdatabase.roleTable@ (
@@ -42,26 +45,32 @@
grant select, insert, update, delete on @jspwiki.groupdatabase.membertable@ to
@jdbc.user.id@;
insert into @jspwiki.userdatabase.table@ (
+ @jspwiki.userdatabase.uid@,
@jspwiki.userdatabase.email@,
@jspwiki.userdatabase.fullName@,
@jspwiki.userdatabase.loginName@,
@jspwiki.userdatabase.password@,
- @jspwiki.userdatabase.wikiName@
+ @jspwiki.userdatabase.wikiName@,
+ @jspwiki.userdatabase.attributes@
) values (
+ '-7739839977499061014',
'[EMAIL PROTECTED]',
'Janne Jalkanen',
'janne',
'{SSHA}1WFv9OV11pD5IySgVH3sFa2VlCyYjbLrcVT/qw==',
- 'JanneJalkanen'
+ 'JanneJalkanen',
+ 'attribute1=some random value\nattribute2=another value'
);
insert into @jspwiki.userdatabase.table@ (
+ @jspwiki.userdatabase.uid@,
@jspwiki.userdatabase.email@,
@jspwiki.userdatabase.fullName@,
@jspwiki.userdatabase.loginName@,
@jspwiki.userdatabase.password@,
@jspwiki.userdatabase.wikiName@
) values (
+ '-6852820166199419346',
'[EMAIL PROTECTED]',
'Administrator',
'admin',
Modified: incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/Release.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/Release.java?rev=688524&r1=688523&r2=688524&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/Release.java (original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/Release.java Sun Aug 24
09:28:30 2008
@@ -77,7 +77,7 @@
* <p>
* If the build identifier is empty, it is not added.
*/
- public static final String BUILD = "28";
+ public static final String BUILD = "29";
/**
* This is the generic version string you should use
Modified: incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/UserManager.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/UserManager.java?rev=688524&r1=688523&r2=688524&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/UserManager.java
(original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/UserManager.java Sun Aug
24 09:28:30 2008
@@ -643,7 +643,7 @@
* @return the user profile
* @throws NoSuchPrincipalException never...
*/
- public UserProfile findByUid( long uid ) throws
NoSuchPrincipalException
+ public UserProfile findByUid( String uid ) throws
NoSuchPrincipalException
{
throw new NoSuchPrincipalException("No user profiles available");
}
Modified:
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/user/AbstractUserDatabase.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/user/AbstractUserDatabase.java?rev=688524&r1=688523&r2=688524&view=diff
==============================================================================
---
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/user/AbstractUserDatabase.java
(original)
+++
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/user/AbstractUserDatabase.java
Sun Aug 24 09:28:30 2008
@@ -48,7 +48,6 @@
protected static final Logger log = Logger.getLogger(
AbstractUserDatabase.class );
protected static final String SHA_PREFIX = "{SHA}";
protected static final String SSHA_PREFIX = "{SSHA}";
- protected static final long UID_NOT_SET = 0;
/**
* No-op method that in previous versions of JSPWiki was intended to
@@ -281,15 +280,15 @@
* @param db The database for which the UID should be generated.
* @return A random, unique UID.
*/
- protected static long generateUid( UserDatabase db )
+ protected static String generateUid( UserDatabase db )
{
// Keep generating UUIDs until we find one that doesn't collide
- long uid;
+ String uid = null;
boolean collision;
do
{
- uid = UUID.randomUUID().getLeastSignificantBits();
+ uid = UUID.randomUUID().toString();
collision = true;
try
{
@@ -300,7 +299,7 @@
collision = false;
}
}
- while ( collision || uid == UID_NOT_SET );
+ while ( collision || uid == null );
return uid;
}
Modified:
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/user/DefaultUserProfile.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/user/DefaultUserProfile.java?rev=688524&r1=688523&r2=688524&view=diff
==============================================================================
---
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/user/DefaultUserProfile.java
(original)
+++
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/user/DefaultUserProfile.java
Sun Aug 24 09:28:30 2008
@@ -56,7 +56,7 @@
private String m_password = null;
- private long m_uid = -1;
+ private String m_uid = null;
private String m_wikiname = null;
@@ -319,7 +319,7 @@
/**
* [EMAIL PROTECTED]
*/
- public long getUid()
+ public String getUid()
{
return m_uid;
}
@@ -350,7 +350,7 @@
/**
* [EMAIL PROTECTED]
*/
- public void setUid( long uid )
+ public void setUid( String uid )
{
m_uid = uid;
}
Modified:
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/user/JDBCUserDatabase.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/user/JDBCUserDatabase.java?rev=688524&r1=688523&r2=688524&view=diff
==============================================================================
---
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/user/JDBCUserDatabase.java
(original)
+++
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/user/JDBCUserDatabase.java
Sun Aug 24 09:28:30 2008
@@ -382,9 +382,9 @@
/**
* @see com.ecyrd.jspwiki.auth.user.UserDatabase#findByWikiName(String)
*/
- public UserProfile findByUid( long uid ) throws NoSuchPrincipalException
+ public UserProfile findByUid( String uid ) throws NoSuchPrincipalException
{
- return findByPreparedStatement( m_findByUid, Long.valueOf( uid ) );
+ return findByPreparedStatement( m_findByUid, uid );
}
/**
@@ -715,7 +715,7 @@
{
// User is new: insert new user record
ps = conn.prepareStatement( m_insertProfile );
- ps.setLong( 1, profile.getUid() );
+ ps.setString( 1, profile.getUid() );
ps.setString( 2, profile.getEmail() );
ps.setString( 3, profile.getFullname() );
ps.setString( 4, password );
@@ -760,7 +760,7 @@
{
// User exists: modify existing record
ps = conn.prepareStatement( m_updateProfile );
- ps.setLong( 1, profile.getUid() );
+ ps.setString( 1, profile.getUid() );
ps.setString( 2, profile.getEmail() );
ps.setString( 3, profile.getFullname() );
ps.setString( 4, password );
@@ -857,8 +857,8 @@
profile = newProfile();
// Fetch the basic user attributes
- profile.setUid( rs.getLong( m_uid ) );
- if ( profile.getUid() == UID_NOT_SET )
+ profile.setUid( rs.getString( m_uid ) );
+ if ( profile.getUid() == null )
{
profile.setUid( generateUid( this ) );
}
Modified:
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/user/UserDatabase.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/user/UserDatabase.java?rev=688524&r1=688523&r2=688524&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/user/UserDatabase.java
(original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/user/UserDatabase.java
Sun Aug 24 09:28:30 2008
@@ -134,7 +134,7 @@
* @return the user profile
* @since 2.8
*/
- public UserProfile findByUid( long uid ) throws NoSuchPrincipalException;
+ public UserProfile findByUid( String uid ) throws NoSuchPrincipalException;
/**
* Looks up and returns the first [EMAIL PROTECTED] UserProfile} in the
user database
Modified:
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/user/UserProfile.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/user/UserProfile.java?rev=688524&r1=688523&r2=688524&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/user/UserProfile.java
(original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/user/UserProfile.java
Sun Aug 24 09:28:30 2008
@@ -100,10 +100,10 @@
/**
* Returns the unique identifier for the user profile. If not previously
- * set, the value will be -1.
+ * set, the value will be <code>null</code>.
* @return the unique ID.
*/
- public long getUid();
+ public String getUid();
/**
* Returns the user's wiki name, based on the full name with all
@@ -189,7 +189,7 @@
* are required <em>not</em> to change the unique identifier after the
initial save.
* @param uid the unique identifier to set
*/
- public void setUid( long uid );
+ public void setUid( String uid );
/**
* No-op method. In previous versions of JSPWiki, the method
Modified:
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/user/XMLUserDatabase.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/user/XMLUserDatabase.java?rev=688524&r1=688523&r2=688524&view=diff
==============================================================================
---
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/user/XMLUserDatabase.java
(original)
+++
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/user/XMLUserDatabase.java
Sun Aug 24 09:28:30 2008
@@ -190,9 +190,9 @@
/**
* [EMAIL PROTECTED]
*/
- public UserProfile findByUid( long uid ) throws NoSuchPrincipalException
+ public UserProfile findByUid( String uid ) throws NoSuchPrincipalException
{
- UserProfile profile = findByAttribute( UID, Long.toString( uid ) );
+ UserProfile profile = findByAttribute( UID, uid );
if ( profile != null )
{
return profile;
@@ -619,8 +619,8 @@
UserProfile profile = newProfile();
// Parse basic attributes
- profile.setUid( parseLong( user.getAttribute( UID ) ) );
- if ( profile.getUid() == UID_NOT_SET )
+ profile.setUid( user.getAttribute( UID ) );
+ if ( profile.getUid() == null )
{
profile.setUid( generateUid( this ) );
}
Modified:
incubator/jspwiki/trunk/tests/com/ecyrd/jspwiki/auth/user/JDBCUserDatabaseTest.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/tests/com/ecyrd/jspwiki/auth/user/JDBCUserDatabaseTest.java?rev=688524&r1=688523&r2=688524&view=diff
==============================================================================
---
incubator/jspwiki/trunk/tests/com/ecyrd/jspwiki/auth/user/JDBCUserDatabaseTest.java
(original)
+++
incubator/jspwiki/trunk/tests/com/ecyrd/jspwiki/auth/user/JDBCUserDatabaseTest.java
Sun Aug 24 09:28:30 2008
@@ -166,7 +166,7 @@
try
{
UserProfile profile = m_db.findByEmail( "[EMAIL PROTECTED]" );
- assertEquals( -7739839977499061014L, profile.getUid() );
+ assertEquals( "-7739839977499061014", profile.getUid() );
assertEquals( "janne", profile.getLoginName() );
assertEquals( "Janne Jalkanen", profile.getFullname() );
assertEquals( "JanneJalkanen", profile.getWikiName() );
@@ -196,7 +196,7 @@
try
{
UserProfile profile = m_db.findByFullName( "Janne Jalkanen" );
- assertEquals( -7739839977499061014L, profile.getUid() );
+ assertEquals( "-7739839977499061014", profile.getUid() );
assertEquals( "janne", profile.getLoginName() );
assertEquals( "Janne Jalkanen", profile.getFullname() );
assertEquals( "JanneJalkanen", profile.getWikiName() );
@@ -225,8 +225,8 @@
{
try
{
- UserProfile profile = m_db.findByUid( -7739839977499061014L );
- assertEquals( -7739839977499061014L, profile.getUid() );
+ UserProfile profile = m_db.findByUid( "-7739839977499061014" );
+ assertEquals( "-7739839977499061014", profile.getUid() );
assertEquals( "janne", profile.getLoginName() );
assertEquals( "Janne Jalkanen", profile.getFullname() );
assertEquals( "JanneJalkanen", profile.getWikiName() );
@@ -256,7 +256,7 @@
try
{
UserProfile profile = m_db.findByWikiName( "JanneJalkanen" );
- assertEquals( -7739839977499061014L, profile.getUid() );
+ assertEquals( "-7739839977499061014", profile.getUid() );
assertEquals( "janne", profile.getLoginName() );
assertEquals( "Janne Jalkanen", profile.getFullname() );
assertEquals( "JanneJalkanen", profile.getWikiName() );
@@ -286,7 +286,7 @@
try
{
UserProfile profile = m_db.findByLoginName( "janne" );
- assertEquals( -7739839977499061014L, profile.getUid() );
+ assertEquals( "-7739839977499061014", profile.getUid() );
assertEquals( "janne", profile.getLoginName() );
assertEquals( "Janne Jalkanen", profile.getFullname() );
assertEquals( "JanneJalkanen", profile.getWikiName() );
Modified:
incubator/jspwiki/trunk/tests/com/ecyrd/jspwiki/auth/user/UserProfileTest.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/tests/com/ecyrd/jspwiki/auth/user/UserProfileTest.java?rev=688524&r1=688523&r2=688524&view=diff
==============================================================================
---
incubator/jspwiki/trunk/tests/com/ecyrd/jspwiki/auth/user/UserProfileTest.java
(original)
+++
incubator/jspwiki/trunk/tests/com/ecyrd/jspwiki/auth/user/UserProfileTest.java
Sun Aug 24 09:28:30 2008
@@ -82,9 +82,9 @@
public void testSetUid()
{
UserProfile p = m_db.newProfile();
- assertNotSame( 1234567890, p.getUid() );
- p.setUid( 1234567890 );
- assertEquals( 1234567890, p.getUid() );
+ assertNotSame( "1234567890", p.getUid() );
+ p.setUid( "1234567890" );
+ assertEquals( "1234567890", p.getUid() );
}
public void testEquals()
Modified:
incubator/jspwiki/trunk/tests/com/ecyrd/jspwiki/auth/user/XMLUserDatabaseTest.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/tests/com/ecyrd/jspwiki/auth/user/XMLUserDatabaseTest.java?rev=688524&r1=688523&r2=688524&view=diff
==============================================================================
---
incubator/jspwiki/trunk/tests/com/ecyrd/jspwiki/auth/user/XMLUserDatabaseTest.java
(original)
+++
incubator/jspwiki/trunk/tests/com/ecyrd/jspwiki/auth/user/XMLUserDatabaseTest.java
Sun Aug 24 09:28:30 2008
@@ -102,7 +102,7 @@
try
{
UserProfile profile = m_db.findByEmail("[EMAIL PROTECTED]");
- assertEquals( -7739839977499061014L, profile.getUid() );
+ assertEquals( "-7739839977499061014", profile.getUid() );
assertEquals("janne", profile.getLoginName());
assertEquals("Janne Jalkanen", profile.getFullname());
assertEquals("JanneJalkanen", profile.getWikiName());
@@ -130,7 +130,7 @@
try
{
UserProfile profile = m_db.findByFullName( "Janne Jalkanen" );
- assertEquals( -7739839977499061014L, profile.getUid() );
+ assertEquals( "-7739839977499061014", profile.getUid() );
assertEquals( "janne", profile.getLoginName() );
assertEquals( "Janne Jalkanen", profile.getFullname() );
assertEquals( "JanneJalkanen", profile.getWikiName() );
@@ -159,8 +159,8 @@
{
try
{
- UserProfile profile = m_db.findByUid( -7739839977499061014L );
- assertEquals( -7739839977499061014L, profile.getUid() );
+ UserProfile profile = m_db.findByUid( "-7739839977499061014" );
+ assertEquals( "-7739839977499061014", profile.getUid() );
assertEquals( "janne", profile.getLoginName() );
assertEquals( "Janne Jalkanen", profile.getFullname() );
assertEquals( "JanneJalkanen", profile.getWikiName() );
@@ -190,7 +190,7 @@
try
{
UserProfile profile = m_db.findByWikiName("JanneJalkanen");
- assertEquals( -7739839977499061014L, profile.getUid() );
+ assertEquals( "-7739839977499061014", profile.getUid() );
assertEquals("janne", profile.getLoginName());
assertEquals("Janne Jalkanen", profile.getFullname());
assertEquals("JanneJalkanen", profile.getWikiName());
@@ -218,7 +218,7 @@
try
{
UserProfile profile = m_db.findByLoginName("janne");
- assertEquals( -7739839977499061014L, profile.getUid() );
+ assertEquals( "-7739839977499061014", profile.getUid() );
assertEquals("janne", profile.getLoginName());
assertEquals("Janne Jalkanen", profile.getFullname());
assertEquals("JanneJalkanen", profile.getWikiName());