Project

General

Profile

« Previous | Next » 

Revision 6123

check system metadata for the id as well (in cases when we only have system metadata)

View differences:

IdentifierManager.java
752 752
                idExists = true;
753 753
            }
754 754
        } catch (McdbDocNotFoundException e) {
755
            idExists = false;
755
        	// try system metadata only
756
        	try {
757
        		idExists = systemMetadataExisits(guid);
758
            } catch (McdbDocNotFoundException e2) {
759
            	idExists = false;
760
            }
756 761
        }
757 762
        return idExists;
758 763
    }
......
865 870
        return guid;
866 871
    }
867 872
    
873
    public boolean systemMetadataExisits(String guid)
874
			throws McdbDocNotFoundException {
875
		logMetacat.debug("looking up system metadata for guid " + guid);
876
		boolean exists = false;
877
		String query = "select guid from systemmetadata where guid = ?";
878

  
879
		DBConnection dbConn = null;
880
		int serialNumber = -1;
881
		try {
882
			// Get a database connection from the pool
883
			dbConn = DBConnectionPool.getDBConnection("IdentifierManager.systemMetadataExisits");
884
			serialNumber = dbConn.getCheckOutSerialNumber();
885

  
886
			// Execute the insert statement
887
			PreparedStatement stmt = dbConn.prepareStatement(query);
888
			stmt.setString(1, guid);
889

  
890
			ResultSet rs = stmt.executeQuery();
891
			if (rs.next()) {
892
				exists = true;
893
			} else {
894
				throw new McdbDocNotFoundException(
895
						"No system metadata registered for guid " + guid);
896
			}
897

  
898
		} catch (SQLException e) {
899
			logMetacat.error("Error while looking up the system metadata: "
900
					+ e.getMessage());
901
		} finally {
902
			// Return database connection to the pool
903
			DBConnectionPool.returnDBConnection(dbConn, serialNumber);
904
		}
905

  
906
		return exists;
907
	}
908
    
868 909
    /**
869 910
     * creates a system metadata mapping and adds additional fields from sysmeta
870 911
     * to the table for quick searching.

Also available in: Unified diff