Hi Youngho,

I thought at the beginning, that you may have no need to use the
convenience classes provided in the Fulcrum Security torque module.
If you want use them, you have to do some more changes:


(1) You should adapt (or delete and rename)

org.apache.fulcrum.security.torque.turbine.TorqueAbstractTurbineUser
(this class or some super class extends TorqueAbstractSecurityEntity)

and change any call of TorqueTurbineUserPeer to JettigerUserImplPeer.
(If you want to use the other abstract classes too you have to change
them as well (e.g. change the method call getTorqueTurbineUser to
getJettigerUserImpl in TorqueAbstractTurbineGroup..).

(2)
Of course, if you are using e.g. mysql databae autoincrement you should
set idMethod="native", othrwise you have to set idMethod="idbroker",
which is used in the fulcrum security torque tests.

(3)
The generating schema becomes then:

 <table name="TURBINE_USER" javaName="JettigerUserImpl"
idMethod="idbroker"


peerInterface="org.apache.fulcrum.security.torque.peer.TorqueTurbinePeer"

baseClass="org.apache.fulcrum.security.torque.turbine.TorqueAbstractTurbineUser"
      interface="JettigerUser">

You should delete the generated classes and regenerate.

If you package your module may be you should rename it and NOT include
the overwritten default fulcrum security torque dependency. Otherwise
you may have class loading issues (classes having the same name, but
different implementation).

Best, Georg

P.S. Dynamic peer class loading is possible, but still hard coded
references (e.g. TorqueTurbineUserPeer.DATABASE_NAME) exist as a default
configuration option. At the moment templating (your use case) is
possible, but requires some code adaptions (method renaming).





Von:    Youngho Cho <[email protected]>
An:     Turbine Developers List <[email protected]>
Datum:  30.09.2014 11:22
Betreff:        Re: trunk fulcrum-security-torque migration question



Hello Georg,

I tried to make some test code.

I copy TorqueTurbineModelManagerTest into my migration test folder

and modified
TurbineTorqueComponentConfig.xml's userManager className set to our
JettigerUserImpl
    <userManager>
        <className>com.nannet.jettiger.om.JettigerUserImpl</className>
    </userManager>

and add simple test method into TorqueTurbineModelManagerTest

    public void testJettigerUser()
        throws Exception
    {
        JettigerUser user = userManager.getUserInstance("");
        user.setName("easydesk");
        user.setFirstName("easydesk");
        user.setLastName("easydesk");
        user.setEmail("[email protected]");
        user.setPassword("password");
        System.out.println(user);
        user.save();
    }

and i got following error

Look's like I didn't set peer class properly and am not sure why
happens class cast exception during revoke roll process.

How can I solve this problems ?


Thanks,


Youngho


=================================================

[DEBUG] Located the service
'org.apache.fulcrum.security.SecurityService' in the local container
[DEBUG] Located the service 'org.apache.fulcrum.security.RoleManager'
in the local container
[DEBUG] Located the service 'org.apache.fulcrum.security.UserManager'
in the local container
[DEBUG] Located the service 'org.apache.fulcrum.security.GroupManager'
in the local container
[DEBUG] Located the service
'org.apache.fulcrum.security.PermissionManager' in the local container
[DEBUG] Located the service 'org.apache.fulcrum.security.ModelManager'
in the local container
Tests run: 8, Failures: 0, Errors: 4, Skipped: 0, Time elapsed: 0.156
sec <<< FAILURE!
testJettigerUser(com.nannet.jettiger.om.TorqueTurbineModelManagerTest)
 Time elapsed: 0 sec  <<< ERROR!
org.apache.torque.ConstraintViolationException: java.sql.SQLException:
Attempt to insert null into a non-nullable column: column: USER_ID
table: TURBINE_USER in statement [INSERT INTO TURBINE_USER(USER_ID)
VALUES (?)]
    at org.apache.torque.util.ExceptionMapperImpl.toTorqueException
(ExceptionMapperImpl.java:43)
    at org.apache.torque.util.BasePeerImpl.doInsert
(BasePeerImpl.java:525)
    at com.nannet.jettiger.om.BaseJettigerUserImplPeerImpl.doInsert
(BaseJettigerUserImplPeerImpl.java:175)
    at com.nannet.jettiger.om.BaseJettigerUserImplPeerImpl.doInsert
(BaseJettigerUserImplPeerImpl.java:204)
    at com.nannet.jettiger.om.BaseJettigerUserImplPeer.doInsert
(BaseJettigerUserImplPeer.java:502)
    at com.nannet.jettiger.om.BaseJettigerUserImpl.save
(BaseJettigerUserImpl.java:527)
    at com.nannet.jettiger.om.BaseJettigerUserImpl.save
(BaseJettigerUserImpl.java:490)
    at com.nannet.jettiger.om.BaseJettigerUserImpl.save
(BaseJettigerUserImpl.java:470)
    at
com.nannet.jettiger.om.TorqueTurbineModelManagerTest.testJettigerUser
(TorqueTurbineModelManagerTest.java:106)
Caused by: java.sql.SQLException: Attempt to insert null into a
non-nullable column: column: USER_ID table: TURBINE_USER in statement
[INSERT INTO TURBINE_USER(USER_ID) VALUES (?)]
    at org.hsqldb.jdbc.Util.throwError(Unknown Source)
    at org.hsqldb.jdbc.jdbcPreparedStatement.executeUpdate(Unknown
Source)
    at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate
(DelegatingPreparedStatement.java:105)
    at org.apache.torque.util.BasePeerImpl.doInsert
(BasePeerImpl.java:515)
    ... 35 more

testRevokeAllUser(com.nannet.jettiger.om.TorqueTurbineModelManagerTest)
 Time elapsed: 0.015 sec  <<< ERROR!
java.lang.ClassCastException: com.nannet.jettiger.om.JettigerUserImpl
cannot be cast to
org.apache.fulcrum.security.torque.TorqueAbstractSecurityEntity
    at
org.apache.fulcrum.security.torque.TorqueAbstractUserManager.checkExists
(TorqueAbstractUserManager.java:174)
    at org.apache.fulcrum.security.spi.AbstractUserManager.checkExists
(AbstractUserManager.java:65)
    at org.apache.fulcrum.security.spi.AbstractUserManager.addUser
(AbstractUserManager.java:285)
    at
org.apache.fulcrum.security.model.turbine.test.AbstractTurbineModelManagerTest.testRevokeAllUser
(AbstractTurbineModelManagerTest.java:152)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at junit.framework.TestCase.runTest(TestCase.java:154)
    at junit.framework.TestCase.runBare(TestCase.java:127)
    at junit.framework.TestResult$1.protect(TestResult.java:106)
    at junit.framework.TestResult.runProtected(TestResult.java:124)
    at junit.framework.TestResult.run(TestResult.java:109)
    at junit.framework.TestCase.run(TestCase.java:118)
    at junit.framework.TestSuite.runTest(TestSuite.java:208)
    at junit.framework.TestSuite.run(TestSuite.java:203)



2014-09-29 22:01 GMT+09:00 Youngho Cho <[email protected]>:
> Hello Georg,
>
> Thanks!,  compile sucessfully finished !.
>
> Tomorrow moring, I will make some test code.
>
>
> Thanks
>
> Youngho
>
>
> 2014-09-29 21:05 GMT+09:00 Georg Kallidis
<[email protected]>:
>> Hi Youngho,
>>
>> (1) are you sure, that class
>> org.apache.fulcrum.security.torque.om.TorqueTurbineUser is not an old
>> class generated previously? Especilly setting  basePeer might be the
>> problem..
>>
>> (2) What about using this header:
>>
>>    <table name="TURBINE_USER" javaName="JettigerUserImpl"
>>
>>
peerInterface="org.apache.fulcrum.security.torque.peer.TorqueTurbinePeer"

>>
>>
baseClass="org.apache.fulcrum.security.model.turbine.entity.impl.TurbineUserImpl"

>>     interface="JettigerUser">
>>
>> instead of
>>
>> <table name="TURBINE_USER" javaName="JettigerUserImpl"
>>
>>
peerInterface="org.apache.fulcrum.security.torque.peer.TorqueTurbinePeer"

>>
>>
baseClass="org.apache.fulcrum.security.torque.om.TorqueTurbineUser"
>>
>>
basePeer="org.apache.fulcrum.security.torque.om.TorqueTurbineUserPeer"
>>     interface="JettigerUser">
>>
>> This generates valid mapper files, where the TurbineUser interface
>> implementation is included. The class
>> org.apache.fulcrum.security.torque.om.TorqueTurbineUserPeer is by
>> default just an interface, not a base peer class...
>>
>> Best, Georg
>>
>>
>>
>> Von:    Youngho Cho <[email protected]>
>> An:     Turbine Developers List <[email protected]>
>> Datum:  29.09.2014 08:57
>> Betreff:        trunk fulcrum-security-torque migration question
>>
>>
>>
>> Hello,
>>
>> I am tring to migrate old turbine which use torque-3.3 and old
>> fulcrum-security
>>  to trunk fulcrum-security-torque with torque-4.1.
>>
>> old-schema file looks likes
>>
>> <?xml version="1.0" encoding="UTF-8" standalone="no" ?>
>> <!DOCTYPE database SYSTEM
>>           "http://db.apache.org/torque/dtd/database_3_3.dtd";>
>> <database name="migration" defaultJavaType="object">
>> <table name="TURBINE_USER" javaName="JettigerUserImpl"
>> alias="TurbineUser"
>>
baseClass="org.apache.fulcrum.security.impl.db.entity.TurbineUser"
>>
>> basePeer="org.apache.fulcrum.security.impl.db.entity.TurbineUserPeer"
>>     interface="JettigerUser">
>>     <column name="USER_ID" primaryKey="true" required="true"
>> type="INTEGER"/>
>> </table>
>> <table name="USER_PREFERENCE" idMethod="none">
>>     <column name="USER_ID" primaryKey="true" required="true"
>> type="INTEGER"/>
>>     <column name="PASSWORD_EXPIRE" type="TIMESTAMP"/>
>>     <foreign-key foreignTable="TURBINE_USER">
>>         <reference local="USER_ID" foreign="USER_ID"/>
>>     </foreign-key>
>> </table>
>> </database>
>>
>> In order to migrate torque-4.1,
>> I modify the new-schema likes
>>
>> <?xml version="1.0" encoding="UTF-8" standalone="no" ?>
>> <database
>>     name="migration"
>>     defaultIdMethod="none"
>>     defaultJavaType="object"
>>     xmlns="http://db.apache.org/torque/4.0/templates/database";
>>     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
>>     xsi:schemaLocation="
>> http://db.apache.org/torque/4.0/templates/database
>>
>>
http://db.apache.org/torque/torque-4.0/documentation/orm-reference/database-4-0.xsd

>> ">
>> <table name="TURBINE_USER" javaName="JettigerUserImpl"
>>
>>
peerInterface="org.apache.fulcrum.security.torque.peer.TorqueTurbinePeer"

>>
>>
baseClass="org.apache.fulcrum.security.torque.om.TorqueTurbineUser"
>>
>>
basePeer="org.apache.fulcrum.security.torque.om.TorqueTurbineUserPeer"
>>     interface="JettigerUser">
>>     <column name="USER_ID" primaryKey="true" required="true"
>> type="INTEGER"/>
>> </table>
>> <table name="USER_PREFERENCE" idMethod="none">
>>     <column name="USER_ID" primaryKey="true" required="true"
>> type="INTEGER"/>
>>     <column name="PASSWORD_EXPIRE" type="TIMESTAMP"/>
>>     <foreign-key foreignTable="TURBINE_USER">
>>         <reference local="USER_ID" foreign="USER_ID"/>
>>     </foreign-key>
>> </table>
>> </database>
>>
>> and I got following compile error.
>>
>> [INFO] -------------------------------------------------------------
>> [ERROR] COMPILATION ERROR :
>> [INFO] -------------------------------------------------------------
>>
[ERROR] 
/D:/projectSvn/migration-test/torque4/target/generated-sources/com/nannet/jettiger/om/BaseJettigerUserImpl.java:[735,56]

>>
>> getPeer() in com.nannet.jettiger.om.BaseJettigerUserImpl cannot
>> override getPeer() in
>> org.apache.fulcrum.security.torque.om.BaseTorqueTurbineUser
>>   return type com.nannet.jettiger.om.JettigerUserImplPeer is not
>> compatible with
>> org.apache.fulcrum.security.torque.om.TorqueTurbineUserPeer
>> [INFO] 1 error
>>
>>
>> How can I fix it ?
>>
>>
>> Thanks,
>>
>> Youngho
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>>

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to