From 64c6a01083e754b1461d40b88bf19f4e5b65593e Mon Sep 17 00:00:00 2001 From: Robert von Burg Date: Wed, 22 Apr 2015 12:06:20 +0200 Subject: [PATCH] [Minor] Added doc to Auditing*MapFacades and impl. query auditing --- .../agent/impl/AuditingAuditMapFacade.java | 50 +++++++++------- .../agent/impl/AuditingElementMapFacade.java | 59 ++++++++++--------- .../strolch/agent/impl/AuditingOrderMap.java | 43 +++++++------- .../agent/impl/AuditingResourceMap.java | 43 +++++++------- 4 files changed, 104 insertions(+), 91 deletions(-) diff --git a/li.strolch.agent/src/main/java/li/strolch/agent/impl/AuditingAuditMapFacade.java b/li.strolch.agent/src/main/java/li/strolch/agent/impl/AuditingAuditMapFacade.java index 62195c79d..fdc8effe3 100644 --- a/li.strolch.agent/src/main/java/li/strolch/agent/impl/AuditingAuditMapFacade.java +++ b/li.strolch.agent/src/main/java/li/strolch/agent/impl/AuditingAuditMapFacade.java @@ -1,23 +1,17 @@ /* - * Copyright (c) 2012, Robert von Burg - * - * All rights reserved. - * - * This file is part of the XXX. - * - * XXX is free software: you can redistribute - * 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, - * or (at your option) any later version. - * - * XXX is distributed in the hope that it will - * be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - * 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 - * . + * Copyright 2013 Robert von Burg + * + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. */ package li.strolch.agent.impl; @@ -37,6 +31,16 @@ import ch.eitchnet.utils.collections.DateRange; import ch.eitchnet.utils.dbc.DBC; /** + *

+ * This {@link AuditTrail} facade registers all actions performed i.e. it registers which {@link Audit Audits} are + * retrieved, created, updated and deleted. + *

+ * + *

+ * In a single transaction an Audit may be created, updated and then deleted - this implementation does not "squash" + * such actions, but registers them separately + *

+ * * @author Robert von Burg */ public class AuditingAuditMapFacade implements AuditTrail { @@ -201,14 +205,16 @@ public class AuditingAuditMapFacade implements AuditTrail { @Override public List doQuery(StrolchTransaction tx, AuditQuery query) { List elements = this.auditTrail.doQuery(tx, query, new NoStrategyAuditVisitor()); - // TODO decide how to audit these queried elements + this.read.addAll(elements); return elements; } @Override public List doQuery(StrolchTransaction tx, AuditQuery query, AuditVisitor auditVisitor) { - List elements = this.auditTrail.doQuery(tx, query, auditVisitor); - // TODO decide how to audit these queried elements + List elements = this.auditTrail.doQuery(tx, query, audit -> { + this.read.add(audit); + return auditVisitor.visitAudit(audit); + }); return elements; } } diff --git a/li.strolch.agent/src/main/java/li/strolch/agent/impl/AuditingElementMapFacade.java b/li.strolch.agent/src/main/java/li/strolch/agent/impl/AuditingElementMapFacade.java index f2dc0dbe8..cd42837fd 100644 --- a/li.strolch.agent/src/main/java/li/strolch/agent/impl/AuditingElementMapFacade.java +++ b/li.strolch.agent/src/main/java/li/strolch/agent/impl/AuditingElementMapFacade.java @@ -1,23 +1,17 @@ /* - * Copyright (c) 2012, Robert von Burg - * - * All rights reserved. - * - * This file is part of the XXX. - * - * XXX is free software: you can redistribute - * 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, - * or (at your option) any later version. - * - * XXX is distributed in the hope that it will - * be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - * 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 - * . + * Copyright 2013 Robert von Burg + * + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. */ package li.strolch.agent.impl; @@ -27,6 +21,7 @@ import java.util.List; import java.util.Map; import java.util.Set; +import li.strolch.agent.api.AuditTrail; import li.strolch.agent.api.ElementMap; import li.strolch.exception.StrolchException; import li.strolch.model.StrolchRootElement; @@ -36,20 +31,30 @@ import li.strolch.persistence.api.StrolchTransaction; import ch.eitchnet.utils.dbc.DBC; /** + *

+ * This {@link AuditTrail} facade registers all actions performed i.e. it registers which {@link StrolchRootElement + * StrolchRootElements} are retrieved, created, updated and deleted. + *

+ * + *

+ * In a single transaction an StrolchRootElement may be created, updated and then deleted - this implementation does not + * "squash" such actions, but registers them separately + *

+ * * @author Robert von Burg */ public class AuditingElementMapFacade implements ElementMap { - private ElementMap elementMap; + protected ElementMap elementMap; - private Set read; - private Set created; - private Set updated; - private Set deleted; - private long deletedAll; - private Map deletedAllByType; + protected Set read; + protected Set created; + protected Set updated; + protected Set deleted; + protected long deletedAll; + protected Map deletedAllByType; - private boolean observeAccessReads; + protected boolean observeAccessReads; public AuditingElementMapFacade(ElementMap elementMap, boolean observeAccessReads) { DBC.PRE.assertNotNull("ElementMap must be set!", elementMap); //$NON-NLS-1$ diff --git a/li.strolch.agent/src/main/java/li/strolch/agent/impl/AuditingOrderMap.java b/li.strolch.agent/src/main/java/li/strolch/agent/impl/AuditingOrderMap.java index d82665a8a..c3197f73e 100644 --- a/li.strolch.agent/src/main/java/li/strolch/agent/impl/AuditingOrderMap.java +++ b/li.strolch.agent/src/main/java/li/strolch/agent/impl/AuditingOrderMap.java @@ -1,28 +1,23 @@ /* - * Copyright (c) 2012, Robert von Burg - * - * All rights reserved. - * - * This file is part of the XXX. - * - * XXX is free software: you can redistribute - * 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, - * or (at your option) any later version. - * - * XXX is distributed in the hope that it will - * be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - * 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 - * . + * Copyright 2013 Robert von Burg + * + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. */ package li.strolch.agent.impl; import java.util.List; +import li.strolch.agent.api.AuditTrail; import li.strolch.agent.api.ElementMap; import li.strolch.agent.api.OrderMap; import li.strolch.model.Order; @@ -31,7 +26,11 @@ import li.strolch.model.query.OrderQuery; import li.strolch.persistence.api.StrolchTransaction; /** + * This is the {@link AuditTrail} for {@link Order Orders} + * * @author Robert von Burg + * + * @see AuditingElementMapFacade */ public class AuditingOrderMap extends AuditingElementMapFacade implements OrderMap { @@ -49,8 +48,10 @@ public class AuditingOrderMap extends AuditingElementMapFacade implements @Override public List doQuery(StrolchTransaction tx, OrderQuery query, OrderVisitor orderVisitor) { - List result = getElementMap().doQuery(tx, query, orderVisitor); - // TODO decide how to audit these queried elements + List result = getElementMap().doQuery(tx, query, order -> { + this.read.add(order); + return orderVisitor.visit(order); + }); return result; } } diff --git a/li.strolch.agent/src/main/java/li/strolch/agent/impl/AuditingResourceMap.java b/li.strolch.agent/src/main/java/li/strolch/agent/impl/AuditingResourceMap.java index 84bdc1aaa..c843c5985 100644 --- a/li.strolch.agent/src/main/java/li/strolch/agent/impl/AuditingResourceMap.java +++ b/li.strolch.agent/src/main/java/li/strolch/agent/impl/AuditingResourceMap.java @@ -1,28 +1,23 @@ /* - * Copyright (c) 2012, Robert von Burg - * - * All rights reserved. - * - * This file is part of the XXX. - * - * XXX is free software: you can redistribute - * 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, - * or (at your option) any later version. - * - * XXX is distributed in the hope that it will - * be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - * 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 - * . + * Copyright 2013 Robert von Burg + * + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. */ package li.strolch.agent.impl; import java.util.List; +import li.strolch.agent.api.AuditTrail; import li.strolch.agent.api.ElementMap; import li.strolch.agent.api.ResourceMap; import li.strolch.model.Resource; @@ -31,7 +26,11 @@ import li.strolch.model.query.ResourceQuery; import li.strolch.persistence.api.StrolchTransaction; /** + * This is the {@link AuditTrail} for {@link Resource Resources} + * * @author Robert von Burg + * + * @see AuditingElementMapFacade */ public class AuditingResourceMap extends AuditingElementMapFacade implements ResourceMap { @@ -49,8 +48,10 @@ public class AuditingResourceMap extends AuditingElementMapFacade impl @Override public List doQuery(StrolchTransaction tx, ResourceQuery query, ResourceVisitor resourceVisitor) { - List result = getElementMap().doQuery(tx, query, resourceVisitor); - // TODO decide how to audit these queried elements + List result = getElementMap().doQuery(tx, query, resource -> { + this.read.add(resource); + return resourceVisitor.visit(resource); + }); return result; } }