@Override public boolean execute(final OHttpRequest iRequest, OHttpResponse iResponse) throws Exception { final String[] urlParts = checkSyntax(iRequest.url, 3, "Syntax error: index/<database>/<index-name>/<key>/[<value>]"); iRequest.data.commandInfo = "Index remove"; ODatabaseDocumentTx db = null; try { db = getProfiledDatabaseInstance(iRequest); final OIndex<?> index = db.getMetadata().getIndexManager().getIndex(urlParts[2]); if (index == null) throw new IllegalArgumentException("Index name '" + urlParts[2] + "' not found"); final boolean found; if (urlParts.length > 4) found = index.remove(urlParts[3], new ORecordId(urlParts[3])); else found = index.remove(urlParts[3]); if (found) iResponse.send(OHttpUtils.STATUS_OK_CODE, "OK", OHttpUtils.CONTENT_TEXT_PLAIN, null, null); else iResponse.send( OHttpUtils.STATUS_NOTFOUND_CODE, OHttpUtils.STATUS_NOTFOUND_DESCRIPTION, OHttpUtils.CONTENT_TEXT_PLAIN, null, null); } finally { if (db != null) db.close(); } return false; }
public void addIndexEntry( final OIndex<?> delegate, final String iIndexName, final OPERATION iStatus, final Object iKey, final OIdentifiable iValue) { switch (iStatus) { case CLEAR: delegate.clear(); break; case PUT: delegate.put(iKey, iValue); break; case REMOVE: if (iKey == null) delegate.remove(iValue); else delegate.remove(iKey, iValue); break; } }
public boolean remove(final String iKey) { return index.remove(iKey); }