[Minor] Added method context to opening of TX in Inspector and ModelQuery
This commit is contained in:
parent
30421d606e
commit
72fd541508
|
@ -1,12 +1,12 @@
|
|||
/*
|
||||
* Copyright 2015 Robert von Burg <eitch@eitchnet.ch>
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
@ -35,6 +35,11 @@ import li.strolch.rest.model.visitor.ToAuditQueryVisitor;
|
|||
@Path("strolch/audits")
|
||||
public class AuditsService {
|
||||
|
||||
private static String getContext() {
|
||||
StackTraceElement element = new Throwable().getStackTrace()[1];
|
||||
return element.getClassName() + "." + element.getMethodName();
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("types")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
|
@ -43,7 +48,7 @@ public class AuditsService {
|
|||
Certificate cert = (Certificate) request.getAttribute(StrolchRestfulConstants.STROLCH_CERTIFICATE);
|
||||
StrolchRealm realm = RestfulStrolchComponent.getInstance().getContainer().getRealm(cert);
|
||||
|
||||
try (StrolchTransaction tx = realm.openTx(cert, AuditsService.class)) {
|
||||
try (StrolchTransaction tx = realm.openTx(cert, getContext())) {
|
||||
JsonArray dataJ = new JsonArray();
|
||||
tx.getAuditTrail().getTypes(tx).forEach(dataJ::add);
|
||||
return Response.ok(dataJ.toString(), MediaType.APPLICATION_JSON).build();
|
||||
|
@ -58,7 +63,7 @@ public class AuditsService {
|
|||
Certificate cert = (Certificate) request.getAttribute(StrolchRestfulConstants.STROLCH_CERTIFICATE);
|
||||
StrolchRealm realm = RestfulStrolchComponent.getInstance().getContainer().getRealm(cert);
|
||||
|
||||
try (StrolchTransaction tx = realm.openTx(cert, AuditsService.class)) {
|
||||
try (StrolchTransaction tx = realm.openTx(cert, getContext())) {
|
||||
|
||||
li.strolch.model.query.AuditQuery<Audit> auditQuery = new ToAuditQueryVisitor().create(query);
|
||||
JsonArray dataJ = new JsonArray();
|
||||
|
|
|
@ -86,9 +86,14 @@ public class Inspector {
|
|||
|
||||
private static final Logger logger = LoggerFactory.getLogger(Inspector.class);
|
||||
|
||||
private static String getContext() {
|
||||
StackTraceElement element = new Throwable().getStackTrace()[2];
|
||||
return element.getClassName() + "." + element.getMethodName();
|
||||
}
|
||||
|
||||
private StrolchTransaction openTx(Certificate certificate, String realm) {
|
||||
return RestfulStrolchComponent.getInstance().getContainer().getRealm(realm)
|
||||
.openTx(certificate, Inspector.class);
|
||||
.openTx(certificate, getContext());
|
||||
}
|
||||
|
||||
private String toString(JsonElement jsonElement) {
|
||||
|
|
|
@ -22,6 +22,15 @@ import li.strolch.soql.core.QueryResponse;
|
|||
@Path("strolch/model")
|
||||
public class ModelQuery {
|
||||
|
||||
private static String getContext() {
|
||||
StackTraceElement element = new Throwable().getStackTrace()[2];
|
||||
return element.getClassName() + "." + element.getMethodName();
|
||||
}
|
||||
|
||||
private StrolchTransaction openTx(Certificate certificate, String realm) {
|
||||
return RestfulStrolchComponent.getInstance().getContainer().getRealm(realm).openTx(certificate, getContext());
|
||||
}
|
||||
|
||||
@POST
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Path("soql")
|
||||
|
@ -42,8 +51,4 @@ public class ModelQuery {
|
|||
.build();
|
||||
}
|
||||
|
||||
private StrolchTransaction openTx(Certificate certificate, String realm) {
|
||||
return RestfulStrolchComponent.getInstance().getContainer().getRealm(realm)
|
||||
.openTx(certificate, ModelQuery.class);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue