private byte[] bytesFromString(final String toWrite) { try { return toWrite.getBytes(CHARSET_UTF_8); } catch (UnsupportedEncodingException e) { throw OException.wrapException(new OSerializationException("Error on string encoding"), e); } }
public IndexSearcher searcher() { // TODO optimize try { return new IndexSearcher(DirectoryReader.open(writer, true, true)); } catch (IOException e) { // OLogManager.instance().error(this, "Error during searcher index instantiation on new documents", e); throw OException.wrapException(new OLuceneIndexException("Error during searcher index instantiation on new documents"), e); } }
public void onAfterFetch(final ODocument iRootRecord) { StringBuilder buffer = typesStack.pop(); if (settings.keepTypes && buffer.length() > 0) try { jsonWriter.writeAttribute(settings.indentLevel > -1 ? settings.indentLevel : 1, true, ORecordSerializerJSON.ATTRIBUTE_FIELD_TYPES, buffer.toString()); } catch (IOException e) { throw OException.wrapException(new OFetchException("Error writing field types"), e); } }
@Override public void remove() { try { sbTree.remove(currentEntry.getKey()); } catch (IOException e) { throw OException.wrapException(new ODatabaseException("Error during removal of element of tree"), e); } currentEntry = null; } }
@Override public Object execute(Object iThis, OIdentifiable iCurrentRecord, Object iCurrentResult, Object[] iParams, OCommandContext iContext) { String geom = (String) iParams[0]; try { return factory.toDoc(geom); } catch (Exception e) { throw OException.wrapException(new OCommandExecutionException(String.format("Cannot parse geometry {%s}", geom)), e); } }
public static OInputParameter deserializeFromOResult(OResult doc) { try { OInputParameter result = (OInputParameter) Class.forName(doc.getProperty("__class")).getConstructor(Integer.class) .newInstance(-1); result.deserialize(doc); } catch (Exception e) { throw OException.wrapException(new OCommandExecutionException(""), e); } return null; }
public static OStatement deserializeFromOResult(OResult doc) { try { OStatement result = (OStatement) Class.forName(doc.getProperty("__class")).getConstructor(Integer.class).newInstance(-1); result.deserialize(doc); } catch (Exception e) { throw OException.wrapException(new OCommandExecutionException(""), e); } return null; }
private SecretKey createKey(String base64EncodedKey) { if (base64EncodedKey == null) { throw new OSecurityException(format(MISSING_KEY_ERROR, OGlobalConfiguration.STORAGE_ENCRYPTION_KEY.getKey())); } try { final byte[] keyBytes = Base64.getDecoder().decode(base64EncodedKey.getBytes()); validateKeySize(keyBytes.length); return new SecretKeySpec(keyBytes, ALGORITHM_NAME); } catch (IllegalArgumentException e) { throw OException.wrapException(new OInvalidStorageEncryptionKeyException(INVALID_KEY_ERROR), e); } }
public void put(Object key, OIdentifiable value, Document doc) { if (deleted.remove(value.getIdentity().toString())) { doc.add(OLuceneIndexType.createField(TMP, value.getIdentity().toString(), Field.Store.YES)); updated.add(value.getIdentity().toString()); } try { writer.addDocument(doc); } catch (IOException e) { throw OException.wrapException(new OLuceneIndexException("unable to add document to changes index"), e); } }
@Override public void clear() { try { sbTree.clear(); } catch (IOException e) { throw OException.wrapException(new OIndexException("Error during clear index " + name), e); } }
@Override public void update(Object key, OIndexKeyUpdater<Object> updater) { try { sbTree.update(key, updater, null); } catch (IOException e) { throw OException.wrapException(new OIndexException("Error during update of key " + key + " in index " + name), e); } }
public void delete() { try { tree.delete(); } catch (IOException e) { throw OException.wrapException(new ODatabaseException("Error during deletion index container"), e); } }
@Override public void clear() { try { sbTree.clear(); } catch (IOException e) { throw OException.wrapException(new OIndexException("Error during clearing of index " + name), e); } }
private void doClearIndex(final int indexId) throws OInvalidIndexEngineIdException { try { checkIndexId(indexId); final OBaseIndexEngine engine = indexEngines.get(indexId); makeStorageDirty(); engine.clear(); } catch (final IOException e) { throw OException.wrapException(new OStorageException("Error during clearing of index"), e); } }
private boolean doRemoveRidIndexEntry(final int indexId, final Object key, final ORID value) throws OInvalidIndexEngineIdException { try { checkIndexId(indexId); final OBaseIndexEngine engine = indexEngines.get(indexId); makeStorageDirty(); return ((OMultiValueIndexEngine) engine).remove(key, value); } catch (final IOException e) { throw OException.wrapException(new OStorageException("Cannot put key " + key + " value " + value + " entry to the index"), e); } }
public Object createSingleValue(final Object... param) { try { return OType.convert(param[0], keyType.getDefaultJavaType()); } catch (Exception e) { OException ex = OException .wrapException(new OIndexException("Invalid key for index: " + param[0] + " cannot be converted to " + keyType), e); throw ex; } }
@Override public boolean remove(final Object key) { try { return getPartition(key).remove(key) != null; } catch (IOException e) { throw OException.wrapException(new OIndexException("Error during deletion of key " + key + " of index with name " + name), e); } }
public void deserialize(OResult fromResult) { left = new OExpression(-1); left.deserialize(fromResult.getProperty("left")); try { operator = (OBinaryCompareOperator) Class.forName(String.valueOf(fromResult.getProperty("operator"))).newInstance(); } catch (Exception e) { throw OException.wrapException(new OCommandExecutionException(""), e); } right = new OExpression(-1); right.deserialize(fromResult.getProperty("right")); }
protected Object executeSQL() { ODatabaseDocument db = ODatabaseRecordThreadLocal.instance().getIfDefined(); try { return executeSQLScript(parserText, db); } catch (IOException e) { throw OException.wrapException(new OCommandExecutionException("Error on executing command: " + parserText), 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); } }