@Test public void testDeleteFail() throws SQLException { OracleConnector testConnector = createTestConnector(); String newUser = "newUser"; try { testConnector.delete(ObjectClass.ACCOUNT, new Uid(newUser), null); } catch (UnknownUidException e) { } Attribute authentication = AttributeBuilder.build(OracleConstants.ORACLE_AUTHENTICATION_ATTR_NAME, OracleConstants.ORACLE_AUTH_LOCAL); Attribute name = new Name(newUser); Attribute password = AttributeBuilder.buildPassword("password".toCharArray()); Uid uid = testConnector.create(ObjectClass.ACCOUNT, CollectionUtil.newSet(authentication, name, password), null); testConnector.delete(ObjectClass.ACCOUNT, uid, null); uid = testConnector.create(ObjectClass.ACCOUNT, CollectionUtil.newSet(authentication, name, password), null); OracleSpecifics.killConnection(connector.getOrCreateAdminConnection(), testConnector .getOrCreateAdminConnection()); try { testConnector.delete(ObjectClass.ACCOUNT, uid, null); Assert.fail("Delete must fail for killed connection"); } catch (UnknownUidException e) { Assert.fail("Should not throw UnknownUidException for killed connection"); } catch (RuntimeException e) { } testConnector.dispose(); connector.delete(ObjectClass.ACCOUNT, uid, null); try { connector.delete(ObjectClass.GROUP, uid, null); Assert.fail("Delete must fail group"); } catch (UnknownUidException e) { Assert.fail("Should not throw UnknownUidException for group"); } catch (RuntimeException e) { } }
public void delete(ObjectClass objClass, Uid uid, OperationOptions options) { OracleConnectorHelper.checkObjectClass(objClass, cfg.getConnectorMessages()); if (cfg.isDropCascade()) { LOG.info("Deleting user cascade: [{0}]", uid.getUidValue()); } else { LOG.info("Deleting user noncascade: [{0}]", uid.getUidValue()); } String userName = uid.getUidValue(); String sql = "drop user " + cfg.getCSSetup().formatToken(OracleUserAttribute.USER, userName); if (cfg.isDropCascade()) { sql = sql + " CASCADE"; } Statement st = null; try { st = adminConn.createStatement(); st.executeUpdate(sql); adminConn.commit(); LOG.info("User deleted : [{0}]", uid.getUidValue()); } catch (SQLException e) { SQLUtil.rollbackQuietly(adminConn); if ("42000".equals(e.getSQLState()) && 1918 == e.getErrorCode()) { throw new UnknownUidException(uid, ObjectClass.ACCOUNT); } throw new ConnectorException(cfg.getConnectorMessages().format( MSG_DELETE_OF_USER_FAILED, null, uid.getUidValue()), e); } finally { SQLUtil.closeQuietly(st); } }
OracleOperationDelete extends AbstractOracleOperation implements DeleteOp { public void delete(ObjectClass objClass, Uid uid, OperationOptions options) { OracleConnectorHelper.checkObjectClass(objClass, cfg.getConnectorMessages()); if (cfg.isDropCascade()) { LOG.info("Deleting user cascade: [{0}]", uid.getUidValue()); } else { LOG.info("Deleting user noncascade: [{0}]", uid.getUidValue()); } String userName = uid.getUidValue(); String sql = "drop user " + cfg.getCSSetup().formatToken(OracleUserAttribute.USER, userName); if (cfg.isDropCascade()) { sql = sql + " CASCADE"; } Statement st = null; try { st = adminConn.createStatement(); st.executeUpdate(sql); adminConn.commit(); LOG.info("User deleted : [{0}]", uid.getUidValue()); } catch (SQLException e) { SQLUtil.rollbackQuietly(adminConn); if ("42000".equals(e.getSQLState()) && 1918 == e.getErrorCode()) { throw new UnknownUidException(uid, ObjectClass.ACCOUNT); } throw new ConnectorException(cfg.getConnectorMessages().format( MSG_DELETE_OF_USER_FAILED, null, uid.getUidValue()), e); } finally { SQLUtil.closeQuietly(st); } } }
OracleOperationDelete extends AbstractOracleOperation implements DeleteOp { public void delete(ObjectClass objClass, Uid uid, OperationOptions options) { OracleConnectorHelper.checkObjectClass(objClass, cfg.getConnectorMessages()); if (cfg.isDropCascade()) { LOG.info("Deleting user cascade: [{0}]", uid.getUidValue()); } else { LOG.info("Deleting user noncascade: [{0}]", uid.getUidValue()); } String userName = uid.getUidValue(); String sql = "drop user " + cfg.getCSSetup().formatToken(OracleUserAttribute.USER, userName); if (cfg.isDropCascade()) { sql = sql + " CASCADE"; } Statement st = null; try { st = adminConn.createStatement(); st.executeUpdate(sql); adminConn.commit(); LOG.info("User deleted : [{0}]", uid.getUidValue()); } catch (SQLException e) { SQLUtil.rollbackQuietly(adminConn); if ("42000".equals(e.getSQLState()) && 1918 == e.getErrorCode()) { throw new UnknownUidException(uid, ObjectClass.ACCOUNT); } throw new ConnectorException(cfg.getConnectorMessages().format( MSG_DELETE_OF_USER_FAILED, null, uid.getUidValue()), e); } finally { SQLUtil.closeQuietly(st); } } OracleOperationDelete(OracleConfiguration cfg, Connection adminConn); }
OracleOperationDelete extends AbstractOracleOperation implements DeleteOp { public void delete(ObjectClass objClass, Uid uid, OperationOptions options) { OracleConnectorHelper.checkObjectClass(objClass, cfg.getConnectorMessages()); if (cfg.isDropCascade()) { LOG.info("Deleting user cascade: [{0}]", uid.getUidValue()); } else { LOG.info("Deleting user noncascade: [{0}]", uid.getUidValue()); } String userName = uid.getUidValue(); String sql = "drop user " + cfg.getCSSetup().formatToken(OracleUserAttribute.USER, userName); if (cfg.isDropCascade()) { sql = sql + " CASCADE"; } Statement st = null; try { st = adminConn.createStatement(); st.executeUpdate(sql); adminConn.commit(); LOG.info("User deleted : [{0}]", uid.getUidValue()); } catch (SQLException e) { SQLUtil.rollbackQuietly(adminConn); if ("42000".equals(e.getSQLState()) && 1918 == e.getErrorCode()) { throw new UnknownUidException(uid, ObjectClass.ACCOUNT); } throw new ConnectorException(cfg.getConnectorMessages().format( MSG_DELETE_OF_USER_FAILED, null, uid.getUidValue()), e); } finally { SQLUtil.closeQuietly(st); } } OracleOperationDelete(OracleConfiguration cfg, Connection adminConn); void delete(ObjectClass objClass, Uid uid, OperationOptions options); }
OracleOperationDelete extends AbstractOracleOperation implements DeleteOp { public void delete(ObjectClass objClass, Uid uid, OperationOptions options) { OracleConnectorHelper.checkObjectClass(objClass, cfg.getConnectorMessages()); if (cfg.isDropCascade()) { LOG.info("Deleting user cascade: [{0}]", uid.getUidValue()); } else { LOG.info("Deleting user noncascade: [{0}]", uid.getUidValue()); } String userName = uid.getUidValue(); String sql = "drop user " + cfg.getCSSetup().formatToken(OracleUserAttribute.USER, userName); if (cfg.isDropCascade()) { sql = sql + " CASCADE"; } Statement st = null; try { st = adminConn.createStatement(); st.executeUpdate(sql); adminConn.commit(); LOG.info("User deleted : [{0}]", uid.getUidValue()); } catch (SQLException e) { SQLUtil.rollbackQuietly(adminConn); if ("42000".equals(e.getSQLState()) && 1918 == e.getErrorCode()) { throw new UnknownUidException(uid, ObjectClass.ACCOUNT); } throw new ConnectorException(cfg.getConnectorMessages().format( MSG_DELETE_OF_USER_FAILED, null, uid.getUidValue()), e); } finally { SQLUtil.closeQuietly(st); } } OracleOperationDelete(OracleConfiguration cfg, Connection adminConn); void delete(ObjectClass objClass, Uid uid, OperationOptions options);  }