forked from lbovet/vertx-redisques
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #142 from hiddenalpha/SDCISA-10974-DiscloseErrorsI…
…nHandlers
- Loading branch information
Showing
14 changed files
with
286 additions
and
174 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 38 additions & 31 deletions
69
src/main/java/org/swisspush/redisques/handler/DeleteLockHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,38 @@ | ||
package org.swisspush.redisques.handler; | ||
|
||
import io.vertx.core.AsyncResult; | ||
import io.vertx.core.Handler; | ||
import io.vertx.core.eventbus.Message; | ||
import io.vertx.core.json.JsonObject; | ||
import io.vertx.redis.client.Response; | ||
|
||
import static org.swisspush.redisques.util.RedisquesAPI.*; | ||
|
||
/** | ||
* Class DeleteLockHandler. | ||
* | ||
* @author baldim | ||
*/ | ||
public class DeleteLockHandler implements Handler<AsyncResult<Response>> { | ||
private final Message<JsonObject> event; | ||
|
||
public DeleteLockHandler(Message<JsonObject> event) { | ||
this.event = event; | ||
} | ||
|
||
@Override | ||
public void handle(AsyncResult<Response> reply) { | ||
if (reply.succeeded()) { | ||
event.reply(new JsonObject().put(STATUS, OK)); | ||
} else { | ||
event.reply(new JsonObject().put(STATUS, ERROR)); | ||
} | ||
} | ||
} | ||
package org.swisspush.redisques.handler; | ||
|
||
import io.vertx.core.AsyncResult; | ||
import io.vertx.core.Handler; | ||
import io.vertx.core.eventbus.Message; | ||
import io.vertx.core.json.JsonObject; | ||
import io.vertx.redis.client.Response; | ||
import org.slf4j.Logger; | ||
|
||
import static org.slf4j.LoggerFactory.getLogger; | ||
import static org.swisspush.redisques.util.RedisquesAPI.ERROR; | ||
import static org.swisspush.redisques.util.RedisquesAPI.OK; | ||
import static org.swisspush.redisques.util.RedisquesAPI.STATUS; | ||
|
||
/** | ||
* Class DeleteLockHandler. | ||
* | ||
* @author baldim | ||
*/ | ||
public class DeleteLockHandler implements Handler<AsyncResult<Response>> { | ||
|
||
private static final Logger log = getLogger(DeleteLockHandler.class); | ||
private final Message<JsonObject> event; | ||
|
||
public DeleteLockHandler(Message<JsonObject> event) { | ||
this.event = event; | ||
} | ||
|
||
@Override | ||
public void handle(AsyncResult<Response> reply) { | ||
if (reply.succeeded()) { | ||
event.reply(new JsonObject().put(STATUS, OK)); | ||
} else { | ||
log.warn("Concealed error", new Exception(reply.cause())); | ||
event.reply(new JsonObject().put(STATUS, ERROR)); | ||
} | ||
} | ||
} |
94 changes: 51 additions & 43 deletions
94
src/main/java/org/swisspush/redisques/handler/GetAllLocksHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,52 @@ | ||
package org.swisspush.redisques.handler; | ||
|
||
import io.vertx.core.AsyncResult; | ||
import io.vertx.core.Handler; | ||
import io.vertx.core.eventbus.Message; | ||
import io.vertx.core.json.JsonArray; | ||
import io.vertx.core.json.JsonObject; | ||
import io.vertx.redis.client.Response; | ||
import org.swisspush.redisques.util.HandlerUtil; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
import java.util.regex.Pattern; | ||
|
||
import static org.swisspush.redisques.util.RedisquesAPI.*; | ||
|
||
/** | ||
* Class GetAllLocksHandler. | ||
* | ||
* @author baldim | ||
*/ | ||
public class GetAllLocksHandler implements Handler<AsyncResult<Response>> { | ||
|
||
private final Message<JsonObject> event; | ||
private final Optional<Pattern> filterPattern; | ||
|
||
public GetAllLocksHandler(Message<JsonObject> event, Optional<Pattern> filterPattern) { | ||
this.event = event; | ||
this.filterPattern = filterPattern; | ||
} | ||
|
||
@Override | ||
public void handle(AsyncResult<Response> reply) { | ||
if (reply.succeeded() && reply.result() != null) { | ||
JsonObject result = new JsonObject(); | ||
Response locks = reply.result(); | ||
List<String> filteredLocks = HandlerUtil.filterByPattern(locks, filterPattern); | ||
result.put("locks", new JsonArray(filteredLocks)); | ||
event.reply(new JsonObject().put(STATUS, OK).put(VALUE, result)); | ||
} else { | ||
event.reply(new JsonObject().put(STATUS, ERROR)); | ||
} | ||
} | ||
package org.swisspush.redisques.handler; | ||
|
||
import io.vertx.core.AsyncResult; | ||
import io.vertx.core.Handler; | ||
import io.vertx.core.eventbus.Message; | ||
import io.vertx.core.json.JsonArray; | ||
import io.vertx.core.json.JsonObject; | ||
import io.vertx.redis.client.Response; | ||
import org.slf4j.Logger; | ||
import org.swisspush.redisques.util.HandlerUtil; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
import java.util.regex.Pattern; | ||
|
||
import static org.slf4j.LoggerFactory.getLogger; | ||
import static org.swisspush.redisques.util.RedisquesAPI.ERROR; | ||
import static org.swisspush.redisques.util.RedisquesAPI.OK; | ||
import static org.swisspush.redisques.util.RedisquesAPI.STATUS; | ||
import static org.swisspush.redisques.util.RedisquesAPI.VALUE; | ||
|
||
/** | ||
* Class GetAllLocksHandler. | ||
* | ||
* @author baldim | ||
*/ | ||
public class GetAllLocksHandler implements Handler<AsyncResult<Response>> { | ||
|
||
private static final Logger log = getLogger(GetAllLocksHandler.class); | ||
private final Message<JsonObject> event; | ||
private final Optional<Pattern> filterPattern; | ||
|
||
public GetAllLocksHandler(Message<JsonObject> event, Optional<Pattern> filterPattern) { | ||
this.event = event; | ||
this.filterPattern = filterPattern; | ||
} | ||
|
||
@Override | ||
public void handle(AsyncResult<Response> reply) { | ||
if (reply.succeeded() && reply.result() != null) { | ||
JsonObject result = new JsonObject(); | ||
Response locks = reply.result(); | ||
List<String> filteredLocks = HandlerUtil.filterByPattern(locks, filterPattern); | ||
result.put("locks", new JsonArray(filteredLocks)); | ||
event.reply(new JsonObject().put(STATUS, OK).put(VALUE, result)); | ||
} else { | ||
if( reply.failed() ) log.warn("Concealed error", new Exception(reply.cause())); | ||
event.reply(new JsonObject().put(STATUS, ERROR)); | ||
} | ||
} | ||
|
||
} |
80 changes: 45 additions & 35 deletions
80
src/main/java/org/swisspush/redisques/handler/GetLockHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,45 @@ | ||
package org.swisspush.redisques.handler; | ||
|
||
import io.vertx.core.AsyncResult; | ||
import io.vertx.core.Handler; | ||
import io.vertx.core.eventbus.Message; | ||
import io.vertx.core.json.JsonObject; | ||
import io.vertx.redis.client.Response; | ||
|
||
import static org.swisspush.redisques.util.RedisquesAPI.*; | ||
|
||
/** | ||
* Class GetLockHandler. | ||
* | ||
* @author baldim | ||
*/ | ||
public class GetLockHandler implements Handler<AsyncResult<Response>> { | ||
private final Message<JsonObject> event; | ||
|
||
public GetLockHandler(Message<JsonObject> event) { | ||
this.event = event; | ||
} | ||
|
||
@Override | ||
public void handle(AsyncResult<Response> reply) { | ||
if (reply.succeeded()) { | ||
if (reply.result() != null) { | ||
event.reply(new JsonObject().put(STATUS, OK).put(VALUE, reply.result().toString())); | ||
} else { | ||
event.reply(new JsonObject().put(STATUS, NO_SUCH_LOCK)); | ||
} | ||
} else { | ||
event.reply(new JsonObject().put(STATUS, ERROR)); | ||
} | ||
} | ||
} | ||
package org.swisspush.redisques.handler; | ||
|
||
import io.vertx.core.AsyncResult; | ||
import io.vertx.core.Handler; | ||
import io.vertx.core.eventbus.Message; | ||
import io.vertx.core.json.JsonObject; | ||
import io.vertx.redis.client.Response; | ||
import org.slf4j.Logger; | ||
|
||
import static org.slf4j.LoggerFactory.getLogger; | ||
import static org.swisspush.redisques.util.RedisquesAPI.ERROR; | ||
import static org.swisspush.redisques.util.RedisquesAPI.NO_SUCH_LOCK; | ||
import static org.swisspush.redisques.util.RedisquesAPI.OK; | ||
import static org.swisspush.redisques.util.RedisquesAPI.STATUS; | ||
import static org.swisspush.redisques.util.RedisquesAPI.VALUE; | ||
|
||
/** | ||
* Class GetLockHandler. | ||
* | ||
* @author baldim | ||
*/ | ||
public class GetLockHandler implements Handler<AsyncResult<Response>> { | ||
|
||
private static final Logger log = getLogger(GetLockHandler.class); | ||
private final Message<JsonObject> event; | ||
|
||
public GetLockHandler(Message<JsonObject> event) { | ||
this.event = event; | ||
} | ||
|
||
@Override | ||
public void handle(AsyncResult<Response> reply) { | ||
if (reply.succeeded()) { | ||
if (reply.result() != null) { | ||
event.reply(new JsonObject().put(STATUS, OK).put(VALUE, reply.result().toString())); | ||
} else { | ||
event.reply(new JsonObject().put(STATUS, NO_SUCH_LOCK)); | ||
} | ||
} else { | ||
log.warn("Concealed error", new Exception(reply.cause())); | ||
event.reply(new JsonObject().put(STATUS, ERROR)); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.