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"> buildHooks="build-hooks.xml">
<ccm:dependencies> <ccm:dependencies>
<ccm:buildRequires name="httpunit" version="1.5.4" relation="ge"/> <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="junitperf" version="1.8" relation="ge"/>
<ccm:buildRequires name="ccm-servlet" version="2.3" relation="ge"/> <ccm:buildRequires name="ccm-servlet" version="2.3" relation="ge"/>
<ccm:buildRequires name="ojdbc14"/> <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 $ -- $DateTime: 2004/08/16 18:10:38 $
create unique index users_name_id_idx on users(name_id); 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) { public void loadSQLPlusScript (String scriptFilename) {
loadScript(scriptFilename); if (scriptFilename != null) {
loadScript(scriptFilename.replace('\\', '/'));
}
} }
protected void loadScript(String scriptFilename) { protected void loadScript(String scriptFilename) {
@ -100,6 +102,7 @@ public class LoadSQLPlusScript {
try { try {
return new FileReader(name); return new FileReader(name);
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
s_log.warn("File not found: " + name);
return null; return null;
} }
} }

View File

@ -63,6 +63,7 @@ public abstract class SQLLoader {
final InputStream is = cload.getResourceAsStream(resourceName); final InputStream is = cload.getResourceAsStream(resourceName);
if (is == null) { if (is == null) {
s_log.warn("Resource not found: " + resourceName);
return null; return null;
} else { } else {
return new InputStreamReader(is); return new InputStreamReader(is);
@ -166,7 +167,7 @@ public abstract class SQLLoader {
if (front == null) { if (front == null) {
resolved = back; resolved = back;
} else { } else {
resolved = front + File.separatorChar + back; resolved = front + '/' + back;
} }
if (s_log.isDebugEnabled()) { 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.BooleanParameter;
import com.arsdigita.util.parameter.EnumerationParameter; import com.arsdigita.util.parameter.EnumerationParameter;
import com.arsdigita.util.parameter.Parameter; import com.arsdigita.util.parameter.Parameter;
import org.apache.log4j.Logger;
/** /**
* @author Justin Ross * @author Justin Ross
* @see com.arsdigita.kernel.Kernel * @see com.arsdigita.kernel.Kernel
* @version $Id: KernelConfig.java 1233 2006-06-22 12:37:05Z apevec $
*/ */
public final class KernelConfig extends AbstractConfig { 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_debug;
private final Parameter m_permissions; private final Parameter m_permissions;
@ -88,6 +82,14 @@ public final class KernelConfig extends AbstractConfig {
return (String) get(m_identifier); 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() { public final boolean isSSOenabled() {
return ((Boolean) get(m_SSO)).booleanValue(); 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.PersistenceException;
import com.arsdigita.persistence.SessionManager; import com.arsdigita.persistence.SessionManager;
import com.arsdigita.persistence.metadata.ObjectType; import com.arsdigita.persistence.metadata.ObjectType;
import org.apache.log4j.Logger;
/** /**
* Represents a user. * Represents a user.
@ -47,14 +46,12 @@ import org.apache.log4j.Logger;
public class User extends Party { 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 $"; 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 PersonName m_name;
private boolean m_external; private boolean m_external;
/** An attribute name for the underlying data object. */ /** An attribute name for the underlying data object. */
public static final String BANNED = "banned"; public static final String BANNED = "banned";
/** /**
* Every instance of group must encapsulate a data object whose * 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.DataObject
* @see com.arsdigita.persistence.OID * @see com.arsdigita.persistence.OID
**/ **/
public static User retrieve(BigDecimal id) public static User retrieve(BigDecimal id) throws DataObjectNotFoundException {
throws DataObjectNotFoundException
{
return retrieve(new OID(BASE_DATA_OBJECT_TYPE, id)); return retrieve(new OID(BASE_DATA_OBJECT_TYPE, id));
} }
@ -108,11 +103,9 @@ public class User extends Party {
* @see com.arsdigita.persistence.OID * @see com.arsdigita.persistence.OID
* @see DomainObjectFactory#newInstance(OID) * @see DomainObjectFactory#newInstance(OID)
**/ **/
public static User retrieve(OID oid) public static User retrieve(OID oid) throws DataObjectNotFoundException {
throws DataObjectNotFoundException
{
User user = (User) DomainObjectFactory.newInstance(oid); User user = (User) DomainObjectFactory.newInstance(oid);
if (user==null) { if (user == null) {
throw new throw new
DataObjectNotFoundException("Domain object factory " + DataObjectNotFoundException("Domain object factory " +
"produced null user for OID " + "produced null user for OID " +
@ -133,7 +126,7 @@ public class User extends Party {
public static User retrieve(DataObject userData) { public static User retrieve(DataObject userData) {
User user = (User) DomainObjectFactory.newInstance(userData); User user = (User) DomainObjectFactory.newInstance(userData);
if (user==null) { if (user == null) {
throw new RuntimeException("Domain object factory produced " + throw new RuntimeException("Domain object factory produced " +
"null user for data object " + "null user for data object " +
userData); userData);
@ -172,13 +165,11 @@ public class User extends Party {
**/ **/
public User(boolean external) { public User(boolean external) {
this(BASE_DATA_OBJECT_TYPE); this(BASE_DATA_OBJECT_TYPE);
m_external = external; m_external = external;
} }
public User() { public User() {
this (false); this(false);
} }
@ -201,8 +192,9 @@ public class User extends Party {
} }
public User(String givenName, String familyName, String email) { 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 * Constructor in which the contained <code>DataObject</code> is
* initialized with a new <code>DataObject</code> with an * initialized with a new <code>DataObject</code> with an
@ -220,7 +212,6 @@ public class User extends Party {
super(typeName); super(typeName);
} }
/** /**
* Constructor in which the contained <code>DataObject</code> is * Constructor in which the contained <code>DataObject</code> is
* initialized with a new <code>DataObject</code> with an * initialized with a new <code>DataObject</code> with an
@ -287,7 +278,7 @@ public class User extends Party {
m_name = new PersonName(); m_name = new PersonName();
setAssociation("name", m_name); 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, // If the domain object is new or the primary email has been changed,
// validate it. // validate it.
if ( (isNew() || isPropertyModified("primaryEmail")) && if ((isNew() || isPropertyModified("primaryEmail")) && Kernel.getConfig().emailIsPrimaryIdentifier()) {
KernelHelper.emailIsPrimaryIdentifier()) {
validatePrimaryEmail(); validatePrimaryEmail();
} }
if ((isNew() || isPropertyModified("primaryEmail") if ((isNew() || isPropertyModified("primaryEmail") || isPropertyModified("screenName"))
|| isPropertyModified("screenName")) && && !Kernel.getConfig().emailIsPrimaryIdentifier()) {
!KernelHelper.emailIsPrimaryIdentifier()) {
if (getPrimaryEmail() == null) { if (getPrimaryEmail() == null) {
throw new RuntimeException("Primary email must be specified"); throw new RuntimeException("Primary email must be specified");
} }
validateScreenName(); validateScreenName();
} }
} }
protected void afterSave() { protected void afterSave() {
super.afterSave(); super.afterSave();
// users have admin permissions on themselves (needed to change // users have admin permissions on themselves (needed to change
// email, for instance). // email, for instance).
if (!m_external) { if (!m_external) {
PermissionDescriptor perm = new PermissionDescriptor(PrivilegeDescriptor.ADMIN, this, this); PermissionDescriptor perm = new PermissionDescriptor(PrivilegeDescriptor.ADMIN, this, this);
PermissionService.grantPermission(perm); PermissionService.grantPermission(perm);
} }
} }
/** /**
@ -444,35 +432,29 @@ public class User extends Party {
} }
// Verify uniqueness of email // Verify uniqueness of email
DataQuery query = SessionManager.getSession() DataQuery query = SessionManager.getSession().retrieveQuery("com.arsdigita.kernel.UserPrimaryEmail");
.retrieveQuery("com.arsdigita.kernel.UserPrimaryEmail"); Filter f = query.addFilter("primaryEmailAddress=:email " + "and userID != :userID");
Filter f =
query.addFilter("primaryEmailAddress=:email " +
"and userID != :userID");
f.set("email", email.getEmailAddress()); f.set("email", email.getEmailAddress());
f.set("userID", getID()); f.set("userID", getID());
if (query.size()>0) { if (query.size() > 0) {
throw new RuntimeException("Primary email must be unique among users"); throw new RuntimeException("Primary email must be unique among users");
} }
} }
protected void validateScreenName() { protected void validateScreenName() {
String sn = getScreenName().toLowerCase(); String sn = getScreenName();
if (sn == null) { if (sn == null) {
throw new RuntimeException("Screen Name must be specified"); throw new RuntimeException("Screen Name must be specified");
} }
// Verify uniqueness of screen name // Verify uniqueness of screen name
DataQuery query = SessionManager.getSession() DataQuery query = SessionManager.getSession().retrieveQuery("com.arsdigita.kernel.UserPrimaryEmail");
.retrieveQuery("com.arsdigita.kernel.UserPrimaryEmail"); Filter f = query.addFilter("lowerScreenName=:sn " + "and userID != :userID");
Filter f = f.set("sn", sn.toLowerCase());
query.addFilter("lowerScreenName=:sn " +
"and userID != :userID");
f.set("sn", sn);
f.set("userID", getID()); f.set("userID", getID());
if (query.size()>0) { if (query.size() > 0) {
throw new RuntimeException("Screen Name must be unique among users"); throw new RuntimeException("Screen Name must be unique among users");
} }
} }
@ -481,19 +463,18 @@ public class User extends Party {
return SessionManager.getSession().retrieveDataOperation(name); return SessionManager.getSession().retrieveDataOperation(name);
} }
/** /**
* Getter for the banned property, which is persisted to the database * Getter for the banned property, which is persisted to the database
*/ */
public boolean isBanned() { public boolean isBanned() {
return ((Boolean) get(BANNED)).booleanValue(); return ((Boolean) get(BANNED)).booleanValue();
} }
/** /**
* Setter for the banned property, which is persisted to the database * Setter for the banned property, which is persisted to the database
*/ */
public void setBanned(boolean b) { public void setBanned(boolean b) {
set(BANNED, new Boolean(b)); set(BANNED, new Boolean(b));
} }
} }

View File

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

View File

@ -18,6 +18,8 @@
*/ */
package com.arsdigita.ui.admin; package com.arsdigita.ui.admin;
import javax.mail.internet.InternetAddress;
import com.arsdigita.bebop.FormProcessException; import com.arsdigita.bebop.FormProcessException;
import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.event.FormInitListener; import com.arsdigita.bebop.event.FormInitListener;
@ -28,7 +30,6 @@ import com.arsdigita.kernel.EmailAddress;
import com.arsdigita.kernel.PersonName; import com.arsdigita.kernel.PersonName;
import com.arsdigita.kernel.User; import com.arsdigita.kernel.User;
import com.arsdigita.kernel.UserAuthentication; import com.arsdigita.kernel.UserAuthentication;
import javax.mail.internet.InternetAddress;
/** /**
* Form used to add a new user to the system. * Form used to add a new user to the system.
@ -58,8 +59,6 @@ class UserAddForm extends UserForm
m_question.addValidationListener m_question.addValidationListener
(new NotEmptyValidationListener()); (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.StringLengthValidationListener;
import com.arsdigita.bebop.parameters.StringParameter; import com.arsdigita.bebop.parameters.StringParameter;
import com.arsdigita.bebop.parameters.URLParameter; import com.arsdigita.bebop.parameters.URLParameter;
import com.arsdigita.kernel.Kernel;
import com.arsdigita.persistence.DataQuery; import com.arsdigita.persistence.DataQuery;
import com.arsdigita.persistence.Filter; import com.arsdigita.persistence.Filter;
import com.arsdigita.persistence.SessionManager; import com.arsdigita.persistence.SessionManager;
import com.arsdigita.ui.login.PasswordValidationListener; import com.arsdigita.ui.login.PasswordValidationListener;
import com.arsdigita.util.StringUtils;
import java.math.BigDecimal; import java.math.BigDecimal;
import javax.mail.internet.InternetAddress; import javax.mail.internet.InternetAddress;
@ -130,7 +132,7 @@ class UserForm extends Form implements FormValidationListener, AdminConstants {
// Password answer // Password answer
m_answer = new TextField(new StringParameter(USER_FORM_INPUT_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(USER_FORM_LABEL_ANSWER);
add(m_answer); add(m_answer);
@ -140,6 +142,7 @@ class UserForm extends Form implements FormValidationListener, AdminConstants {
(new EmailParameter(USER_FORM_INPUT_PRIMARY_EMAIL)); (new EmailParameter(USER_FORM_INPUT_PRIMARY_EMAIL));
m_primaryEmail.addValidationListener m_primaryEmail.addValidationListener
(new NotEmptyValidationListener()); (new NotEmptyValidationListener());
m_primaryEmail.setSize(50);
add(USER_FORM_LABEL_PRIMARY_EMAIL); add(USER_FORM_LABEL_PRIMARY_EMAIL);
add(m_primaryEmail); add(m_primaryEmail);
@ -150,12 +153,16 @@ class UserForm extends Form implements FormValidationListener, AdminConstants {
m_additionalEmail = new TextField m_additionalEmail = new TextField
(new EmailParameter(USER_FORM_INPUT_ADDITIONAL_EMAIL)); (new EmailParameter(USER_FORM_INPUT_ADDITIONAL_EMAIL));
m_additionalEmail.setSize(50);
add(USER_FORM_LABEL_ADDITIONAL_EMAIL); add(USER_FORM_LABEL_ADDITIONAL_EMAIL);
add(m_additionalEmail); add(m_additionalEmail);
// Screen name // Screen name
m_screenName = new TextField m_screenName = new TextField
(new StringParameter(USER_FORM_INPUT_SCREEN_NAME)); (new StringParameter(USER_FORM_INPUT_SCREEN_NAME));
if (Kernel.getConfig().screenNameIsPrimaryIdentifier()) {
m_screenName.addValidationListener(new NotEmptyValidationListener());
}
add(USER_FORM_LABEL_SCREEN_NAME); add(USER_FORM_LABEL_SCREEN_NAME);
add(m_screenName); add(m_screenName);
@ -204,17 +211,11 @@ class UserForm extends Form implements FormValidationListener, AdminConstants {
String password = (String) m_password.getValue(ps); String password = (String) m_password.getValue(ps);
String confirm = (String) m_confirmPassword.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)) { if (!password.equals(confirm)) {
data.addError(USER_FORM_INPUT_PASSWORD_CONFIRMATION, data.addError(USER_FORM_INPUT_PASSWORD_CONFIRMATION,
(String) USER_FORM_ERROR_PASSWORD_NOT_MATCH.localize(req)); (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; package com.redhat.persistence.pdl.adapters;
import com.arsdigita.db.DbHelper;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.lang.reflect.InvocationTargetException;
import java.sql.Blob; import java.sql.Blob;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Types; import java.sql.Types;
import com.arsdigita.db.DbHelper;
/** /**
* BlobAd * BlobAd
* *
* @author Rafael H. Schloming &lt;rhs@mit.edu&gt; * @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 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() { public BlobAd() {
super("global.Blob", Types.BLOB); super("global.Blob", Types.BLOB);
} }
@ -75,11 +75,9 @@ public class BlobAd extends SimpleAdapter {
return; return;
} }
/* Jens Pelzetter 2009-03-16 commented out to get rid of Netbeans errors */ Blob blob = rs.getBlob(column);
/*oracle.sql.BLOB blob =
(oracle.sql.BLOB) rs.getBlob(column);
OutputStream out = blob.getBinaryOutputStream();
try { try {
OutputStream out = (OutputStream)(blob.getClass().getMethod("getBinaryOutputStream", new Class[0]).invoke(blob));
out.write((byte[]) value); out.write((byte[]) value);
out.flush(); out.flush();
out.close(); out.close();
@ -88,8 +86,18 @@ public class BlobAd extends SimpleAdapter {
// persistence exception here breaks ant verify-pdl // persistence exception here breaks ant verify-pdl
// because the classpath isn't set up to include // because the classpath isn't set up to include
// com.arsdigita.util.* // 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; package com.redhat.persistence.pdl.adapters;
import com.arsdigita.db.DbHelper;
import java.io.IOException; import java.io.IOException;
import java.io.Writer; import java.io.Writer;
import java.lang.reflect.InvocationTargetException;
import java.sql.Clob; import java.sql.Clob;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
@ -28,21 +28,19 @@ import java.sql.ResultSetMetaData;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Types; import java.sql.Types;
import com.arsdigita.db.DbHelper;
/** /**
* StringAd: StringAdapter class * StringAd: StringAdapter class
* *
* *
* @author Rafael H. Schloming &lt;rhs@mit.edu&gt; * @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 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() { public StringAd() {
super("global.String", Types.VARCHAR); super("global.String", Types.VARCHAR);
} }
@ -78,11 +76,9 @@ public class StringAd extends SimpleAdapter {
return; return;
} }
/* Jens Pelzetter 2009-03-16 commented out to get rid of Netbeans errors */ Clob clob = rs.getClob(column);
/*oracle.sql.CLOB clob =
(oracle.sql.CLOB) rs.getClob(column);
Writer out = clob.getCharacterOutputStream();
try { try {
Writer out = (Writer)clob.getClass().getMethod("getCharacterOutputStream", new Class[0]).invoke(clob);
out.write(((String) value).toCharArray()); out.write(((String) value).toCharArray());
out.flush(); out.flush();
out.close(); out.close();
@ -92,6 +88,17 @@ public class StringAd extends SimpleAdapter {
// because the classpath isn't set up to include // because the classpath isn't set up to include
// com.arsdigita.util.* // 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 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; 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.io.Writer;
import java.lang.reflect.InvocationTargetException;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.BigInteger; import java.math.BigInteger;
import java.sql.Clob;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import com.arsdigita.db.DbHelper;
/** /**
* LobTest - for testing Blob and Clob datatype. * LobTest - for testing Blob and Clob datatype.
* *
* @author Jeff Teeters * @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 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 = private Logger s_cat =
Logger.getLogger(LobTest.class); Logger.getLogger(LobTest.class);
@ -253,7 +253,6 @@ public class LobTest extends PersistenceTestCase {
dt.save(); dt.save();
dt = getSession().retrieve(new OID("examples.Datatype", BigInteger.ZERO)); dt = getSession().retrieve(new OID("examples.Datatype", BigInteger.ZERO));
String bar = (String) dt.get("string");
String foundString = (String) dt.get("clob"); String foundString = (String) dt.get("clob");
dt.delete(); dt.delete();
@ -365,7 +364,7 @@ public class LobTest extends PersistenceTestCase {
private void executeOracleUpdate(Connection conn, String testString, private void executeOracleUpdate(Connection conn, String testString,
int id) int id)
throws java.sql.SQLException, java.io.IOException { throws java.sql.SQLException, java.io.IOException, IllegalArgumentException, SecurityException, IllegalAccessException, InvocationTargetException, NoSuchMethodException {
PreparedStatement ps = PreparedStatement ps =
conn.prepareStatement("insert into t_datatypes (id, j_clob) " + conn.prepareStatement("insert into t_datatypes (id, j_clob) " +
"values (?, EMPTY_CLOB())"); "values (?, EMPTY_CLOB())");
@ -383,8 +382,8 @@ public class LobTest extends PersistenceTestCase {
ps.setBigDecimal(1, new BigDecimal(BigInteger.valueOf(id))); ps.setBigDecimal(1, new BigDecimal(BigInteger.valueOf(id)));
ResultSet rs = ps.executeQuery(); ResultSet rs = ps.executeQuery();
rs.next(); rs.next();
oracle.sql.CLOB Clob = (oracle.sql.CLOB)rs.getClob(1); Clob clob = rs.getClob(1);
Writer char_stream = Clob.getCharacterOutputStream (); Writer char_stream = (Writer)clob.getClass().getMethod("getCharacterOutputStream", new Class[0]).invoke(clob);
char_stream.write(testString); char_stream.write(testString);
char_stream.flush(); char_stream.flush();
char_stream.close(); char_stream.close();