Project

General

Profile

« Previous | Next » 

Revision 6892

Added by Chris Jones over 12 years ago

In IdentifierManager, throw SQLExceptions rather than just logging them, and let them be handled higher up in the stack.

View differences:

IdentifierManager.java
914 914
     * @param guid the id to insert
915 915
     * @param localId the systemMetadata object to get the local id for
916 916
     * @throws McdbDocNotFoundException 
917
     * @throws SQLException 
917 918
     */
918
    public void createSystemMetadata(SystemMetadata sysmeta) throws McdbDocNotFoundException
919
    {
919
    public void createSystemMetadata(SystemMetadata sysmeta) 
920
        throws McdbDocNotFoundException, SQLException {
920 921
    	String guid = sysmeta.getIdentifier().getValue();
921 922
    	// insert the record
922 923
        insertSystemMetadata(guid);
923 924
        // update with the values
924 925
        updateSystemMetadata(sysmeta);
926
        
925 927
    }
926 928
        
927 929
    
......
980 982
    }
981 983
        
982 984
    private void updateSystemMetadataFields(long dateUploaded, String rightsHolder,
983
            String checksum, String checksumAlgorithm, String originMemberNode,
984
            String authoritativeMemberNode, long modifiedDate, String submitter, 
985
            String guid, String objectFormat, BigInteger size, boolean archived, boolean replicationAllowed,
986
            int numberReplicas, String obsoletes, String obsoletedBy, BigInteger serialVersion)
987
    {
985
        String checksum, String checksumAlgorithm, String originMemberNode, 
986
        String authoritativeMemberNode, long modifiedDate, String submitter, 
987
        String guid, String objectFormat, BigInteger size, boolean archived,
988
        boolean replicationAllowed, int numberReplicas, String obsoletes,
989
        String obsoletedBy, BigInteger serialVersion) throws SQLException  {
990
        
988 991
        DBConnection dbConn = null;
989 992
        int serialNumber = -1;
990 993
        
......
1028 1031
            int rows = stmt.executeUpdate();
1029 1032

  
1030 1033
            stmt.close();
1034
            
1031 1035
        } catch (SQLException e) {
1032
            e.printStackTrace();
1033 1036
            logMetacat.error("updateSystemMetadataFields: SQL error while updating system metadata: " 
1034 1037
                    + e.getMessage());
1035
        } catch (NumberFormatException e) {
1036
            e.printStackTrace();
1037
            logMetacat.error("updateSystemMetadataFields: NumberFormat error while updating system metadata: " 
1038
                    + e.getMessage());
1038
            throw e;
1039
            
1039 1040
        } finally {
1040 1041
            // Return database connection to the pool
1041 1042
            DBConnectionPool.returnDBConnection(dbConn, serialNumber);
......
1140 1141
     * Insert the system metadata fields into the db
1141 1142
     * @param sm
1142 1143
     * @throws McdbDocNotFoundException 
1144
     * @throws SQLException 
1143 1145
     */
1144
    public void updateSystemMetadata(SystemMetadata sm) throws McdbDocNotFoundException {
1146
    public void updateSystemMetadata(SystemMetadata sm) 
1147
      throws McdbDocNotFoundException, SQLException {
1145 1148
    	
1146
        Boolean replicationAllowed = false;
1147
		Integer numberReplicas = -1;
1149
      Boolean replicationAllowed = false;
1150
		  Integer numberReplicas = -1;
1148 1151
    	ReplicationPolicy replicationPolicy = sm.getReplicationPolicy();
1149 1152
    	if (replicationPolicy != null) {
1150 1153
    		replicationAllowed = replicationPolicy.getReplicationAllowed();
......
1154 1157
    	}
1155 1158

  
1156 1159
    	// the main systemMetadata fields
1157
		updateSystemMetadataFields(
1160
		  updateSystemMetadataFields(
1158 1161
				sm.getDateUploaded() == null ? null: sm.getDateUploaded().getTime(),
1159 1162
				sm.getRightsHolder() == null ? null: sm.getRightsHolder().getValue(), 
1160 1163
				sm.getChecksum() == null ? null: sm.getChecksum().getValue(), 

Also available in: Unified diff