diff --git a/ch.eitchnet.privilege b/ch.eitchnet.privilege index 4c6434f47..0c7315b71 160000 --- a/ch.eitchnet.privilege +++ b/ch.eitchnet.privilege @@ -1 +1 @@ -Subproject commit 4c6434f475dc40e73b54890540eaf943f21e1084 +Subproject commit 0c7315b713edb81442208c2b347c6432a3b6bc70 diff --git a/li.strolch.agent/src/main/java/li/strolch/agent/impl/StartRealms.java b/li.strolch.agent/src/main/java/li/strolch/agent/impl/StartRealms.java index aa2395de9..513fe7d2b 100644 --- a/li.strolch.agent/src/main/java/li/strolch/agent/impl/StartRealms.java +++ b/li.strolch.agent/src/main/java/li/strolch/agent/impl/StartRealms.java @@ -21,7 +21,7 @@ import ch.eitchnet.privilege.model.PrivilegeContext; /** * @author Robert von Burg */ -public class StartRealms implements SystemUserAction { +public class StartRealms extends SystemUserAction { private final DefaultRealmHandler defaultRealmHandler; diff --git a/li.strolch.agent/src/main/java/li/strolch/service/api/ServiceResult.java b/li.strolch.agent/src/main/java/li/strolch/service/api/ServiceResult.java index d1d5430e9..fc58fcff5 100644 --- a/li.strolch.agent/src/main/java/li/strolch/service/api/ServiceResult.java +++ b/li.strolch.agent/src/main/java/li/strolch/service/api/ServiceResult.java @@ -101,6 +101,27 @@ public class ServiceResult implements Serializable { this.message = message; } + public String getRootMessage() { + Throwable t = getRootCause(); + if (t == null) + return null; + return t.getMessage() == null ? t.getClass().getName() : (t.getClass().getName() + ": " + t.getMessage()); + } + + /** + * @return the root cause of the encapsulated {@link Throwable} or null if no {@link Throwable} is set + */ + public Throwable getRootCause() { + if (this.throwable == null) + return null; + Throwable t = this.throwable; + while (t.getCause() != null) { + t = t.getCause(); + } + + return t; + } + /** * @return the throwable */ diff --git a/li.strolch.agent/src/test/resources/cachedtest/config/PrivilegeModel.xml b/li.strolch.agent/src/test/resources/cachedtest/config/PrivilegeModel.xml index e332cb1bc..7752f1a92 100644 --- a/li.strolch.agent/src/test/resources/cachedtest/config/PrivilegeModel.xml +++ b/li.strolch.agent/src/test/resources/cachedtest/config/PrivilegeModel.xml @@ -21,8 +21,8 @@ - - true + + li.strolch.agent.impl.StartRealms diff --git a/li.strolch.agent/src/test/resources/emptytest/config/PrivilegeModel.xml b/li.strolch.agent/src/test/resources/emptytest/config/PrivilegeModel.xml index d2a6ec7f5..6c11b8ef2 100644 --- a/li.strolch.agent/src/test/resources/emptytest/config/PrivilegeModel.xml +++ b/li.strolch.agent/src/test/resources/emptytest/config/PrivilegeModel.xml @@ -21,8 +21,8 @@ - - true + + li.strolch.agent.impl.StartRealms diff --git a/li.strolch.agent/src/test/resources/minimaltest/config/PrivilegeModel.xml b/li.strolch.agent/src/test/resources/minimaltest/config/PrivilegeModel.xml index e67cc8b8c..a3f08bd05 100644 --- a/li.strolch.agent/src/test/resources/minimaltest/config/PrivilegeModel.xml +++ b/li.strolch.agent/src/test/resources/minimaltest/config/PrivilegeModel.xml @@ -21,8 +21,8 @@ - - true + + li.strolch.agent.impl.StartRealms diff --git a/li.strolch.agent/src/test/resources/realmtest/config/PrivilegeModel.xml b/li.strolch.agent/src/test/resources/realmtest/config/PrivilegeModel.xml index d2a6ec7f5..6c11b8ef2 100644 --- a/li.strolch.agent/src/test/resources/realmtest/config/PrivilegeModel.xml +++ b/li.strolch.agent/src/test/resources/realmtest/config/PrivilegeModel.xml @@ -21,8 +21,8 @@ - - true + + li.strolch.agent.impl.StartRealms diff --git a/li.strolch.agent/src/test/resources/transactionaltest/config/PrivilegeModel.xml b/li.strolch.agent/src/test/resources/transactionaltest/config/PrivilegeModel.xml index d2a6ec7f5..6c11b8ef2 100644 --- a/li.strolch.agent/src/test/resources/transactionaltest/config/PrivilegeModel.xml +++ b/li.strolch.agent/src/test/resources/transactionaltest/config/PrivilegeModel.xml @@ -21,8 +21,8 @@ - - true + + li.strolch.agent.impl.StartRealms diff --git a/li.strolch.agent/src/test/resources/transienttest/config/PrivilegeModel.xml b/li.strolch.agent/src/test/resources/transienttest/config/PrivilegeModel.xml index f6e73eeab..e3a3f0937 100644 --- a/li.strolch.agent/src/test/resources/transienttest/config/PrivilegeModel.xml +++ b/li.strolch.agent/src/test/resources/transienttest/config/PrivilegeModel.xml @@ -23,8 +23,8 @@ - - true + + li.strolch.agent.impl.StartRealms diff --git a/li.strolch.model/src/main/java/li/strolch/exception/StrolchException.java b/li.strolch.model/src/main/java/li/strolch/exception/StrolchException.java index 67c43b706..d42df6709 100644 --- a/li.strolch.model/src/main/java/li/strolch/exception/StrolchException.java +++ b/li.strolch.model/src/main/java/li/strolch/exception/StrolchException.java @@ -17,7 +17,6 @@ package li.strolch.exception; /** * @author Robert von Burg - * */ public class StrolchException extends RuntimeException { diff --git a/li.strolch.model/src/main/java/li/strolch/exception/StrolchModelException.java b/li.strolch.model/src/main/java/li/strolch/exception/StrolchModelException.java new file mode 100644 index 000000000..4e581cd93 --- /dev/null +++ b/li.strolch.model/src/main/java/li/strolch/exception/StrolchModelException.java @@ -0,0 +1,39 @@ +/* + * Copyright 2015 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.exception; + +/** + * @author Robert von Burg + */ +public class StrolchModelException extends StrolchException { + + private static final long serialVersionUID = 1L; + + /** + * @param message + * @param cause + */ + public StrolchModelException(String message, Throwable cause) { + super(message, cause); + } + + /** + * @param message + */ + public StrolchModelException(String message) { + super(message); + } +} diff --git a/li.strolch.model/src/main/java/li/strolch/model/GroupedParameterizedElement.java b/li.strolch.model/src/main/java/li/strolch/model/GroupedParameterizedElement.java index 44a70636b..cbb073571 100644 --- a/li.strolch.model/src/main/java/li/strolch/model/GroupedParameterizedElement.java +++ b/li.strolch.model/src/main/java/li/strolch/model/GroupedParameterizedElement.java @@ -23,6 +23,7 @@ import java.util.Map; import java.util.Set; import li.strolch.exception.StrolchException; +import li.strolch.exception.StrolchModelException; import li.strolch.model.parameter.Parameter; import org.w3c.dom.Element; @@ -92,15 +93,49 @@ public abstract class GroupedParameterizedElement extends AbstractStrolchElement * @return the found {@link Parameter} or null if it was not found */ public T getParameter(String bagKey, String paramKey) { + return getParameter(bagKey, paramKey, false); + } + + /** + * Returns the {@link Parameter} with the given key from the {@link ParameterBag} with the given bagKey, or null if + * the {@link Parameter} or the {@link ParameterBag} does not exist + * + * @param bagKey + * the key of the {@link ParameterBag} from which the {@link Parameter} is to be returned + * @param paramKey + * the key of the {@link Parameter} which is to be returned + * @param assertExists + * if set to true, and the parameter does not exist, a {@link StrolchModelException} is thrown + * + * @return the found {@link Parameter} or null if it was not found + */ + public T getParameter(String bagKey, String paramKey, boolean assertExists) { if (this.parameterBagMap == null) { + if (assertExists) { + String msg = "The Parameter {0} does not exist"; + throw new StrolchModelException(MessageFormat.format(msg, + getLocator().append(Tags.BAG, bagKey, paramKey))); + } + return null; } ParameterBag bag = this.parameterBagMap.get(bagKey); if (bag == null) { + if (assertExists) { + String msg = "The Parameter {0} does not exist"; + throw new StrolchModelException(MessageFormat.format(msg, + getLocator().append(Tags.BAG, bagKey, paramKey))); + } + return null; } - return bag.getParameter(paramKey); + T parameter = bag.getParameter(paramKey); + if (assertExists && parameter == null) { + String msg = "The Parameter {0} does not exist"; + throw new StrolchModelException(MessageFormat.format(msg, getLocator().append(Tags.BAG, bagKey, paramKey))); + } + return parameter; } /** diff --git a/li.strolch.model/src/main/java/li/strolch/model/Locator.java b/li.strolch.model/src/main/java/li/strolch/model/Locator.java index d57c98d91..80a05b743 100644 --- a/li.strolch.model/src/main/java/li/strolch/model/Locator.java +++ b/li.strolch.model/src/main/java/li/strolch/model/Locator.java @@ -155,6 +155,18 @@ public class Locator { public Locator append(List subPathElements) { return new Locator(this.pathElements, subPathElements); } + + /** + * Returns a new {@link Locator} where the given sub path is appended to the locator + * + * @param subPathElements + * the sub path to append + * + * @return the new locator + */ + public Locator append(String... subPathElements) { + return new Locator(this.pathElements, Arrays.asList(subPathElements)); + } /** * Returns a new {@link Locator} where the given element is appended to the locator diff --git a/li.strolch.performancetest/src/runtime/config/PrivilegeModel.xml b/li.strolch.performancetest/src/runtime/config/PrivilegeModel.xml index e332cb1bc..7752f1a92 100644 --- a/li.strolch.performancetest/src/runtime/config/PrivilegeModel.xml +++ b/li.strolch.performancetest/src/runtime/config/PrivilegeModel.xml @@ -21,8 +21,8 @@ - - true + + li.strolch.agent.impl.StartRealms diff --git a/li.strolch.persistence.postgresql/src/main/java/li/strolch/persistence/postgresql/PostgreSqlInitializer.java b/li.strolch.persistence.postgresql/src/main/java/li/strolch/persistence/postgresql/PostgreSqlInitializer.java index 4d1af9612..8b351e95f 100644 --- a/li.strolch.persistence.postgresql/src/main/java/li/strolch/persistence/postgresql/PostgreSqlInitializer.java +++ b/li.strolch.persistence.postgresql/src/main/java/li/strolch/persistence/postgresql/PostgreSqlInitializer.java @@ -41,7 +41,7 @@ import ch.eitchnet.privilege.model.Certificate; /** * @author Robert von Burg */ -public abstract class PostgreSqlInitializer implements SystemUserAction { +public abstract class PostgreSqlInitializer extends SystemUserAction { protected static final Logger logger = LoggerFactory.getLogger(PostgreSqlInitializer.class); protected StrolchAgent agent; diff --git a/li.strolch.persistence.postgresql/src/test/resources/cachedruntime/config/PrivilegeModel.xml b/li.strolch.persistence.postgresql/src/test/resources/cachedruntime/config/PrivilegeModel.xml index e332cb1bc..7752f1a92 100644 --- a/li.strolch.persistence.postgresql/src/test/resources/cachedruntime/config/PrivilegeModel.xml +++ b/li.strolch.persistence.postgresql/src/test/resources/cachedruntime/config/PrivilegeModel.xml @@ -21,8 +21,8 @@ - - true + + li.strolch.agent.impl.StartRealms diff --git a/li.strolch.persistence.postgresql/src/test/resources/realmtest/config/PrivilegeModel.xml b/li.strolch.persistence.postgresql/src/test/resources/realmtest/config/PrivilegeModel.xml index e332cb1bc..7752f1a92 100644 --- a/li.strolch.persistence.postgresql/src/test/resources/realmtest/config/PrivilegeModel.xml +++ b/li.strolch.persistence.postgresql/src/test/resources/realmtest/config/PrivilegeModel.xml @@ -21,8 +21,8 @@ - - true + + li.strolch.agent.impl.StartRealms diff --git a/li.strolch.persistence.postgresql/src/test/resources/transactionalruntime/config/PrivilegeModel.xml b/li.strolch.persistence.postgresql/src/test/resources/transactionalruntime/config/PrivilegeModel.xml index e332cb1bc..7752f1a92 100644 --- a/li.strolch.persistence.postgresql/src/test/resources/transactionalruntime/config/PrivilegeModel.xml +++ b/li.strolch.persistence.postgresql/src/test/resources/transactionalruntime/config/PrivilegeModel.xml @@ -21,8 +21,8 @@ - - true + + li.strolch.agent.impl.StartRealms diff --git a/li.strolch.persistence.xml/src/test/resources/cachedruntime/config/PrivilegeModel.xml b/li.strolch.persistence.xml/src/test/resources/cachedruntime/config/PrivilegeModel.xml index e332cb1bc..7752f1a92 100644 --- a/li.strolch.persistence.xml/src/test/resources/cachedruntime/config/PrivilegeModel.xml +++ b/li.strolch.persistence.xml/src/test/resources/cachedruntime/config/PrivilegeModel.xml @@ -21,8 +21,8 @@ - - true + + li.strolch.agent.impl.StartRealms diff --git a/li.strolch.persistence.xml/src/test/resources/existingDbRuntime/config/PrivilegeModel.xml b/li.strolch.persistence.xml/src/test/resources/existingDbRuntime/config/PrivilegeModel.xml index e332cb1bc..360b9f57c 100644 --- a/li.strolch.persistence.xml/src/test/resources/existingDbRuntime/config/PrivilegeModel.xml +++ b/li.strolch.persistence.xml/src/test/resources/existingDbRuntime/config/PrivilegeModel.xml @@ -20,11 +20,13 @@ + - - true + + li.strolch.agent.impl.StartRealms + true @@ -33,5 +35,6 @@ true + \ No newline at end of file diff --git a/li.strolch.persistence.xml/src/test/resources/transactionalruntime/config/PrivilegeModel.xml b/li.strolch.persistence.xml/src/test/resources/transactionalruntime/config/PrivilegeModel.xml index e332cb1bc..191ce609d 100644 --- a/li.strolch.persistence.xml/src/test/resources/transactionalruntime/config/PrivilegeModel.xml +++ b/li.strolch.persistence.xml/src/test/resources/transactionalruntime/config/PrivilegeModel.xml @@ -21,10 +21,11 @@ - - true + + li.strolch.agent.impl.StartRealms + true @@ -33,5 +34,6 @@ true + \ No newline at end of file diff --git a/li.strolch.rest/src/test/resources/withPrivilegeRuntime/config/PrivilegeModel.xml b/li.strolch.rest/src/test/resources/withPrivilegeRuntime/config/PrivilegeModel.xml index c1f488346..d0c963b04 100644 --- a/li.strolch.rest/src/test/resources/withPrivilegeRuntime/config/PrivilegeModel.xml +++ b/li.strolch.rest/src/test/resources/withPrivilegeRuntime/config/PrivilegeModel.xml @@ -57,8 +57,8 @@ - - true + + li.strolch.agent.impl.StartRealms @@ -71,8 +71,7 @@ - - + diff --git a/li.strolch.service/src/main/java/li/strolch/migrations/QueryCurrentVersionsAction.java b/li.strolch.service/src/main/java/li/strolch/migrations/QueryCurrentVersionsAction.java index fb158a19f..af12fdc03 100644 --- a/li.strolch.service/src/main/java/li/strolch/migrations/QueryCurrentVersionsAction.java +++ b/li.strolch.service/src/main/java/li/strolch/migrations/QueryCurrentVersionsAction.java @@ -21,7 +21,7 @@ import ch.eitchnet.privilege.model.PrivilegeContext; /** * @author Robert von Burg */ -public class QueryCurrentVersionsAction implements SystemUserAction { +public class QueryCurrentVersionsAction extends SystemUserAction { private CurrentMigrationVersionQuery query; diff --git a/li.strolch.service/src/main/java/li/strolch/migrations/RunMigrationsAction.java b/li.strolch.service/src/main/java/li/strolch/migrations/RunMigrationsAction.java index 19e539fcc..911bb45f1 100644 --- a/li.strolch.service/src/main/java/li/strolch/migrations/RunMigrationsAction.java +++ b/li.strolch.service/src/main/java/li/strolch/migrations/RunMigrationsAction.java @@ -24,7 +24,7 @@ import ch.eitchnet.utils.Version; /** * @author Robert von Burg */ -public class RunMigrationsAction implements SystemUserAction { +public class RunMigrationsAction extends SystemUserAction { private Migrations migrations; private Map currentVersions; diff --git a/li.strolch.service/src/test/resources/migrationstest/config/PrivilegeModel.xml b/li.strolch.service/src/test/resources/migrationstest/config/PrivilegeModel.xml index 7e355c30f..a25bd338f 100644 --- a/li.strolch.service/src/test/resources/migrationstest/config/PrivilegeModel.xml +++ b/li.strolch.service/src/test/resources/migrationstest/config/PrivilegeModel.xml @@ -20,17 +20,15 @@ + - - true - - - true - - - true + + li.strolch.agent.impl.StartRealms + li.strolch.migrations.QueryCurrentVersionsAction + li.strolch.migrations.RunMigrationsAction + true diff --git a/li.strolch.service/src/test/resources/svctest/config/PrivilegeModel.xml b/li.strolch.service/src/test/resources/svctest/config/PrivilegeModel.xml index e332cb1bc..517383d51 100644 --- a/li.strolch.service/src/test/resources/svctest/config/PrivilegeModel.xml +++ b/li.strolch.service/src/test/resources/svctest/config/PrivilegeModel.xml @@ -20,11 +20,13 @@ + - - true + + li.strolch.agent.impl.StartRealms + true diff --git a/li.strolch.service/src/test/resources/transienttest/config/PrivilegeModel.xml b/li.strolch.service/src/test/resources/transienttest/config/PrivilegeModel.xml index e67cc8b8c..d2b8e9c7b 100644 --- a/li.strolch.service/src/test/resources/transienttest/config/PrivilegeModel.xml +++ b/li.strolch.service/src/test/resources/transienttest/config/PrivilegeModel.xml @@ -20,11 +20,13 @@ + - - true + + li.strolch.agent.impl.StartRealms + true diff --git a/li.strolch.service/src/test/resources/withPrivilegeRuntime/config/PrivilegeModel.xml b/li.strolch.service/src/test/resources/withPrivilegeRuntime/config/PrivilegeModel.xml index db193c4f2..1832f677b 100644 --- a/li.strolch.service/src/test/resources/withPrivilegeRuntime/config/PrivilegeModel.xml +++ b/li.strolch.service/src/test/resources/withPrivilegeRuntime/config/PrivilegeModel.xml @@ -59,10 +59,14 @@ - + + li.strolch.agent.impl.StartRealms + + true + true @@ -71,8 +75,9 @@ true - - + + + li.strolch.service.test.model.GreetingService diff --git a/li.strolch.tutorialapp/src/runtime/config/PrivilegeModel.xml b/li.strolch.tutorialapp/src/runtime/config/PrivilegeModel.xml index 8900c354b..319fc14d4 100644 --- a/li.strolch.tutorialapp/src/runtime/config/PrivilegeModel.xml +++ b/li.strolch.tutorialapp/src/runtime/config/PrivilegeModel.xml @@ -58,8 +58,8 @@ - - true + + li.strolch.agent.impl.StartRealms @@ -72,8 +72,7 @@ - - + diff --git a/li.strolch.tutorialwebapp/src/main/webapp/WEB-INF/config/PrivilegeModel.xml b/li.strolch.tutorialwebapp/src/main/webapp/WEB-INF/config/PrivilegeModel.xml index b50ec1f7a..5055be39c 100644 --- a/li.strolch.tutorialwebapp/src/main/webapp/WEB-INF/config/PrivilegeModel.xml +++ b/li.strolch.tutorialwebapp/src/main/webapp/WEB-INF/config/PrivilegeModel.xml @@ -58,8 +58,8 @@ - - true + + li.strolch.agent.impl.StartRealms true @@ -75,8 +75,7 @@ - - +