Project

General

Profile

« Previous | Next » 

Revision 9056

Added by Jing Tao over 9 years ago

Add the code to check the if the new series id is legitimate in the systemMetadataChanged method.

View differences:

MNodeService.java
1304 1304
                throw sf;
1305 1305
            }
1306 1306
            
1307
            //check about the sid in the system metadata
1308
            Identifier newSID = newSysMeta.getSeriesId();
1309
            if(newSID != null) {
1310
                if (!isValidIdentifier(newSID)) {
1311
                    throw new InvalidRequest("1334", "The series identifier in the new system metadata is invalid.");
1312
                }
1313
                Identifier currentSID = currentLocalSysMeta.getSeriesId();
1314
                if( currentSID != null && currentSID.getValue() != null) {
1315
                    if(!newSID.getValue().equals(currentSID.getValue())) {
1316
                        //newSID doesn't match the currentSID. The newSID shouldn't be used.
1317
                        try {
1318
                            if(IdentifierManager.getInstance().identifierExists(newSID.getValue())) {
1319
                                throw new InvalidRequest("1334", "The series identifier "+newSID.getValue()+" in the new system metadata has been used by another object.");
1320
                            }
1321
                        } catch (SQLException sql) {
1322
                            throw new ServiceFailure("1333", "Couldn't determine if the SID "+newSID.getValue()+" in the system metadata exists in the node since "+sql.getMessage());
1323
                        }
1324
                        
1325
                    }
1326
                } else {
1327
                    //newSID shouldn't be used
1328
                    try {
1329
                        if(IdentifierManager.getInstance().identifierExists(newSID.getValue())) {
1330
                            throw new InvalidRequest("1334", "The series identifier "+newSID.getValue()+" in the new system metadata has been used by another object.");
1331
                        }
1332
                    } catch (SQLException sql) {
1333
                        throw new ServiceFailure("1333", "Couldn't determine if the SID "+newSID.getValue()+" in the system metadata exists in the node since "+sql.getMessage());
1334
                    }
1335
                }
1336
            }
1307 1337
            // update the local copy of system metadata for the pid
1308 1338
            try {
1309 1339
                HazelcastService.getInstance().getSystemMetadataMap().put(newSysMeta.getIdentifier(), newSysMeta);

Also available in: Unified diff