Review Board 1.7.22


SQOOP-630: Check if connection/job is in use before deleting as deleting used entity might result in FK violations

Review Request #7625 - Created Oct. 17, 2012 and submitted

Jarek Cecho
SQOOP-630
Reviewers
Sqoop
sqoop-sqoop2
I've implemented such check both for connection and job objects, even thought that checking if job is in use is NOP at the moment (will be improved once submission engine will be in place).
No new unit tests included at the moment, manually verified.
core/src/main/java/org/apache/sqoop/repository/JdbcRepository.java
Revision e76a0ccff37e0599130279ffbb785f56c540a95f New Change
[20] 203 lines
[+20] [+] public void deleteConnection(final long connectionId) {
204
      public Object doIt(Connection conn) {
204
      public Object doIt(Connection conn) {
205
        if(!handler.existsConnection(connectionId, conn)) {
205
        if(!handler.existsConnection(connectionId, conn)) {
206
          throw new SqoopException(RepositoryError.JDBCREPO_0017,
206
          throw new SqoopException(RepositoryError.JDBCREPO_0017,
207
            "Invalid id: " + connectionId);
207
            "Invalid id: " + connectionId);
208
        }
208
        }

    
   
209
        if(handler.inUseConnection(connectionId, conn)) {

    
   
210
          throw new SqoopException(RepositoryError.JDBCREPO_0021,

    
   
211
            "Id in use: " + connectionId);

    
   
212
        }
209

    
   
213

   
210
        handler.deleteConnection(connectionId, conn);
214
        handler.deleteConnection(connectionId, conn);
211
        return null;
215
        return null;
212
      }
216
      }
213
    });
217
    });
[+20] [20] 76 lines
[+20] [+] public void deleteJob(final long id) {
290
      public Object doIt(Connection conn) {
294
      public Object doIt(Connection conn) {
291
        if(!handler.existsJob(id, conn)) {
295
        if(!handler.existsJob(id, conn)) {
292
          throw new SqoopException(RepositoryError.JDBCREPO_0020,
296
          throw new SqoopException(RepositoryError.JDBCREPO_0020,
293
            "Invalid id: " + id);
297
            "Invalid id: " + id);
294
        }
298
        }

    
   
299
        if(handler.inUseJob(id, conn)) {

    
   
300
          throw new SqoopException(RepositoryError.JDBCREPO_0022,

    
   
301
            "Id in use: " + id);

    
   
302
        }
295

    
   
303

   
296
        handler.deleteJob(id, conn);
304
        handler.deleteJob(id, conn);
297
        return null;
305
        return null;
298
      }
306
      }
299
    });
307
    });
[+20] [20] 29 lines
core/src/main/java/org/apache/sqoop/repository/JdbcRepositoryHandler.java
Revision ff10beefbc69e1dda15cade916ebe683e7fb8991 New Change
 
core/src/main/java/org/apache/sqoop/repository/RepositoryError.java
Revision ca0c5a15e2e3565563ff874dddfe57660e902379 New Change
 
repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepoError.java
Revision 00bc926c24cd6b54d731f46e15da89f9e07cd5f0 New Change
 
repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepositoryHandler.java
Revision c72a571ee279b36e3b068414d119c347316f1aeb New Change
 
repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbySchemaQuery.java
Revision a895cfe327d4f8bd3671c298efdd2f1a6fc1d96f New Change
 
  1. core/src/main/java/org/apache/sqoop/repository/JdbcRepository.java: Loading...
  2. core/src/main/java/org/apache/sqoop/repository/JdbcRepositoryHandler.java: Loading...
  3. core/src/main/java/org/apache/sqoop/repository/RepositoryError.java: Loading...
  4. repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepoError.java: Loading...
  5. repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepositoryHandler.java: Loading...
  6. repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbySchemaQuery.java: Loading...