diff --git a/.gitignore b/.gitignore
index 2f7896d1d..b284c6517 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,4 @@
target/
+.project
+.settings
+.classpath
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 000000000..9031f06a2
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,185 @@
+
+
+ 4.0.0
+
+ li.strolch
+ li.strolch.service
+ 0.1.0-SNAPSHOT
+
+ Service API for Strolch
+ Service API for Strolch
+
+ https://github.com/eitch/li.strolch.service
+
+
+ UTF-8
+
+
+
+
+ 2011
+
+
+ GNU Lesser General Public License
+ http://www.gnu.org/licenses/lgpl.html
+ repo
+
+
+
+ eitchnet.ch
+ http://blog.eitchnet.ch
+
+
+
+ eitch
+ Robert von Vurg
+ eitch@eitchnet.ch
+ http://blog.eitchnet.ch
+ eitchnet.ch
+ http://blog.eitchnet.ch
+
+ architect
+ developer
+
+ +1
+
+ http://localhost
+
+
+
+
+
+ Github Issues
+ https://github.com/eitch/li.strolch.service/issues
+
+
+
+
+
+ scm:git:https://github.com/eitch/li.strolch.service.git
+ scm:git:git@github.com:eitch/li.strolch.service.git
+ https://github.com/eitch/li.strolch.service
+
+
+
+
+
+
+
+ li.strolch
+ li.strolch.model
+ 1.0-SNAPSHOT
+
+
+ li.strolch
+ li.strolch.persistence.api
+ 0.1.0-SNAPSHOT
+
+
+
+ ch.eitchnet
+ ch.eitchnet.xmlpers
+ 0.2.0-SNAPSHOT
+
+
+ ch.eitchnet
+ ch.eitchnet.privilege
+ 0.2.0-SNAPSHOT
+
+
+
+ junit
+ junit
+ 4.10
+ test
+
+
+ ch.eitchnet
+ ch.eitchnet.utils
+ 0.2.0-SNAPSHOT
+
+
+ org.slf4j
+ slf4j-api
+ 1.7.2
+
+
+ org.slf4j
+ slf4j-log4j12
+ 1.7.2
+ test
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-eclipse-plugin
+ 2.9
+
+ true
+ true
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.0
+
+ 1.7
+ 1.7
+
+
+
+
+ org.apache.maven.plugins
+ maven-source-plugin
+ 2.1.2
+
+
+ attach-sources
+ verify
+
+ jar-no-fork
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+ 2.4
+
+
+
+ true
+ true
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-site-plugin
+ 2.3
+
+ UTF-8
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/java/li/strolch/command/AbstractCommand.java b/src/main/java/li/strolch/command/AbstractCommand.java
new file mode 100644
index 000000000..69fd43018
--- /dev/null
+++ b/src/main/java/li/strolch/command/AbstractCommand.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2012
+ *
+ * This file is part of ???????????????
+ *
+ * ?????????????? is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Privilege 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 Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with ????????????????. If not, see .
+ *
+ */
+package ch.eitchnet.command;
+
+import ch.eitchnet.privilege.model.Restrictable;
+
+
+/**
+ * @author Robert von Burg
+ *
+ */
+public abstract class AbstractCommand implements Restrictable {
+
+ /**
+ * @see ch.eitchnet.privilege.model.Restrictable#getPrivilegeName()
+ */
+ @Override
+ public String getPrivilegeName() {
+ return AbstractCommand.class.getName();
+ }
+
+ /**
+ * @see ch.eitchnet.privilege.model.Restrictable#getPrivilegeValue()
+ */
+ @Override
+ public Object getPrivilegeValue() {
+ return this.getClass().getName();
+ }
+
+ public abstract void doCommand();
+}
diff --git a/src/main/java/li/strolch/service/AbstractService.java b/src/main/java/li/strolch/service/AbstractService.java
new file mode 100644
index 000000000..11f520316
--- /dev/null
+++ b/src/main/java/li/strolch/service/AbstractService.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2012
+ *
+ * This file is part of ???????????????
+ *
+ * ?????????????? is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Privilege 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 Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with ????????????????. If not, see .
+ *
+ */
+package ch.eitchnet.service;
+
+/**
+ * @author Robert von Burg
+ *
+ */
+public abstract class AbstractService implements Service {
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * @see ch.eitchnet.privilege.model.Restrictable#getPrivilegeName()
+ */
+ @Override
+ public String getPrivilegeName() {
+ return Service.class.getName();
+ }
+
+ /**
+ * @see ch.eitchnet.privilege.model.Restrictable#getPrivilegeValue()
+ */
+ @Override
+ public Object getPrivilegeValue() {
+ return this.getClass().getName();
+ }
+}
diff --git a/src/main/java/li/strolch/service/Service.java b/src/main/java/li/strolch/service/Service.java
new file mode 100644
index 000000000..4b4a5ce5d
--- /dev/null
+++ b/src/main/java/li/strolch/service/Service.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2012
+ *
+ * This file is part of ???????????????
+ *
+ * ?????????????? is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Privilege 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 Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with ????????????????. If not, see .
+ *
+ */
+package ch.eitchnet.service;
+
+import java.io.Serializable;
+
+import ch.eitchnet.privilege.model.Restrictable;
+
+/**
+ * @author Robert von Burg
+ *
+ */
+public interface Service extends Serializable, Restrictable {
+
+ public ServiceResult doService(ServiceArgument argument);
+
+ public ServiceArgument getServiceArgument();
+}
diff --git a/src/main/java/li/strolch/service/ServiceArgument.java b/src/main/java/li/strolch/service/ServiceArgument.java
new file mode 100644
index 000000000..95841dbac
--- /dev/null
+++ b/src/main/java/li/strolch/service/ServiceArgument.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2012
+ *
+ * This file is part of ???????????????
+ *
+ * ?????????????? is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Privilege 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 Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with ????????????????. If not, see .
+ *
+ */
+package ch.eitchnet.service;
+
+import java.io.Serializable;
+
+/**
+ * @author Robert von Burg
+ *
+ */
+public interface ServiceArgument extends Serializable {
+
+ // marker interface
+}
diff --git a/src/main/java/li/strolch/service/ServiceResult.java b/src/main/java/li/strolch/service/ServiceResult.java
new file mode 100644
index 000000000..6a7fde078
--- /dev/null
+++ b/src/main/java/li/strolch/service/ServiceResult.java
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2012
+ *
+ * This file is part of ???????????????
+ *
+ * ?????????????? is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Privilege 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 Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with ????????????????. If not, see .
+ *
+ */
+package ch.eitchnet.service;
+
+/**
+ * @author Robert von Burg
+ *
+ */
+public class ServiceResult {
+
+ private ServiceResultState state;
+ private String message;
+ private Throwable throwable;
+
+ /**
+ * @param state
+ * @param message
+ * @param throwable
+ */
+ public ServiceResult(ServiceResultState state, String message, Throwable throwable) {
+ this.state = state;
+ this.message = message;
+ this.throwable = throwable;
+ }
+
+ /**
+ * @return the state
+ */
+ public ServiceResultState getState() {
+ return this.state;
+ }
+
+ /**
+ * @param state
+ * the state to set
+ */
+ public void setState(ServiceResultState state) {
+ this.state = state;
+ }
+
+ /**
+ * @return the message
+ */
+ public String getMessage() {
+ return this.message;
+ }
+
+ /**
+ * @param message
+ * the message to set
+ */
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ /**
+ * @return the throwable
+ */
+ public Throwable getThrowable() {
+ return this.throwable;
+ }
+
+ /**
+ * @param throwable
+ * the throwable to set
+ */
+ public void setThrowable(Throwable throwable) {
+ this.throwable = throwable;
+ }
+
+ public static ServiceResult success() {
+ return new ServiceResult(ServiceResultState.SUCCESS, null, null);
+ }
+
+ public static ServiceResult success(String msg) {
+ return new ServiceResult(ServiceResultState.SUCCESS, msg, null);
+ }
+
+ public static ServiceResult warning(String warning) {
+ return new ServiceResult(ServiceResultState.WARNING, warning, null);
+ }
+
+ public static ServiceResult warning(String warning, Throwable t) {
+ return new ServiceResult(ServiceResultState.WARNING, warning, t);
+ }
+
+ public static ServiceResult failed(String error, Throwable t) {
+ return new ServiceResult(ServiceResultState.FAILED, error, t);
+ }
+}
diff --git a/src/main/java/li/strolch/service/ServiceResultState.java b/src/main/java/li/strolch/service/ServiceResultState.java
new file mode 100644
index 000000000..d6e7981e1
--- /dev/null
+++ b/src/main/java/li/strolch/service/ServiceResultState.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2012
+ *
+ * This file is part of ???????????????
+ *
+ * ?????????????? is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Privilege 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 Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with ????????????????. If not, see .
+ *
+ */
+package ch.eitchnet.service;
+
+/**
+ * @author Robert von Burg
+ *
+ */
+public enum ServiceResultState {
+
+ SUCCESS, WARNING, FAILED;
+}
diff --git a/src/main/java/li/strolch/service/SimpleServiceHandler.java b/src/main/java/li/strolch/service/SimpleServiceHandler.java
new file mode 100644
index 000000000..54ef842b4
--- /dev/null
+++ b/src/main/java/li/strolch/service/SimpleServiceHandler.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2012
+ *
+ * This file is part of ???????????????
+ *
+ * ?????????????? is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Privilege 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 Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with ????????????????. If not, see .
+ *
+ */
+package ch.eitchnet.service;
+
+import ch.eitchnet.privilege.handler.PrivilegeHandler;
+import ch.eitchnet.privilege.model.Certificate;
+
+/**
+ * @author Robert von Burg
+ *
+ */
+public class SimpleServiceHandler {
+
+ private PrivilegeHandler privilegeHandler;
+
+ public ServiceResult doService(Certificate certificate, Service service, ServiceArgument argument) {
+
+ try {
+
+ this.privilegeHandler.getPrivilegeContext(certificate).validateAction(service);
+
+ return service.doService(argument);
+
+ } catch (Exception e) {
+ String error = "Failed to perform service " + service.getClass().getName() + " due to exception "
+ + e.getLocalizedMessage();
+ return ServiceResult.failed(error, e);
+ }
+ }
+}