63 |
63 |
* Construct an instance of the AccessControlList class.
|
64 |
64 |
* It is used by the permission check up from DBQuery and DocumentImpl
|
65 |
65 |
*/
|
66 |
|
public AccessControlList ()
|
|
66 |
public AccessControlList () //throws SQLException, ClassNotFoundException
|
67 |
67 |
{
|
68 |
|
// this.conn = conn;
|
|
68 |
//MetaCatUtil util = new MetaCatUtil();
|
|
69 |
//this.conn = util.openDBConnection();
|
69 |
70 |
}
|
70 |
71 |
|
71 |
72 |
/**
|
... | ... | |
346 |
347 |
String principal, String resourceId )
|
347 |
348 |
throws SQLException
|
348 |
349 |
{
|
|
350 |
Connection dbconn = conn;
|
|
351 |
|
|
352 |
if ( dbconn == null ) {
|
|
353 |
System.out.println("AccessControlList.hasPermission(): " +
|
|
354 |
"DB connection was closed. Open a new one");
|
|
355 |
try {
|
|
356 |
MetaCatUtil util = new MetaCatUtil();
|
|
357 |
dbconn = util.openDBConnection();
|
|
358 |
} catch (Exception e) {
|
|
359 |
throw new SQLException(e.getMessage());
|
|
360 |
}
|
|
361 |
}
|
|
362 |
|
349 |
363 |
PreparedStatement pstmt;
|
350 |
364 |
// check public access to @resourceId from xml_documents table
|
351 |
365 |
if ( permission.equals("READ") ) {
|
352 |
366 |
try {
|
353 |
|
pstmt = conn.prepareStatement(
|
|
367 |
pstmt = dbconn.prepareStatement(
|
354 |
368 |
"SELECT 'x' FROM xml_documents " +
|
355 |
369 |
"WHERE docid LIKE ? AND public_access = 1");
|
356 |
370 |
// Bind the values to the query
|
... | ... | |
376 |
390 |
// check if @principal is owner of @resourceId in xml_documents table
|
377 |
391 |
if ( principal != null ) {
|
378 |
392 |
try {
|
379 |
|
pstmt = conn.prepareStatement(
|
|
393 |
pstmt = dbconn.prepareStatement(
|
380 |
394 |
"SELECT 'x' FROM xml_documents " +
|
381 |
395 |
"WHERE docid LIKE ? AND user_owner LIKE ?");
|
382 |
396 |
// Bind the values to the query
|
... | ... | |
403 |
417 |
int ticketCount = 0;
|
404 |
418 |
String permOrder = "";
|
405 |
419 |
try {
|
406 |
|
pstmt = conn.prepareStatement(
|
|
420 |
pstmt = dbconn.prepareStatement(
|
407 |
421 |
"SELECT permission, perm_order, ticket_count " +
|
408 |
422 |
"FROM xml_access " +
|
409 |
423 |
"WHERE docid LIKE ? " +
|
problem with passing the connection between objects