You are viewing a plain text version of this content. The canonical link for it is here.
Posted to slide-user@jakarta.apache.org by Var George <va...@yahoo.com> on 2004/10/21 08:58:39 UTC

revokePermission() in CommonRDBMSAdaper vs StandardRDBMSAdaper

1. public void revokePermission(Connection connection, Uri uri, NodePermission permission)  method in CommonRDBMSAdaper  seems to be buggy where as this issue is fixed in the same method on StandardRDBMSAdaper.java. Is there any reason why this method is overridden is CommonRDBMSAdaper .java? They seems to be doing the same thing except that the one on CommonRDBMSAdaper.java is buggy because it doesn't do null check on revisionNumber. 

2. public void revokePermissions(Connection connection, Uri uri) throws ServiceAccessException method on  CommonRDBMSAdaper  seems  to be redundant but interestingly  here the SQL logic different in CommonRDBMSAdaper  &  StandardRDBMSAdaper (why?). 

-- StandardRDMBSAdaper: delete PERMISSIONS from PERMISSIONS, URI u where OBJECT_ID = u.URI_ID and u.URI_STRING = ?");

-- CommonRDBMSAdaper : delete from PERMISSIONS where PERMISSIONS.OBJECT_ID in (select u.URI_ID from URI u where u.URI_STRING = ?

Can we remove the redundant methods on CommonRDBMSAdaper.java?

Regards
Var George


 

 


		
---------------------------------
Do you Yahoo!?
vote.yahoo.com - Register online to vote today!

Re: revokePermission() in CommonRDBMSAdapter vs StandardRDBMSAdapter

Posted by Var George <va...@yahoo.com>.
the code i sent you was the fix that was copied from StandardRDBMSAdapter.
 
"statement.setString(4, revisionNumber == null ? null : revisionNumber.toString());" won't work because  the resulting SQL "p.version_no = NULL"  will not return any rows in SQL, instead it should be "p.version_no IS NULL" 
 
regards
Var George
 
 
regards
Varughese George
Oliver Zeigermann <ol...@gmail.com> wrote:
Why not doing something like

statement.setString(4, revisionNumber == null ? null :
revisionNumber.toString());

Oliver

On Thu, 21 Oct 2004 13:38:07 -0700 (PDT), Var George
wrote:
> Oliver
> 
> Yes, they are different SQL and I missed it. However in StandardDBMSAdapter there is null check for >>>revisionNumber<<< where as the same is missing in CommonsRDBMSAdapter. You will notice that the SQL has 3 bind variables in StandardDBMSAdapter where as it has 4 bind variables in CommonsRDBMSAapter.
> 
> Here is the fixed SQL with fixes marked between //fix:start and //fix:end. Please fix it in slide cvs if possible.
> 
> public void revokePermission(Connection connection, Uri uri,
> NodePermission permission)
> throws ServiceAccessException {
> if (permission == null) return;
> PreparedStatement statement = null;
> try {
> NodeRevisionNumber revisionNumber =
> permission.getRevisionNumber();
> statement =
> connection.prepareStatement(
> //fix:begin: added null check for revision no
> "delete from PERMISSIONS p where p.OBJECT_ID in
> (select ou.URI_ID from URI ou, URI su, URI au where ou.URI_STRING = ? and p.SUBJECT_ID = su.URI_ID and su.URI_STRING = ? and p.ACTION_ID = au.URI_ID and au.URI_STRING = ? and p.VERSION_NO" + ((revisionNumber == null) ? " IS NULL " : " = '" + revisionNumber.toString() + "'"));
> //fix:end
> statement.setString(1, permission.getObjectUri());
> statement.setString(2, permission.getSubjectUri());
> statement.setString(3, permission.getActionUri());
> //fix:begin: commented out because bind is no longer required
> //statement.setString(4, revisionNumber.toString());
> //fix:end:
> statement.executeUpdate();
> } catch (SQLException e) {
> throw createException(e, uri.toString());
> } finally {
> close(statement);
> }
> }
> 
> regards
> Varughese George
> 
> Oliver Zeigermann wrote:
> On Wed, 20 Oct 2004 23:58:39 -0700 (PDT), Var George
> wrote:
> >
> > 1. public void revokePermission(Connection connection, Uri uri, NodePermission permission) method in CommonRDBMSAdaper seems to be buggy where as this issue is fixed in the same method on StandardRDBMSAdaper.java. Is there any reason why this method is overridden is CommonRDBMSAdaper .java? They seems to be doing the same thing except that the one on CommonRDBMSAdaper.java is buggy because it doesn't do null check on revisionNumber.
> 
> Except for the different SQL dialects both methods are the same, both
> start with
> 
> if (permission == null) return;
> 
> both in 2.1 as in the current CVS head. Am I missing something?
> 
> Oliver
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: slide-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: slide-user-help@jakarta.apache.org
> 
> ---------------------------------
> Do you Yahoo!?
> Take Yahoo! Mail with you! Get it on your mobile phone.
>

---------------------------------------------------------------------
To unsubscribe, e-mail: slide-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: slide-user-help@jakarta.apache.org


		
---------------------------------
Do you Yahoo!?
vote.yahoo.com - Register online to vote today!

Re: revokePermission() in CommonRDBMSAdapter vs StandardRDBMSAdapter

Posted by Oliver Zeigermann <ol...@gmail.com>.
Why not doing something like

statement.setString(4, revisionNumber == null ? null :
revisionNumber.toString());

Oliver

On Thu, 21 Oct 2004 13:38:07 -0700 (PDT), Var George
<va...@yahoo.com> wrote:
> Oliver
> 
> Yes, they are different SQL and I missed it. However in StandardDBMSAdapter there is null check for >>>revisionNumber<<< where as the same is missing in CommonsRDBMSAdapter. You will notice that the SQL has 3 bind variables in StandardDBMSAdapter where as it has 4 bind variables in CommonsRDBMSAapter.
> 
> Here is the fixed SQL with fixes marked between //fix:start and //fix:end. Please fix it in slide cvs if possible.
> 
> public void revokePermission(Connection connection, Uri uri,
> NodePermission permission)
>    throws ServiceAccessException {
>    if (permission == null) return;
>    PreparedStatement statement = null;
>    try {
>        NodeRevisionNumber revisionNumber =
> permission.getRevisionNumber();
>        statement =
>           connection.prepareStatement(
>           //fix:begin: added null check for revision no
>         "delete from PERMISSIONS p where p.OBJECT_ID in
> (select ou.URI_ID from URI ou, URI su, URI au where ou.URI_STRING = ? and p.SUBJECT_ID = su.URI_ID and su.URI_STRING = ? and p.ACTION_ID = au.URI_ID and au.URI_STRING = ? and p.VERSION_NO" + ((revisionNumber == null) ? " IS NULL " : " = '" + revisionNumber.toString() + "'"));
>           //fix:end
>           statement.setString(1, permission.getObjectUri());
>           statement.setString(2, permission.getSubjectUri());
>           statement.setString(3, permission.getActionUri());
>           //fix:begin: commented out because bind is no longer required
>           //statement.setString(4, revisionNumber.toString());
>           //fix:end:
>           statement.executeUpdate();
>     } catch (SQLException e) {
>       throw createException(e, uri.toString());
>     } finally {
>       close(statement);
>    }
> }
> 
> regards
> Varughese George
> 
> Oliver Zeigermann <ol...@gmail.com> wrote:
> On Wed, 20 Oct 2004 23:58:39 -0700 (PDT), Var George
> wrote:
> >
> > 1. public void revokePermission(Connection connection, Uri uri, NodePermission permission) method in CommonRDBMSAdaper seems to be buggy where as this issue is fixed in the same method on StandardRDBMSAdaper.java. Is there any reason why this method is overridden is CommonRDBMSAdaper .java? They seems to be doing the same thing except that the one on CommonRDBMSAdaper.java is buggy because it doesn't do null check on revisionNumber.
> 
> Except for the different SQL dialects both methods are the same, both
> start with
> 
> if (permission == null) return;
> 
> both in 2.1 as in the current CVS head. Am I missing something?
> 
> Oliver
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: slide-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: slide-user-help@jakarta.apache.org
> 
> ---------------------------------
> Do you Yahoo!?
> Take Yahoo! Mail with you! Get it on your mobile phone.
>

---------------------------------------------------------------------
To unsubscribe, e-mail: slide-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: slide-user-help@jakarta.apache.org


Re: revokePermission() in CommonRDBMSAdapter vs StandardRDBMSAdapter

Posted by Var George <va...@yahoo.com>.
Oliver
 
Yes, they are different SQL and I missed it. However in StandardDBMSAdapter there is null check for >>>revisionNumber<<< where as the same is missing in CommonsRDBMSAdapter. You will notice that the SQL has 3 bind variables in StandardDBMSAdapter where as it has 4 bind variables in CommonsRDBMSAapter.
 
Here is the fixed SQL with fixes marked between //fix:start and //fix:end. Please fix it in slide cvs if possible.
 
public void revokePermission(Connection connection, Uri uri, 
NodePermission permission)
   throws ServiceAccessException {
   if (permission == null) return;
   PreparedStatement statement = null;
   try {
       NodeRevisionNumber revisionNumber = 
permission.getRevisionNumber();
       statement =
          connection.prepareStatement(
          //fix:begin: added null check for revision no
        "delete from PERMISSIONS p where p.OBJECT_ID in 
(select ou.URI_ID from URI ou, URI su, URI au where ou.URI_STRING = ? and p.SUBJECT_ID = su.URI_ID and su.URI_STRING = ? and p.ACTION_ID = au.URI_ID and au.URI_STRING = ? and p.VERSION_NO" + ((revisionNumber == null) ? " IS NULL " : " = '" + revisionNumber.toString() + "'"));
          //fix:end
          statement.setString(1, permission.getObjectUri());
          statement.setString(2, permission.getSubjectUri());
          statement.setString(3, permission.getActionUri());
          //fix:begin: commented out because bind is no longer required
          //statement.setString(4, revisionNumber.toString());
          //fix:end:
          statement.executeUpdate();
    } catch (SQLException e) {
      throw createException(e, uri.toString());
    } finally {
      close(statement);
   }
}

regards
Varughese George

Oliver Zeigermann <ol...@gmail.com> wrote:
On Wed, 20 Oct 2004 23:58:39 -0700 (PDT), Var George
wrote:
> 
> 1. public void revokePermission(Connection connection, Uri uri, NodePermission permission) method in CommonRDBMSAdaper seems to be buggy where as this issue is fixed in the same method on StandardRDBMSAdaper.java. Is there any reason why this method is overridden is CommonRDBMSAdaper .java? They seems to be doing the same thing except that the one on CommonRDBMSAdaper.java is buggy because it doesn't do null check on revisionNumber.

Except for the different SQL dialects both methods are the same, both
start with

if (permission == null) return;

both in 2.1 as in the current CVS head. Am I missing something?

Oliver

---------------------------------------------------------------------
To unsubscribe, e-mail: slide-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: slide-user-help@jakarta.apache.org


		
---------------------------------
Do you Yahoo!?
Take Yahoo! Mail with you! Get it on your mobile phone.

Re: revokePermission() in CommonRDBMSAdaper vs StandardRDBMSAdaper

Posted by Oliver Zeigermann <ol...@gmail.com>.
On Wed, 20 Oct 2004 23:58:39 -0700 (PDT), Var George
<va...@yahoo.com> wrote:
> 
> 1. public void revokePermission(Connection connection, Uri uri, NodePermission permission)  method in CommonRDBMSAdaper  seems to be buggy where as this issue is fixed in the same method on StandardRDBMSAdaper.java. Is there any reason why this method is overridden is CommonRDBMSAdaper .java? They seems to be doing the same thing except that the one on CommonRDBMSAdaper.java is buggy because it doesn't do null check on revisionNumber.

Except for the different SQL dialects both methods are the same, both
start with

        if (permission == null) return;

both in 2.1 as in the current CVS head. Am I missing something?

Oliver

---------------------------------------------------------------------
To unsubscribe, e-mail: slide-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: slide-user-help@jakarta.apache.org


Re: revokePermission() in CommonRDBMSAdapter vs StandardRDBMSAdapter

Posted by Var George <va...@yahoo.com>.
thanks, i noticed the "delete PERMISSIONS from PERMISSIONS" part after i sent the email out. 
 
Could slide team please fix the bug in CommonsRDBMSAdapter.java?.
fix based on StandardRDBMSAdapter.java changes:
 
public void revokePermission(Connection connection, Uri uri, NodePermission permission)
   throws ServiceAccessException {
   if (permission == null) return;
   PreparedStatement statement = null;
   try {
       NodeRevisionNumber revisionNumber = permission.getRevisionNumber();
       statement =
          connection.prepareStatement(
          //fix:begin: added null check for revision no
          //"delete from " + PERMISSIONS_TABLE + " p where p.OBJECT_ID in (select ou.URI_ID from " + URI_TABLE + " ou, " + URI_TABLE + " su, " + URI_TABLE + " au where ou.URI_STRING = ? and p.SUBJECT_ID = su.URI_ID and su.URI_STRING = ? and p.ACTION_ID = au.URI_ID and au.URI_STRING = ? and p.VERSION_NO = ?)");
        "delete from " + PERMISSIONS_TABLE + " p where p.OBJECT_ID in (select ou.URI_ID from " + URI_TABLE + " ou, " + URI_TABLE + " su, " + URI_TABLE + " au where ou.URI_STRING = ? and p.SUBJECT_ID = su.URI_ID and su.URI_STRING = ? and p.ACTION_ID = au.URI_ID and au.URI_STRING = ? and p.VERSION_NO" + ((revisionNumber == null) ? " IS NULL " : " = '" + revisionNumber.toString() + "'"));
          //fix:end
          statement.setString(1, permission.getObjectUri());
          statement.setString(2, permission.getSubjectUri());
          statement.setString(3, permission.getActionUri());
          //fix:begin: commented out because bind is no longer required
          //statement.setString(4, revisionNumber.toString());
          //fix:end:
          statement.executeUpdate();
    } catch (SQLException e) {
      throw createException(e, uri.toString());
    } finally {
      close(statement);
   }
}

 


Carlos Villegas <ca...@uniscope.jp> wrote:
Var George wrote:

> 2. public void revokePermissions(Connection connection, Uri uri) throws ServiceAccessException method on CommonRDBMSAdaper seems to be redundant but interestingly here the SQL logic different in CommonRDBMSAdaper & StandardRDBMSAdaper (why?). 
> 
> -- StandardRDMBSAdaper: delete PERMISSIONS from PERMISSIONS, URI u where OBJECT_ID = u.URI_ID and u.URI_STRING = ?");
> 
> -- CommonRDBMSAdaper : delete from PERMISSIONS where PERMISSIONS.OBJECT_ID in (select u.URI_ID from URI u where u.URI_STRING = ?

I think these two SQL fragments do exactly the same thing, except that 
the one in StandardRDMBSAdapter is valid for MySQL and MSSQL (I think) 
and the one in CommonRDBMSAdapter is valid for PostgreSQL and other 
databases. I think the latter is SQL99 compatible and so should be in 
the most generic class.

Carlos

---------------------------------------------------------------------
To unsubscribe, e-mail: slide-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: slide-user-help@jakarta.apache.org


		
---------------------------------
Do you Yahoo!?
vote.yahoo.com - Register online to vote today!

Re: revokePermission() in CommonRDBMSAdaper vs StandardRDBMSAdaper

Posted by Carlos Villegas <ca...@uniscope.jp>.
Var George wrote:

> 2. public void revokePermissions(Connection connection, Uri uri) throws ServiceAccessException method on  CommonRDBMSAdaper  seems  to be redundant but interestingly  here the SQL logic different in CommonRDBMSAdaper  &  StandardRDBMSAdaper (why?). 
> 
> -- StandardRDMBSAdaper: delete PERMISSIONS from PERMISSIONS, URI u where OBJECT_ID = u.URI_ID and u.URI_STRING = ?");
> 
> -- CommonRDBMSAdaper : delete from PERMISSIONS where PERMISSIONS.OBJECT_ID in (select u.URI_ID from URI u where u.URI_STRING = ?

I think these two SQL fragments do exactly the same thing, except that 
the one in StandardRDMBSAdapter is valid for MySQL and MSSQL (I think) 
and the one in CommonRDBMSAdapter is valid for PostgreSQL and other 
databases. I think the latter is SQL99 compatible and so should be in 
the most generic class.

Carlos

---------------------------------------------------------------------
To unsubscribe, e-mail: slide-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: slide-user-help@jakarta.apache.org