Project

General

Profile

« Previous | Next » 

Revision 5444

Added by berkley over 14 years ago

fixed problems with access control on sysmeta

View differences:

src/edu/ucsb/nceas/metacat/dataone/CrudService.java
268 268
            InputStream object, SystemMetadata sysmeta) throws InvalidToken, 
269 269
            ServiceFailure, NotAuthorized, IdentifierNotUnique, UnsupportedType, 
270 270
            InsufficientResources, InvalidSystemMetadata, NotImplemented {
271
        System.out.println("#####################Create!");
271 272

  
272 273
        logMetacat.debug("Starting CrudService.create()...");
273 274
        
......
332 333
        // For Metadata and Data, insert the system metadata into the object store too
333 334
        String sysMetaLocalId = insertSystemMetadata(sysmeta, sessionData);
334 335
        //get the document info.  add any access params for the sysmeta too
336
        System.out.println("looking for access records to add for system " +
337
            "metadata who's parent doc's  local id is " + localId);
335 338
        try
336 339
        {
337
            Hashtable<String, Object> h = im.getDocumentInfo(sysMetaLocalId);
340
            Hashtable<String, Object> h = im.getDocumentInfo(localId.substring(0, localId.lastIndexOf(".")));
338 341
            Vector v = (Vector)h.get("access");
339 342
            for(int i=0; i<v.size(); i++)
340 343
            {
......
344 347
                String permissionType = (String)ah.get("permission_type");
345 348
                String permissionOrder = (String)ah.get("permission_order");
346 349
                int perm = new Integer(permission).intValue();
347
                this.setAccess(token, guid, principal, perm, permissionType, permissionOrder, false);
350
                System.out.println("found access record for principal " + principal);
351
                System.out.println("permission: " + perm + " perm_type: " + permissionType + 
352
                    " perm_order: " + permissionOrder);
353
                this.setAccess(token, guid, principal, perm, permissionType, permissionOrder, true);
348 354
            }
349 355
        }
350 356
        catch(Exception e)
......
437 443
        {
438 444
            perm = "write";
439 445
        }
446
        System.out.println("perm in setAccess: " + perm);
447
        System.out.println("permission in setAccess: " + permission);
440 448
        setAccess(token, id, principal, perm, permissionType, permissionOrder,
441 449
                setSystemMetadata);
442 450
       
......
1386 1394
        System.out.println("****inserting new system metadata with modified date " + sysmeta.getDateSysMetadataModified());
1387 1395

  
1388 1396
        String xml = new String(serializeSystemMetadata(sysmeta).toByteArray());
1389
        //System.out.println("sysmeta: " + xml);
1397
        System.out.println("sysmeta: " + xml);
1390 1398
        String localId = insertDocument(xml, sysMetaGuid, sessionData);
1391 1399
        System.out.println("sysmeta inserted with localId " + localId);
1392 1400
        //insert the system metadata doc id into the identifiers table to 
src/edu/ucsb/nceas/metacat/IdentifierManager.java
133 133
                throw new McdbDocNotFoundException("Could not find document " + localId);
134 134
            }
135 135
            
136
            String sql2 = "select principal_name, permission, perm_type, perm_order from xml_acccess " +
136
            String sql2 = "select principal_name, permission, perm_type, perm_order from xml_access " +
137 137
            "where docid like '" + localId + "'";
138
            System.out.println("executing sql: " + sql2);
138 139
            PreparedStatement stmt2 = dbConn.prepareStatement(sql2);
139 140
            rs = stmt2.executeQuery();
140 141
            Vector accessVector = new Vector();
......
149 150
                accessHash.put("permission", permission);
150 151
                accessHash.put("permission_type", permissionType);
151 152
                accessHash.put("permission_order", permissionOrder);
153
                System.out.println("accessHash: " + accessHash.toString());
152 154
                accessVector.add(accessHash);
153 155
            }
154 156
            h.put("access", accessVector);
155 157
        } 
156 158
        catch (SQLException e) 
157 159
        {
160
            e.printStackTrace();
158 161
            logMetacat.error("Error while getting document info for localid " + localId + " : "  
159 162
                    + e.getMessage());
160 163
        } 

Also available in: Unified diff