private ResultSet doQuery(final PreparedStatement stm) throws SQLException { LOG.ok("Execute query {0}", stm.toString()); return stm.executeQuery(); }
public void closeConnection() throws SQLException { if (this.conn != null) { LOG.ok("Closing connection ..."); dropTableAndViewIfExists(); this.conn.close(); tables.clear(); } }
/** * Checks if resource is alive. * * @see Connector#test() */ @Override public void checkAlive() { LOG.ok("Connection test"); connection.test(); }
/** * Callback method to receive the {@link Configuration}. * * @param cfg connector configuration * @see Connector#init */ @Override public void init(final Configuration cfg) { LOG.ok("Connector initialization"); this.config = (WebServiceConfiguration) cfg; this.connection = new WebServiceConnection(this.config); }
private <T extends DummyObject> Collection<T> sortObjects(Collection<T> allObjects, OperationOptions options) { if (options == null) { return allObjects; } SortKey[] sortKeys = options.getSortKeys(); if (sortKeys == null || sortKeys.length == 0) { return allObjects; } List<T> list = new ArrayList<>(allObjects); list.sort((o1,o2) -> compare(o1, o2, sortKeys)); log.ok("Objects sorted by {0}: {1}", Arrays.toString(sortKeys), list); return list; }
/** * Indirect call of prepareCall statement with mapped callable statement parameters * @param sql a <CODE>String</CODE> sql statement definition * @param params the bind parameter values * @return return a callable statement * @throws SQLException an exception in statement */ public CallableStatement prepareCall(final String sql, final List<SQLParam> params) throws SQLException { log.ok("normalize call statement {0}", sql); final List<SQLParam> out = new ArrayList<SQLParam>(); final String nomalized = SQLUtil.normalizeNullValues(sql, params, out); final CallableStatement prepareCall = getConnection().prepareCall(nomalized); SQLUtil.setParams(prepareCall, out); log.ok("call statement {0} normalizead and prepared", nomalized); return prepareCall; }
/** * Indirect call of prepare statement with mapped prepare statement parameters * @param sql a <CODE>String</CODE> sql statement definition * @param params the bind parameter values * @return return a prepared statement * @throws SQLException an exception in statement */ public PreparedStatement prepareStatement(final String sql, final List<SQLParam> params) throws SQLException { log.ok("prepareStatement: statement {0}", sql); final List<SQLParam> out = new ArrayList<SQLParam>(); final String nomalized = SQLUtil.normalizeNullValues(sql, params, out); final PreparedStatement prepareStatement = getConnection().prepareStatement(nomalized); SQLUtil.setParams(prepareStatement, out); log.ok("prepareStatement: normalizzed statement {0} prepared", nomalized); return prepareStatement; }
@Override public ConnectorFacade newInstance(final ConnectorInfo connectorInfo, String config) { ConnectorFacade facade = CACHE.get(config); if (null == facade) { // new ConnectorFacade creation must remain cheap operation facade = super.newInstance(connectorInfo, config); ConnectorFacade ret = CACHE.putIfAbsent(facade.getConnectorFacadeKey(), facade); if (null != ret) { LOG.ok("ConnectorFacade found in cache"); facade = ret; } } return facade; }
/** * {@inheritDoc} */ @Override public ConnectorFacade newInstance(final APIConfiguration config) { ConnectorFacade facade = super.newInstance(config); ConnectorFacade ret = CACHE.putIfAbsent(facade.getConnectorFacadeKey(), facade); if (null != ret) { LOG.ok("ConnectorFacade found in cache"); facade = ret; } return facade; }
@Override public ConnectorFacade newInstance(final ConnectorInfo connectorInfo, String config) { ConnectorFacade facade = CACHE.get(config); if (null == facade) { // new ConnectorFacade creation must remain cheap operation facade = super.newInstance(connectorInfo, config); ConnectorFacade ret = CACHE.putIfAbsent(facade.getConnectorFacadeKey(), facade); if (null != ret) { LOG.ok("ConnectorFacade found in cache"); facade = ret; } } return facade; }
/** * {@inheritDoc} */ @Override public ConnectorFacade newInstance(final APIConfiguration config) { ConnectorFacade facade = super.newInstance(config); ConnectorFacade ret = CACHE.putIfAbsent(facade.getConnectorFacadeKey(), facade); if (null != ret) { LOG.ok("ConnectorFacade found in cache"); facade = ret; } return facade; }
/** * Disposes of the {@link WebServiceConnector}'s resources. * * @see Connector#dispose() */ @Override public void dispose() { LOG.ok("Dispose connector resources"); config = null; if (connection != null) { connection.dispose(); connection = null; } WebServiceConnection.shutdownBus(); }
/** * Indirect call of prepare statement using the query builder object * @param query DatabaseQueryBuilder query * @return return a prepared statement * @throws SQLException an exception in statement */ public PreparedStatement prepareStatement(DatabaseQueryBuilder query) throws SQLException { final String sql = query.getSQL(); log.ok("prepareStatement {0}", sql); return prepareStatement(sql, query.getParams()); }
private void executeImpl() throws SQLException { if (!userExists(uid.getUidValue(), conn, conf)) { throw new ConnectorException("User does not exist"); } conn.deleteAccount(uid); LOG.ok("Delete completed"); } }
@Override protected void extendSchema(SchemaBuilder builder) { super.extendSchema(builder); if (configuration.getSupportRunAs()) { log.ok("Adding runAs options to schema"); builder.defineOperationOption(OperationOptionInfoBuilder.buildRunWithUser(), UpdateAttributeValuesOp.class); builder.defineOperationOption(OperationOptionInfoBuilder.buildRunWithPassword(), UpdateAttributeValuesOp.class); } }
@Override protected void extendSchema(SchemaBuilder builder) { super.extendSchema(builder); if (configuration.getSupportRunAs()) { log.ok("Adding runAs options to schema"); builder.defineOperationOption(OperationOptionInfoBuilder.buildRunWithUser(), UpdateDeltaOp.class); builder.defineOperationOption(OperationOptionInfoBuilder.buildRunWithPassword(), UpdateDeltaOp.class); } }
private Uid executeImpl() throws SQLException { if (uid == null || StringUtil.isBlank(uid.getUidValue())) { throw new IllegalArgumentException("No Name attribute provided in the attributes"); } if (!userExists(uid.getUidValue(), conn, conf)) { throw new ConnectorException("User doesn't exist"); } conn.updateAccount(getAttributeMap(conf, attrs, new Name(uid.getUidValue())), uid); LOG.ok("Creation commited"); return uid; } }
private Uid executeImpl() throws SQLException { final Name name = AttributeUtil.getNameFromAttributes(attrs); if (name == null || StringUtil.isBlank(name.getNameValue())) { throw new IllegalArgumentException( "No Name attribute provided in the attributes"); } if (userExists(name.getNameValue(), conn, conf)) { throw new ConnectorException("User Exists"); } conn.insertAccount(getAttributeMap(conf, attrs, name)); LOG.ok("Creation commited"); return new Uid(name.getNameValue()); } }
/** * Unit test for checking if the {@link Configuration} property type is supported */ @Test public void testPropertiesType() { assertNotNull(_configProperties); List<String> propertyNames = _configProperties.getPropertyNames(); assertNotNull(propertyNames); //go through the properties and check the type for (String propertyName : propertyNames) { ConfigurationProperty property = _configProperties.getProperty(propertyName); assertNotNull(property); String typeName = property.getType().getName(); LOG.ok("Property: ''{0}'' type ''{1}''", property.getName(), typeName); assertTrue("Type " + typeName + " not allowed in configuration!", FrameworkUtil .isSupportedConfigurationType(property.getType())); } } }
/** * Unit test for checking if the {@link Configuration} property type is supported */ @Test public void testPropertiesType() { assertNotNull(_configProperties); List<String> propertyNames = _configProperties.getPropertyNames(); assertNotNull(propertyNames); //go through the properties and check the type for (String propertyName : propertyNames) { ConfigurationProperty property = _configProperties.getProperty(propertyName); assertNotNull(property); String typeName = property.getType().getName(); LOG.ok("Property: ''{0}'' type ''{1}''", property.getName(), typeName); assertTrue("Type " + typeName + " not allowed in configuration!", FrameworkUtil .isSupportedConfigurationType(property.getType())); } } }