[Minor] Added doc to Auditing*MapFacades and impl. query auditing
This commit is contained in:
parent
47881df2ee
commit
64c6a01083
|
@ -1,23 +1,17 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2012, Robert von Burg
|
* Copyright 2013 Robert von Burg <eitch@eitchnet.ch>
|
||||||
*
|
*
|
||||||
* All rights reserved.
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
*
|
* you may not use this file except in compliance with the License.
|
||||||
* This file is part of the XXX.
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* XXX is free software: you can redistribute
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
* it and/or modify it under the terms of the GNU General Public License as
|
*
|
||||||
* published by the Free Software Foundation, either version 3 of the License,
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* or (at your option) any later version.
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
*
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* XXX is distributed in the hope that it will
|
* See the License for the specific language governing permissions and
|
||||||
* be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* limitations under the License.
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with XXX. If not, see
|
|
||||||
* <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
*/
|
||||||
package li.strolch.agent.impl;
|
package li.strolch.agent.impl;
|
||||||
|
|
||||||
|
@ -37,6 +31,16 @@ import ch.eitchnet.utils.collections.DateRange;
|
||||||
import ch.eitchnet.utils.dbc.DBC;
|
import ch.eitchnet.utils.dbc.DBC;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* <p>
|
||||||
|
* This {@link AuditTrail} facade registers all actions performed i.e. it registers which {@link Audit Audits} are
|
||||||
|
* retrieved, created, updated and deleted.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* In a single transaction an Audit may be created, updated and then deleted - this implementation does not "squash"
|
||||||
|
* such actions, but registers them separately
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
* @author Robert von Burg <eitch@eitchnet.ch>
|
* @author Robert von Burg <eitch@eitchnet.ch>
|
||||||
*/
|
*/
|
||||||
public class AuditingAuditMapFacade implements AuditTrail {
|
public class AuditingAuditMapFacade implements AuditTrail {
|
||||||
|
@ -201,14 +205,16 @@ public class AuditingAuditMapFacade implements AuditTrail {
|
||||||
@Override
|
@Override
|
||||||
public List<Audit> doQuery(StrolchTransaction tx, AuditQuery query) {
|
public List<Audit> doQuery(StrolchTransaction tx, AuditQuery query) {
|
||||||
List<Audit> elements = this.auditTrail.doQuery(tx, query, new NoStrategyAuditVisitor());
|
List<Audit> elements = this.auditTrail.doQuery(tx, query, new NoStrategyAuditVisitor());
|
||||||
// TODO decide how to audit these queried elements
|
this.read.addAll(elements);
|
||||||
return elements;
|
return elements;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <U> List<U> doQuery(StrolchTransaction tx, AuditQuery query, AuditVisitor<U> auditVisitor) {
|
public <U> List<U> doQuery(StrolchTransaction tx, AuditQuery query, AuditVisitor<U> auditVisitor) {
|
||||||
List<U> elements = this.auditTrail.doQuery(tx, query, auditVisitor);
|
List<U> elements = this.auditTrail.doQuery(tx, query, audit -> {
|
||||||
// TODO decide how to audit these queried elements
|
this.read.add(audit);
|
||||||
|
return auditVisitor.visitAudit(audit);
|
||||||
|
});
|
||||||
return elements;
|
return elements;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,23 +1,17 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2012, Robert von Burg
|
* Copyright 2013 Robert von Burg <eitch@eitchnet.ch>
|
||||||
*
|
*
|
||||||
* All rights reserved.
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
*
|
* you may not use this file except in compliance with the License.
|
||||||
* This file is part of the XXX.
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* XXX is free software: you can redistribute
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
* it and/or modify it under the terms of the GNU General Public License as
|
*
|
||||||
* published by the Free Software Foundation, either version 3 of the License,
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* or (at your option) any later version.
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
*
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* XXX is distributed in the hope that it will
|
* See the License for the specific language governing permissions and
|
||||||
* be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* limitations under the License.
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with XXX. If not, see
|
|
||||||
* <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
*/
|
||||||
package li.strolch.agent.impl;
|
package li.strolch.agent.impl;
|
||||||
|
|
||||||
|
@ -27,6 +21,7 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import li.strolch.agent.api.AuditTrail;
|
||||||
import li.strolch.agent.api.ElementMap;
|
import li.strolch.agent.api.ElementMap;
|
||||||
import li.strolch.exception.StrolchException;
|
import li.strolch.exception.StrolchException;
|
||||||
import li.strolch.model.StrolchRootElement;
|
import li.strolch.model.StrolchRootElement;
|
||||||
|
@ -36,20 +31,30 @@ import li.strolch.persistence.api.StrolchTransaction;
|
||||||
import ch.eitchnet.utils.dbc.DBC;
|
import ch.eitchnet.utils.dbc.DBC;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* <p>
|
||||||
|
* This {@link AuditTrail} facade registers all actions performed i.e. it registers which {@link StrolchRootElement
|
||||||
|
* StrolchRootElements} are retrieved, created, updated and deleted.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* In a single transaction an StrolchRootElement may be created, updated and then deleted - this implementation does not
|
||||||
|
* "squash" such actions, but registers them separately
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
* @author Robert von Burg <eitch@eitchnet.ch>
|
* @author Robert von Burg <eitch@eitchnet.ch>
|
||||||
*/
|
*/
|
||||||
public class AuditingElementMapFacade<T extends StrolchRootElement> implements ElementMap<T> {
|
public class AuditingElementMapFacade<T extends StrolchRootElement> implements ElementMap<T> {
|
||||||
|
|
||||||
private ElementMap<T> elementMap;
|
protected ElementMap<T> elementMap;
|
||||||
|
|
||||||
private Set<T> read;
|
protected Set<T> read;
|
||||||
private Set<T> created;
|
protected Set<T> created;
|
||||||
private Set<T> updated;
|
protected Set<T> updated;
|
||||||
private Set<T> deleted;
|
protected Set<T> deleted;
|
||||||
private long deletedAll;
|
protected long deletedAll;
|
||||||
private Map<String, Long> deletedAllByType;
|
protected Map<String, Long> deletedAllByType;
|
||||||
|
|
||||||
private boolean observeAccessReads;
|
protected boolean observeAccessReads;
|
||||||
|
|
||||||
public AuditingElementMapFacade(ElementMap<T> elementMap, boolean observeAccessReads) {
|
public AuditingElementMapFacade(ElementMap<T> elementMap, boolean observeAccessReads) {
|
||||||
DBC.PRE.assertNotNull("ElementMap must be set!", elementMap); //$NON-NLS-1$
|
DBC.PRE.assertNotNull("ElementMap must be set!", elementMap); //$NON-NLS-1$
|
||||||
|
|
|
@ -1,28 +1,23 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2012, Robert von Burg
|
* Copyright 2013 Robert von Burg <eitch@eitchnet.ch>
|
||||||
*
|
*
|
||||||
* All rights reserved.
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
*
|
* you may not use this file except in compliance with the License.
|
||||||
* This file is part of the XXX.
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* XXX is free software: you can redistribute
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
* it and/or modify it under the terms of the GNU General Public License as
|
*
|
||||||
* published by the Free Software Foundation, either version 3 of the License,
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* or (at your option) any later version.
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
*
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* XXX is distributed in the hope that it will
|
* See the License for the specific language governing permissions and
|
||||||
* be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* limitations under the License.
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with XXX. If not, see
|
|
||||||
* <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
*/
|
||||||
package li.strolch.agent.impl;
|
package li.strolch.agent.impl;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import li.strolch.agent.api.AuditTrail;
|
||||||
import li.strolch.agent.api.ElementMap;
|
import li.strolch.agent.api.ElementMap;
|
||||||
import li.strolch.agent.api.OrderMap;
|
import li.strolch.agent.api.OrderMap;
|
||||||
import li.strolch.model.Order;
|
import li.strolch.model.Order;
|
||||||
|
@ -31,7 +26,11 @@ import li.strolch.model.query.OrderQuery;
|
||||||
import li.strolch.persistence.api.StrolchTransaction;
|
import li.strolch.persistence.api.StrolchTransaction;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* This is the {@link AuditTrail} for {@link Order Orders}
|
||||||
|
*
|
||||||
* @author Robert von Burg <eitch@eitchnet.ch>
|
* @author Robert von Burg <eitch@eitchnet.ch>
|
||||||
|
*
|
||||||
|
* @see AuditingElementMapFacade
|
||||||
*/
|
*/
|
||||||
public class AuditingOrderMap extends AuditingElementMapFacade<Order> implements OrderMap {
|
public class AuditingOrderMap extends AuditingElementMapFacade<Order> implements OrderMap {
|
||||||
|
|
||||||
|
@ -49,8 +48,10 @@ public class AuditingOrderMap extends AuditingElementMapFacade<Order> implements
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <U> List<U> doQuery(StrolchTransaction tx, OrderQuery query, OrderVisitor<U> orderVisitor) {
|
public <U> List<U> doQuery(StrolchTransaction tx, OrderQuery query, OrderVisitor<U> orderVisitor) {
|
||||||
List<U> result = getElementMap().doQuery(tx, query, orderVisitor);
|
List<U> result = getElementMap().doQuery(tx, query, order -> {
|
||||||
// TODO decide how to audit these queried elements
|
this.read.add(order);
|
||||||
|
return orderVisitor.visit(order);
|
||||||
|
});
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,28 +1,23 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2012, Robert von Burg
|
* Copyright 2013 Robert von Burg <eitch@eitchnet.ch>
|
||||||
*
|
*
|
||||||
* All rights reserved.
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
*
|
* you may not use this file except in compliance with the License.
|
||||||
* This file is part of the XXX.
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* XXX is free software: you can redistribute
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
* it and/or modify it under the terms of the GNU General Public License as
|
*
|
||||||
* published by the Free Software Foundation, either version 3 of the License,
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* or (at your option) any later version.
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
*
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* XXX is distributed in the hope that it will
|
* See the License for the specific language governing permissions and
|
||||||
* be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* limitations under the License.
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with XXX. If not, see
|
|
||||||
* <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
*/
|
||||||
package li.strolch.agent.impl;
|
package li.strolch.agent.impl;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import li.strolch.agent.api.AuditTrail;
|
||||||
import li.strolch.agent.api.ElementMap;
|
import li.strolch.agent.api.ElementMap;
|
||||||
import li.strolch.agent.api.ResourceMap;
|
import li.strolch.agent.api.ResourceMap;
|
||||||
import li.strolch.model.Resource;
|
import li.strolch.model.Resource;
|
||||||
|
@ -31,7 +26,11 @@ import li.strolch.model.query.ResourceQuery;
|
||||||
import li.strolch.persistence.api.StrolchTransaction;
|
import li.strolch.persistence.api.StrolchTransaction;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* This is the {@link AuditTrail} for {@link Resource Resources}
|
||||||
|
*
|
||||||
* @author Robert von Burg <eitch@eitchnet.ch>
|
* @author Robert von Burg <eitch@eitchnet.ch>
|
||||||
|
*
|
||||||
|
* @see AuditingElementMapFacade
|
||||||
*/
|
*/
|
||||||
public class AuditingResourceMap extends AuditingElementMapFacade<Resource> implements ResourceMap {
|
public class AuditingResourceMap extends AuditingElementMapFacade<Resource> implements ResourceMap {
|
||||||
|
|
||||||
|
@ -49,8 +48,10 @@ public class AuditingResourceMap extends AuditingElementMapFacade<Resource> impl
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <U> List<U> doQuery(StrolchTransaction tx, ResourceQuery query, ResourceVisitor<U> resourceVisitor) {
|
public <U> List<U> doQuery(StrolchTransaction tx, ResourceQuery query, ResourceVisitor<U> resourceVisitor) {
|
||||||
List<U> result = getElementMap().doQuery(tx, query, resourceVisitor);
|
List<U> result = getElementMap().doQuery(tx, query, resource -> {
|
||||||
// TODO decide how to audit these queried elements
|
this.read.add(resource);
|
||||||
|
return resourceVisitor.visit(resource);
|
||||||
|
});
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue