+ *
+ * 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;
}
}