Project

General

Profile

« Previous | Next » 

Revision 6443

check for null pointers when adding system metadata/creating records during cn.create()

View differences:

src/edu/ucsb/nceas/metacat/dataone/D1NodeService.java
762 762
      
763 763
    }
764 764

  
765
    params = new Hashtable<String, String[]>();
765 766
    String[] action = new String[1];
766 767
    action[0] = insertOrUpdate;
767 768
    params.put("action", action);
......
788 789
    }
789 790
    
790 791
    // do the insert or update action
792
    handler = new MetacatHandler(new Timer());
791 793
    String result = handler.handleInsertOrUpdateAction(metacatUrl, null, 
792 794
                        null, params, username, groupnames);
793 795
    
src/edu/ucsb/nceas/metacat/IdentifierManager.java
1135 1135
	        int deletedCount = stmt.executeUpdate();
1136 1136
	        stmt.close();
1137 1137
            
1138
            for (Replica replica: replicas) {
1139
	            // Execute the insert statement
1140
	            String insert = "insert into systemMetadataReplicationStatus " + 
1141
	                "(guid, member_node, status, date_verified) " +
1142
	                "values (?, ?, ?, ?)";
1143
	            PreparedStatement insertStatement = dbConn.prepareStatement(insert);
1144
	            
1145
	            //data values
1146
	            String memberNode = replica.getReplicaMemberNode().getValue();
1147
	            String status = replica.getReplicationStatus().toString();
1148
	            java.sql.Date sqlDate = new java.sql.Date(replica.getReplicaVerified().getTime());
1149
	            insertStatement.setString(1, guid);
1150
	            insertStatement.setString(2, memberNode);
1151
	            insertStatement.setString(3, status);
1152
	            insertStatement.setDate(4, sqlDate);
1153

  
1154
	            //execute
1155
	            int rows = insertStatement.executeUpdate();
1156
	            insertStatement.close();
1157
            }
1138
	        if (replicas != null) {
1139
	            for (Replica replica: replicas) {
1140
		            // Execute the insert statement
1141
		            String insert = "insert into systemMetadataReplicationStatus " + 
1142
		                "(guid, member_node, status, date_verified) " +
1143
		                "values (?, ?, ?, ?)";
1144
		            PreparedStatement insertStatement = dbConn.prepareStatement(insert);
1145
		            
1146
		            //data values
1147
		            String memberNode = replica.getReplicaMemberNode().getValue();
1148
		            String status = replica.getReplicationStatus().toString();
1149
		            java.sql.Date sqlDate = new java.sql.Date(replica.getReplicaVerified().getTime());
1150
		            insertStatement.setString(1, guid);
1151
		            insertStatement.setString(2, memberNode);
1152
		            insertStatement.setString(3, status);
1153
		            insertStatement.setDate(4, sqlDate);
1154
	
1155
		            //execute
1156
		            int rows = insertStatement.executeUpdate();
1157
		            insertStatement.close();
1158
	            }
1159
	        }
1158 1160
        } catch (SQLException e) {
1159 1161
            logMetacat.error("SQL error while adding systemMetadataReplicationStatus for: " + guid, e); 
1160 1162
        } finally {

Also available in: Unified diff