Integrated r1954,r1956-r1961,r1964 ccm-core:

- Upgrade Saxon from 6.5.2 to 6.5.5
- Fixed version of junit in ccm-core/application.xml so that unit tests compile 
- Minor cleanup of validation for administration of users
- Now uses reflection for Oracle-specific code so system builds without the 
  Oracle libraries
- Fixed SQL loading problems on Windoze due to back-slash problems 
- Created index on lower(screen_name) to stop full table scan when there is 
  a large number of users in the database

Trunk hb is now fuly in sync with fedorahosted up to r1965.
We left off:
- r1965: Prototye JSR portlet implementation as it does not access CCM
  content
- r1940-r1942: Removal of $Id: from code, we should retain information about
  time and developer who recently changed the code
- r1879 introducing eclipce configuration in trunk root (wrong location and
  we don't use eclipse for now)
- r??? (ccm-sample) as it does not provide usefull functionality for now



git-svn-id: https://svn.libreccm.org/ccm/trunk@255 8810af33-2d31-482b-a856-94f89814c4df
master
pb 2009-08-29 08:01:39 +00:00
parent dec240bf3b
commit dcc4670518
15 changed files with 121 additions and 118 deletions

View File

@ -9,7 +9,7 @@
buildHooks="build-hooks.xml">
<ccm:dependencies>
<ccm:buildRequires name="httpunit" version="1.5.4" relation="ge"/>
<ccm:buildRequires name="junit" version="3.8" relation="ge"/>
<ccm:buildRequires name="junit" version="3.8.1" relation="ge"/>
<ccm:buildRequires name="junitperf" version="1.8" relation="ge"/>
<ccm:buildRequires name="ccm-servlet" version="2.3" relation="ge"/>
<ccm:buildRequires name="ojdbc14"/>

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -19,3 +19,5 @@
-- $DateTime: 2004/08/16 18:10:38 $
create unique index users_name_id_idx on users(name_id);
create unique index users_lower_screen_name_idx on users(lower(screen_name));

View File

@ -88,7 +88,9 @@ public class LoadSQLPlusScript {
}
public void loadSQLPlusScript (String scriptFilename) {
loadScript(scriptFilename);
if (scriptFilename != null) {
loadScript(scriptFilename.replace('\\', '/'));
}
}
protected void loadScript(String scriptFilename) {
@ -100,6 +102,7 @@ public class LoadSQLPlusScript {
try {
return new FileReader(name);
} catch (FileNotFoundException e) {
s_log.warn("File not found: " + name);
return null;
}
}

View File

@ -63,6 +63,7 @@ public abstract class SQLLoader {
final InputStream is = cload.getResourceAsStream(resourceName);
if (is == null) {
s_log.warn("Resource not found: " + resourceName);
return null;
} else {
return new InputStreamReader(is);
@ -166,7 +167,7 @@ public abstract class SQLLoader {
if (front == null) {
resolved = back;
} else {
resolved = front + File.separatorChar + back;
resolved = front + '/' + back;
}
if (s_log.isDebugEnabled()) {

View File

@ -22,19 +22,13 @@ import com.arsdigita.runtime.AbstractConfig;
import com.arsdigita.util.parameter.BooleanParameter;
import com.arsdigita.util.parameter.EnumerationParameter;
import com.arsdigita.util.parameter.Parameter;
import org.apache.log4j.Logger;
/**
* @author Justin Ross
* @see com.arsdigita.kernel.Kernel
* @version $Id: KernelConfig.java 1233 2006-06-22 12:37:05Z apevec $
*/
public final class KernelConfig extends AbstractConfig {
public static final String versionId =
"$Id: KernelConfig.java 1233 2006-06-22 12:37:05Z apevec $" +
"$Author: apevec $" +
"$DateTime: 2004/08/16 18:10:38 $";
private static final Logger s_log = Logger.getLogger(KernelConfig.class);
private final Parameter m_debug;
private final Parameter m_permissions;
@ -88,6 +82,14 @@ public final class KernelConfig extends AbstractConfig {
return (String) get(m_identifier);
}
public final boolean emailIsPrimaryIdentifier() {
return "email".equals(get(m_identifier));
}
public final boolean screenNameIsPrimaryIdentifier() {
return !emailIsPrimaryIdentifier();
}
public final boolean isSSOenabled() {
return ((Boolean) get(m_SSO)).booleanValue();
}

View File

@ -36,7 +36,6 @@ import com.arsdigita.persistence.OID;
import com.arsdigita.persistence.PersistenceException;
import com.arsdigita.persistence.SessionManager;
import com.arsdigita.persistence.metadata.ObjectType;
import org.apache.log4j.Logger;
/**
* Represents a user.
@ -47,14 +46,12 @@ import org.apache.log4j.Logger;
public class User extends Party {
public static final String versionId = "$Id: User.java 1586 2007-05-31 13:05:10Z chrisgilbert23 $ by $Author: chrisgilbert23 $, $DateTime: 2004/08/16 18:10:38 $";
private PersonName m_name;
private boolean m_external;
/** An attribute name for the underlying data object. */
public static final String BANNED = "banned";
/** An attribute name for the underlying data object. */
public static final String BANNED = "banned";
/**
* Every instance of group must encapsulate a data object whose
@ -84,9 +81,7 @@ public class User extends Party {
* @see com.arsdigita.persistence.DataObject
* @see com.arsdigita.persistence.OID
**/
public static User retrieve(BigDecimal id)
throws DataObjectNotFoundException
{
public static User retrieve(BigDecimal id) throws DataObjectNotFoundException {
return retrieve(new OID(BASE_DATA_OBJECT_TYPE, id));
}
@ -108,11 +103,9 @@ public class User extends Party {
* @see com.arsdigita.persistence.OID
* @see DomainObjectFactory#newInstance(OID)
**/
public static User retrieve(OID oid)
throws DataObjectNotFoundException
{
public static User retrieve(OID oid) throws DataObjectNotFoundException {
User user = (User) DomainObjectFactory.newInstance(oid);
if (user==null) {
if (user == null) {
throw new
DataObjectNotFoundException("Domain object factory " +
"produced null user for OID " +
@ -133,7 +126,7 @@ public class User extends Party {
public static User retrieve(DataObject userData) {
User user = (User) DomainObjectFactory.newInstance(userData);
if (user==null) {
if (user == null) {
throw new RuntimeException("Domain object factory produced " +
"null user for data object " +
userData);
@ -172,13 +165,11 @@ public class User extends Party {
**/
public User(boolean external) {
this(BASE_DATA_OBJECT_TYPE);
m_external = external;
m_external = external;
}
public User() {
this (false);
this(false);
}
@ -201,8 +192,9 @@ public class User extends Party {
}
public User(String givenName, String familyName, String email) {
this (givenName, familyName, email, false);
this(givenName, familyName, email, false);
}
/**
* Constructor in which the contained <code>DataObject</code> is
* initialized with a new <code>DataObject</code> with an
@ -220,7 +212,6 @@ public class User extends Party {
super(typeName);
}
/**
* Constructor in which the contained <code>DataObject</code> is
* initialized with a new <code>DataObject</code> with an
@ -287,7 +278,7 @@ public class User extends Party {
m_name = new PersonName();
setAssociation("name", m_name);
set(BANNED, new Boolean(false));
set(BANNED, new Boolean(false));
}
}
@ -390,31 +381,28 @@ public class User extends Party {
// If the domain object is new or the primary email has been changed,
// validate it.
if ( (isNew() || isPropertyModified("primaryEmail")) &&
KernelHelper.emailIsPrimaryIdentifier()) {
if ((isNew() || isPropertyModified("primaryEmail")) && Kernel.getConfig().emailIsPrimaryIdentifier()) {
validatePrimaryEmail();
}
if ((isNew() || isPropertyModified("primaryEmail")
|| isPropertyModified("screenName")) &&
!KernelHelper.emailIsPrimaryIdentifier()) {
if ((isNew() || isPropertyModified("primaryEmail") || isPropertyModified("screenName"))
&& !Kernel.getConfig().emailIsPrimaryIdentifier()) {
if (getPrimaryEmail() == null) {
throw new RuntimeException("Primary email must be specified");
}
validateScreenName();
}
if (getPrimaryEmail() == null) {
throw new RuntimeException("Primary email must be specified");
}
validateScreenName();
}
}
protected void afterSave() {
super.afterSave();
// users have admin permissions on themselves (needed to change
// email, for instance).
// users have admin permissions on themselves (needed to change
// email, for instance).
if (!m_external) {
PermissionDescriptor perm = new PermissionDescriptor(PrivilegeDescriptor.ADMIN, this, this);
PermissionService.grantPermission(perm);
}
PermissionDescriptor perm = new PermissionDescriptor(PrivilegeDescriptor.ADMIN, this, this);
PermissionService.grantPermission(perm);
}
}
/**
@ -444,35 +432,29 @@ public class User extends Party {
}
// Verify uniqueness of email
DataQuery query = SessionManager.getSession()
.retrieveQuery("com.arsdigita.kernel.UserPrimaryEmail");
Filter f =
query.addFilter("primaryEmailAddress=:email " +
"and userID != :userID");
DataQuery query = SessionManager.getSession().retrieveQuery("com.arsdigita.kernel.UserPrimaryEmail");
Filter f = query.addFilter("primaryEmailAddress=:email " + "and userID != :userID");
f.set("email", email.getEmailAddress());
f.set("userID", getID());
if (query.size()>0) {
if (query.size() > 0) {
throw new RuntimeException("Primary email must be unique among users");
}
}
protected void validateScreenName() {
String sn = getScreenName().toLowerCase();
String sn = getScreenName();
if (sn == null) {
throw new RuntimeException("Screen Name must be specified");
}
// Verify uniqueness of screen name
DataQuery query = SessionManager.getSession()
.retrieveQuery("com.arsdigita.kernel.UserPrimaryEmail");
Filter f =
query.addFilter("lowerScreenName=:sn " +
"and userID != :userID");
f.set("sn", sn);
DataQuery query = SessionManager.getSession().retrieveQuery("com.arsdigita.kernel.UserPrimaryEmail");
Filter f = query.addFilter("lowerScreenName=:sn " + "and userID != :userID");
f.set("sn", sn.toLowerCase());
f.set("userID", getID());
if (query.size()>0) {
if (query.size() > 0) {
throw new RuntimeException("Screen Name must be unique among users");
}
}
@ -481,19 +463,18 @@ public class User extends Party {
return SessionManager.getSession().retrieveDataOperation(name);
}
/**
* Getter for the banned property, which is persisted to the database
*/
public boolean isBanned() {
return ((Boolean) get(BANNED)).booleanValue();
/**
* Getter for the banned property, which is persisted to the database
*/
public boolean isBanned() {
return ((Boolean) get(BANNED)).booleanValue();
}
/**
* Setter for the banned property, which is persisted to the database
*/
public void setBanned(boolean b) {
set(BANNED, new Boolean(b));
}
/**
* Setter for the banned property, which is persisted to the database
*/
public void setBanned(boolean b) {
set(BANNED, new Boolean(b));
}
}

View File

@ -37,6 +37,6 @@ class CreateUserPane extends SegmentedPanel
}
public void reset(PageState ps) {
// empty
ps.setValue(USER_ID_PARAM, null);
}
}

View File

@ -18,6 +18,8 @@
*/
package com.arsdigita.ui.admin;
import javax.mail.internet.InternetAddress;
import com.arsdigita.bebop.FormProcessException;
import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.event.FormInitListener;
@ -28,7 +30,6 @@ import com.arsdigita.kernel.EmailAddress;
import com.arsdigita.kernel.PersonName;
import com.arsdigita.kernel.User;
import com.arsdigita.kernel.UserAuthentication;
import javax.mail.internet.InternetAddress;
/**
* Form used to add a new user to the system.
@ -58,8 +59,6 @@ class UserAddForm extends UserForm
m_question.addValidationListener
(new NotEmptyValidationListener());
m_answer.addValidationListener
(new NotEmptyValidationListener());
}
/**

View File

@ -35,10 +35,12 @@ import com.arsdigita.bebop.parameters.NotEmptyValidationListener;
import com.arsdigita.bebop.parameters.StringLengthValidationListener;
import com.arsdigita.bebop.parameters.StringParameter;
import com.arsdigita.bebop.parameters.URLParameter;
import com.arsdigita.kernel.Kernel;
import com.arsdigita.persistence.DataQuery;
import com.arsdigita.persistence.Filter;
import com.arsdigita.persistence.SessionManager;
import com.arsdigita.ui.login.PasswordValidationListener;
import com.arsdigita.util.StringUtils;
import java.math.BigDecimal;
import javax.mail.internet.InternetAddress;
@ -130,7 +132,7 @@ class UserForm extends Form implements FormValidationListener, AdminConstants {
// Password answer
m_answer = new TextField(new StringParameter(USER_FORM_INPUT_ANSWER));
m_answer.setSize(30);
m_answer.setSize(50);
add(USER_FORM_LABEL_ANSWER);
add(m_answer);
@ -140,6 +142,7 @@ class UserForm extends Form implements FormValidationListener, AdminConstants {
(new EmailParameter(USER_FORM_INPUT_PRIMARY_EMAIL));
m_primaryEmail.addValidationListener
(new NotEmptyValidationListener());
m_primaryEmail.setSize(50);
add(USER_FORM_LABEL_PRIMARY_EMAIL);
add(m_primaryEmail);
@ -150,12 +153,16 @@ class UserForm extends Form implements FormValidationListener, AdminConstants {
m_additionalEmail = new TextField
(new EmailParameter(USER_FORM_INPUT_ADDITIONAL_EMAIL));
m_additionalEmail.setSize(50);
add(USER_FORM_LABEL_ADDITIONAL_EMAIL);
add(m_additionalEmail);
// Screen name
m_screenName = new TextField
(new StringParameter(USER_FORM_INPUT_SCREEN_NAME));
if (Kernel.getConfig().screenNameIsPrimaryIdentifier()) {
m_screenName.addValidationListener(new NotEmptyValidationListener());
}
add(USER_FORM_LABEL_SCREEN_NAME);
add(m_screenName);
@ -204,17 +211,11 @@ class UserForm extends Form implements FormValidationListener, AdminConstants {
String password = (String) m_password.getValue(ps);
String confirm = (String) m_confirmPassword.getValue(ps);
if (password != null && confirm != null) {
if (!StringUtils.emptyString(password) && !StringUtils.emptyString(confirm)) {
if (!password.equals(confirm)) {
data.addError(USER_FORM_INPUT_PASSWORD_CONFIRMATION,
(String) USER_FORM_ERROR_PASSWORD_NOT_MATCH.localize(req));
}
} else {
if (password != null || confirm != null) {
// One of the field is null.
data.addError(USER_FORM_INPUT_PASSWORD_CONFIRMATION,
(String) USER_FORM_ERROR_PASSWORD_NOT_MATCH.localize(req));
}
}
}

View File

@ -18,28 +18,28 @@
*/
package com.redhat.persistence.pdl.adapters;
import com.arsdigita.db.DbHelper;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.lang.reflect.InvocationTargetException;
import java.sql.Blob;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Types;
import com.arsdigita.db.DbHelper;
/**
* BlobAd
*
* @author Rafael H. Schloming &lt;rhs@mit.edu&gt;
* @version $Revision: #7 $ $Date: 2004/08/16 $
* @version $Id: BlobAd.java 287 2005-02-22 00:29:02Z sskracic $
**/
public class BlobAd extends SimpleAdapter {
public final static String versionId = "$Id: BlobAd.java 287 2005-02-22 00:29:02Z sskracic $ by $Author: sskracic $, $DateTime: 2004/08/16 18:10:38 $";
public BlobAd() {
super("global.Blob", Types.BLOB);
}
@ -75,11 +75,9 @@ public class BlobAd extends SimpleAdapter {
return;
}
/* Jens Pelzetter 2009-03-16 commented out to get rid of Netbeans errors */
/*oracle.sql.BLOB blob =
(oracle.sql.BLOB) rs.getBlob(column);
OutputStream out = blob.getBinaryOutputStream();
Blob blob = rs.getBlob(column);
try {
OutputStream out = (OutputStream)(blob.getClass().getMethod("getBinaryOutputStream", new Class[0]).invoke(blob));
out.write((byte[]) value);
out.flush();
out.close();
@ -88,8 +86,18 @@ public class BlobAd extends SimpleAdapter {
// persistence exception here breaks ant verify-pdl
// because the classpath isn't set up to include
// com.arsdigita.util.*
throw new Error("Unable to write LOB: " + e);
}*/
throw new Error("Unable to write LOB", e);
} catch (IllegalArgumentException e) {
throw new RuntimeException("Unable to write BLOB", e);
} catch (SecurityException e) {
throw new RuntimeException("Unable to write BLOB", e);
} catch (IllegalAccessException e) {
throw new RuntimeException("Unable to write BLOB", e);
} catch (InvocationTargetException e) {
throw new RuntimeException("Unable to write BLOB", e);
} catch (NoSuchMethodException e) {
throw new RuntimeException("Unable to write BLOB", e);
}
}
}

View File

@ -18,9 +18,9 @@
*/
package com.redhat.persistence.pdl.adapters;
import com.arsdigita.db.DbHelper;
import java.io.IOException;
import java.io.Writer;
import java.lang.reflect.InvocationTargetException;
import java.sql.Clob;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
@ -28,21 +28,19 @@ import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Types;
import com.arsdigita.db.DbHelper;
/**
* StringAd: StringAdapter class
*
*
* @author Rafael H. Schloming &lt;rhs@mit.edu&gt;
* @version $Revision: #7 $ $Date: 2004/08/16 $
* @version $Id: StringAd.java 287 2005-02-22 00:29:02Z sskracic $
**/
public class StringAd extends SimpleAdapter {
public final static String versionId =
"$Id: StringAd.java 287 2005-02-22 00:29:02Z sskracic $" +
" by $Author: sskracic $, $DateTime: 2004/08/16 18:10:38 $";
public StringAd() {
super("global.String", Types.VARCHAR);
}
@ -78,11 +76,9 @@ public class StringAd extends SimpleAdapter {
return;
}
/* Jens Pelzetter 2009-03-16 commented out to get rid of Netbeans errors */
/*oracle.sql.CLOB clob =
(oracle.sql.CLOB) rs.getClob(column);
Writer out = clob.getCharacterOutputStream();
Clob clob = rs.getClob(column);
try {
Writer out = (Writer)clob.getClass().getMethod("getCharacterOutputStream", new Class[0]).invoke(clob);
out.write(((String) value).toCharArray());
out.flush();
out.close();
@ -92,6 +88,17 @@ public class StringAd extends SimpleAdapter {
// because the classpath isn't set up to include
// com.arsdigita.util.*
throw new Error("Unable to write LOB: " + e);
}*/
} catch (IllegalArgumentException e) {
throw new RuntimeException("Unable to write CLOB", e);
} catch (SecurityException e) {
throw new RuntimeException("Unable to write CLOB", e);
} catch (IllegalAccessException e) {
throw new RuntimeException("Unable to write CLOB", e);
} catch (InvocationTargetException e) {
throw new RuntimeException("Unable to write CLOB", e);
} catch (NoSuchMethodException e) {
throw new RuntimeException("Unable to write CLOB", e);
}
}
}

View File

@ -18,28 +18,28 @@
*/
package com.arsdigita.persistence;
import com.arsdigita.db.DbHelper;
import com.arsdigita.persistence.DataObject;
import com.arsdigita.persistence.OID;
import java.io.Writer;
import java.lang.reflect.InvocationTargetException;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.sql.Clob;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import org.apache.log4j.Logger;
import com.arsdigita.db.DbHelper;
/**
* LobTest - for testing Blob and Clob datatype.
*
* @author Jeff Teeters
* @version $Revision: #17 $ $Date: 2004/08/16 $
* @version $Id: LobTest.java 745 2005-09-02 10:50:34Z sskracic $
*/
public class LobTest extends PersistenceTestCase {
public static final String versionId = "$Id: LobTest.java 745 2005-09-02 10:50:34Z sskracic $ by $Author: sskracic $, $DateTime: 2004/08/16 18:10:38 $";
private Logger s_cat =
Logger.getLogger(LobTest.class);
@ -253,7 +253,6 @@ public class LobTest extends PersistenceTestCase {
dt.save();
dt = getSession().retrieve(new OID("examples.Datatype", BigInteger.ZERO));
String bar = (String) dt.get("string");
String foundString = (String) dt.get("clob");
dt.delete();
@ -365,7 +364,7 @@ public class LobTest extends PersistenceTestCase {
private void executeOracleUpdate(Connection conn, String testString,
int id)
throws java.sql.SQLException, java.io.IOException {
throws java.sql.SQLException, java.io.IOException, IllegalArgumentException, SecurityException, IllegalAccessException, InvocationTargetException, NoSuchMethodException {
PreparedStatement ps =
conn.prepareStatement("insert into t_datatypes (id, j_clob) " +
"values (?, EMPTY_CLOB())");
@ -383,8 +382,8 @@ public class LobTest extends PersistenceTestCase {
ps.setBigDecimal(1, new BigDecimal(BigInteger.valueOf(id)));
ResultSet rs = ps.executeQuery();
rs.next();
oracle.sql.CLOB Clob = (oracle.sql.CLOB)rs.getClob(1);
Writer char_stream = Clob.getCharacterOutputStream ();
Clob clob = rs.getClob(1);
Writer char_stream = (Writer)clob.getClass().getMethod("getCharacterOutputStream", new Class[0]).invoke(clob);
char_stream.write(testString);
char_stream.flush();
char_stream.close();