public OScriptDocumentDatabaseWrapper getDatabase() { if (db == null) throw new OConfigurationException("No database instance found in context"); if (db instanceof ODatabaseDocumentInternal) return new OScriptDocumentDatabaseWrapper((ODatabaseDocumentInternal) db); throw new OConfigurationException("No valid database instance found in context: " + db + ", class: " + db.getClass()); } }
protected void analyzeFlow() { if (extractor == null) throw new OConfigurationException("extractor is null"); if (loader == null) throw new OConfigurationException("loader is null"); OETLComponent lastComponent = extractor; for (OETLTransformer t : transformers) { checkTypeCompatibility(t, lastComponent); lastComponent = t; } checkTypeCompatibility(loader, lastComponent); }
@Override public void configure(OETLProcessor iProcessor, final ODocument iConfiguration, OCommandContext iContext) { super.configure(iProcessor, iConfiguration, iContext); operation = iConfiguration.field("operation"); if (operation == null) throw new OConfigurationException("Flow transformer has not mandatory 'operation' field"); if (!operation.equalsIgnoreCase("halt") && !operation.equalsIgnoreCase("skip")) throw new OConfigurationException("Flow transformer has invalid 'operation' field='" + operation + "', while supported are: 'skip' and 'halt'"); }
protected void analyzeFlow() { if (extractor == null) throw new OConfigurationException("extractor is null"); if (loader == null) throw new OConfigurationException("loader is null"); OETLComponent lastComponent = extractor; for (OTransformer t : transformers) { checkTypeCompatibility(t, lastComponent); lastComponent = t; } checkTypeCompatibility(loader, lastComponent); }
@Override public void configure(final ODocument iConfiguration, OCommandContext iContext) { super.configure(iConfiguration, iContext); operation = iConfiguration.field("operation"); if (operation == null) throw new OConfigurationException("Flow transformer has not mandatory 'operation' field"); if (!operation.equalsIgnoreCase("halt") && !operation.equalsIgnoreCase("skip")) throw new OConfigurationException( "Flow transformer has invalid 'operation' field='" + operation + "', while supported are: 'skip' and 'halt'"); }
public synchronized byte[] digestSHA256(final String iInput) { if (iInput == null) return null; try { return md.digest(iInput.getBytes("UTF-8")); } catch (UnsupportedEncodingException e) { final String message = "The requested encoding is not supported: cannot execute security checks"; OLogManager.instance().error(this, message, e); throw OException.wrapException(new OConfigurationException(message), e); } }
@SuppressWarnings("unchecked") public ORuntimeKeyIndexDefinition(final byte iId, int version) { super(); serializer = (OBinarySerializer<T>) OBinarySerializerFactory.getInstance().getObjectSerializer(iId); if (serializer == null) throw new OConfigurationException("Runtime index definition cannot find binary serializer with id=" + iId + ". Assure to plug custom serializer into the server."); }
public OIndexInternal<?> createIndex(String name, OStorage storage, String indexType, String algorithm, String valueContainerAlgorithm, ODocument metadata, int version) throws OConfigurationException { if (valueContainerAlgorithm == null) valueContainerAlgorithm = NONE_VALUE_CONTAINER; if (version < 0) version = getLastVersion(); if (AUTOSHARDING_ALGORITHM.equals(algorithm)) return createShardedIndex(name, indexType, valueContainerAlgorithm, metadata, (OAbstractPaginatedStorage) storage.getUnderlying(), version); throw new OConfigurationException("Unsupported type: " + indexType); }
@Override public void startup() { final OServerNetworkListener listener = server.getListenerByProtocol(ONetworkProtocolHttpAbstract.class); if (listener == null) throw new OConfigurationException("HTTP listener not found"); listener.registerStatelessCommand(new OServerCommandETL()); }
@Override public OCommandCacheSoftRefs enable() { enable = true; configuration.field("enabled", true); try { updateCfgOnDisk(); } catch (IOException e) { throw OException.wrapException( new OConfigurationException("Cannot write Command Cache Cache configuration to file '" + CONFIG_FILE + "'"), e); } return this; }
private void checkForAutoReloading() { if (configurationLoader != null) if (configurationLoader.checkForAutoReloading()) { try { configuration = configurationLoader.load(); } catch (IOException e) { throw OException.wrapException(new OConfigurationException("Cannot load server configuration"), e); } } } }
private OIndexInternal<?> createShardedIndex(final String name, final String indexType, final String valueContainerAlgorithm, final ODocument metadata, final OAbstractPaginatedStorage storage, final int version) { final int binaryFormatVersion = storage.getConfiguration().getBinaryFormatVersion(); if (OClass.INDEX_TYPE.UNIQUE.toString().equals(indexType)) { return new OIndexUnique(name, indexType, AUTOSHARDING_ALGORITHM, version, storage, valueContainerAlgorithm, metadata, binaryFormatVersion); } else if (OClass.INDEX_TYPE.NOTUNIQUE.toString().equals(indexType)) { return new OIndexNotUnique(name, indexType, AUTOSHARDING_ALGORITHM, version, storage, valueContainerAlgorithm, metadata, binaryFormatVersion); } throw new OConfigurationException("Unsupported type: " + indexType); }
private ODocument loadConfiguration() { try { final File f = getConfigFile(); if (f != null && f.exists()) { final String configurationContent = OIOUtils.readFileAsString(f); return new ODocument().fromJSON(configurationContent); } } catch (Exception e) { throw OException.wrapException(new OConfigurationException( "Cannot load Command Cache Cache configuration file '" + CONFIG_FILE + "'. Command Cache will use default settings"), e); } return null; }
@Override protected void serializeFromStream() { super.serializeFromStream(); final byte keySerializerId = ((Number) document.field("keySerializerId")).byteValue(); serializer = (OBinarySerializer<T>) OBinarySerializerFactory.getInstance().getObjectSerializer(keySerializerId); if (serializer == null) throw new OConfigurationException("Runtime index definition cannot find binary serializer with id=" + keySerializerId + ". Assure to plug custom serializer into the server."); String collateField = document.field("collate"); if (collateField == null) collateField = ODefaultCollate.NAME; setNullValuesIgnored(!Boolean.FALSE.equals(document.<Boolean> field("nullValuesIgnored"))); }
@Override public void configure(ODocument iConfiguration, OCommandContext iContext) { super.configure(iConfiguration, iContext); url = iConfiguration.field("url"); if (url == null || url.isEmpty()) throw new OConfigurationException("HTTP Source missing URL"); if (iConfiguration.containsField("method")) method = iConfiguration.field("method"); if (iConfiguration.containsField("headers")) headers = iConfiguration.field("headers"); }
@Override public void configure(OETLProcessor iProcessor, ODocument iConfiguration, OCommandContext iContext) { super.configure(iProcessor, iConfiguration, iContext); url = iConfiguration.field("url"); if (url == null || url.isEmpty()) throw new OConfigurationException("HTTP Source missing URL"); if (iConfiguration.containsField("method")) method = iConfiguration.field("method"); if (iConfiguration.containsField("headers")) headers = iConfiguration.field("headers"); }
protected boolean skip(final Object input) { final OSQLFilter ifFilter = getIfFilter(); if (ifFilter != null) { final ODocument doc = input instanceof OIdentifiable ? (ODocument) ((OIdentifiable) input).getRecord() : null; log(Level.FINE, "Evaluating conditional expression if=%s...", ifFilter); final Object result = ifFilter.evaluate(doc, null, context); if (!(result instanceof Boolean)) throw new OConfigurationException( "'if' expression in Transformer " + getName() + " returned '" + result + "' instead of boolean"); return !(Boolean) result; } return false; }
@Override public void configure(OETLProcessor iProcessor, final ODocument iConfiguration, OCommandContext iContext) { super.configure(iProcessor, iConfiguration, iContext); final String[] fieldNames = iConfiguration.fieldNames(); try { block = processor.getFactory().getBlock(fieldNames[0]); block.configure(processor, (ODocument) iConfiguration.field(fieldNames[0]), context); } catch (Exception e) { throw new OConfigurationException("[Block transformer] Error on configuring inner block", e); } }
@Override public void begin(ODatabaseDocument db) { super.begin(db); final String[] fieldNames = configuration.fieldNames(); try { String fieldName = fieldNames[0]; block = new OETLComponentFactory().getBlock(fieldName); block.configure(configuration.<ODocument>field(fieldName), context); } catch (Exception e) { throw OException.wrapException(new OConfigurationException("[Block transformer] Error on configuring inner block"), e); } }
private OIndexInternal<?> createLuceneIndex(String name, ODatabaseDocumentInternal oDatabaseRecord, String indexType, String valueContainerAlgorithm, ODocument metadata) { if (OClass.INDEX_TYPE.FULLTEXT.toString().equals(indexType)) { return new OLuceneFullTextIndex(name, indexType, LUCENE_ALGORITHM, new OLuceneIndexEngine<Set<OIdentifiable>>( new OLuceneFullTextIndexManager(), indexType), valueContainerAlgorithm, metadata); } else if (OClass.INDEX_TYPE.SPATIAL.toString().equals(indexType)) { return new OLuceneSpatialIndex(name, indexType, LUCENE_ALGORITHM, new OLuceneIndexEngine<Set<OIdentifiable>>( new OLuceneSpatialIndexManager(OShapeFactoryImpl.INSTANCE), indexType), valueContainerAlgorithm, metadata); } throw new OConfigurationException("Unsupported type : " + indexType); } }