Initial Commit
This commit is contained in:
parent
cf6b5bbea9
commit
c7ce6ead76
|
@ -1 +1,4 @@
|
||||||
target/
|
target/
|
||||||
|
.project
|
||||||
|
.settings
|
||||||
|
.classpath
|
||||||
|
|
|
@ -0,0 +1,185 @@
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<groupId>li.strolch</groupId>
|
||||||
|
<artifactId>li.strolch.service</artifactId>
|
||||||
|
<version>0.1.0-SNAPSHOT</version>
|
||||||
|
|
||||||
|
<name>Service API for Strolch</name>
|
||||||
|
<description>Service API for Strolch</description>
|
||||||
|
|
||||||
|
<url>https://github.com/eitch/li.strolch.service</url>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<!-- POM Reference: http://maven.apache.org/pom.html#Licenses -->
|
||||||
|
|
||||||
|
<inceptionYear>2011</inceptionYear>
|
||||||
|
<licenses>
|
||||||
|
<license>
|
||||||
|
<name>GNU Lesser General Public License</name>
|
||||||
|
<url>http://www.gnu.org/licenses/lgpl.html</url>
|
||||||
|
<distribution>repo</distribution>
|
||||||
|
</license>
|
||||||
|
</licenses>
|
||||||
|
<organization>
|
||||||
|
<name>eitchnet.ch</name>
|
||||||
|
<url>http://blog.eitchnet.ch</url>
|
||||||
|
</organization>
|
||||||
|
<developers>
|
||||||
|
<developer>
|
||||||
|
<id>eitch</id>
|
||||||
|
<name>Robert von Vurg</name>
|
||||||
|
<email>eitch@eitchnet.ch</email>
|
||||||
|
<url>http://blog.eitchnet.ch</url>
|
||||||
|
<organization>eitchnet.ch</organization>
|
||||||
|
<organizationUrl>http://blog.eitchnet.ch</organizationUrl>
|
||||||
|
<roles>
|
||||||
|
<role>architect</role>
|
||||||
|
<role>developer</role>
|
||||||
|
</roles>
|
||||||
|
<timezone>+1</timezone>
|
||||||
|
<properties>
|
||||||
|
<picUrl>http://localhost</picUrl>
|
||||||
|
</properties>
|
||||||
|
</developer>
|
||||||
|
</developers>
|
||||||
|
|
||||||
|
<issueManagement>
|
||||||
|
<system>Github Issues</system>
|
||||||
|
<url>https://github.com/eitch/li.strolch.service/issues</url>
|
||||||
|
</issueManagement>
|
||||||
|
|
||||||
|
<!-- <ciManagement> <system>continuum</system> <url>http://127.0.0.1:8080/continuum</url> <notifiers> <notifier> <type>mail</type>
|
||||||
|
<sendOnError>true</sendOnError> <sendOnFailure>true</sendOnFailure> <sendOnSuccess>false</sendOnSuccess> <sendOnWarning>false</sendOnWarning>
|
||||||
|
<configuration><address>continuum@127.0.0.1</address></configuration> </notifier> </notifiers> </ciManagement> <mailingLists>
|
||||||
|
<mailingList> <name>User List</name> <subscribe>user-subscribe@127.0.0.1</subscribe> <unsubscribe>user-unsubscribe@127.0.0.1</unsubscribe>
|
||||||
|
<post>user@127.0.0.1</post> <archive>http://127.0.0.1/user/</archive> <otherArchives> <otherArchive>http://base.google.com/base/1/127.0.0.1</otherArchive>
|
||||||
|
</otherArchives> </mailingList> </mailingLists> -->
|
||||||
|
|
||||||
|
<scm>
|
||||||
|
<connection>scm:git:https://github.com/eitch/li.strolch.service.git</connection>
|
||||||
|
<developerConnection>scm:git:git@github.com:eitch/li.strolch.service.git</developerConnection>
|
||||||
|
<url>https://github.com/eitch/li.strolch.service</url>
|
||||||
|
</scm>
|
||||||
|
|
||||||
|
<!-- <repositories> <repository> <releases> <enabled>false</enabled> <updatePolicy>always</updatePolicy> <checksumPolicy>warn</checksumPolicy>
|
||||||
|
</releases> <snapshots> <enabled>true</enabled> <updatePolicy>never</updatePolicy> <checksumPolicy>fail</checksumPolicy>
|
||||||
|
</snapshots> <id>codehausSnapshots</id> <name>Codehaus Snapshots</name> <url>http://snapshots.maven.codehaus.org/maven2</url>
|
||||||
|
<layout>default</layout> </repository> </repositories> <pluginRepositories> ... </pluginRepositories> -->
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>li.strolch</groupId>
|
||||||
|
<artifactId>li.strolch.model</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>li.strolch</groupId>
|
||||||
|
<artifactId>li.strolch.persistence.api</artifactId>
|
||||||
|
<version>0.1.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>ch.eitchnet</groupId>
|
||||||
|
<artifactId>ch.eitchnet.xmlpers</artifactId>
|
||||||
|
<version>0.2.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>ch.eitchnet</groupId>
|
||||||
|
<artifactId>ch.eitchnet.privilege</artifactId>
|
||||||
|
<version>0.2.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>junit</groupId>
|
||||||
|
<artifactId>junit</artifactId>
|
||||||
|
<version>4.10</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>ch.eitchnet</groupId>
|
||||||
|
<artifactId>ch.eitchnet.utils</artifactId>
|
||||||
|
<version>0.2.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.slf4j</groupId>
|
||||||
|
<artifactId>slf4j-api</artifactId>
|
||||||
|
<version>1.7.2</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.slf4j</groupId>
|
||||||
|
<artifactId>slf4j-log4j12</artifactId>
|
||||||
|
<version>1.7.2</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-eclipse-plugin</artifactId>
|
||||||
|
<version>2.9</version>
|
||||||
|
<configuration>
|
||||||
|
<downloadJavadocs>true</downloadJavadocs>
|
||||||
|
<downloadSources>true</downloadSources>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.0</version>
|
||||||
|
<configuration>
|
||||||
|
<source>1.7</source>
|
||||||
|
<target>1.7</target>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-source-plugin</artifactId>
|
||||||
|
<version>2.1.2</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>attach-sources</id>
|
||||||
|
<phase>verify</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>jar-no-fork</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-jar-plugin</artifactId>
|
||||||
|
<version>2.4</version>
|
||||||
|
<configuration>
|
||||||
|
<archive>
|
||||||
|
<manifest>
|
||||||
|
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
|
||||||
|
<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
|
||||||
|
<!--mainClass>ch.eitchnet.App</mainClass -->
|
||||||
|
</manifest>
|
||||||
|
</archive>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-site-plugin</artifactId>
|
||||||
|
<version>2.3</version>
|
||||||
|
<configuration>
|
||||||
|
<outputEncoding>UTF-8</outputEncoding>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package ch.eitchnet.command;
|
||||||
|
|
||||||
|
import ch.eitchnet.privilege.model.Restrictable;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Robert von Burg <eitch@eitchnet.ch>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
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();
|
||||||
|
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package ch.eitchnet.service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Robert von Burg <eitch@eitchnet.ch>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package ch.eitchnet.service;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
import ch.eitchnet.privilege.model.Restrictable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Robert von Burg <eitch@eitchnet.ch>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface Service extends Serializable, Restrictable {
|
||||||
|
|
||||||
|
public ServiceResult doService(ServiceArgument argument);
|
||||||
|
|
||||||
|
public ServiceArgument getServiceArgument();
|
||||||
|
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package ch.eitchnet.service;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Robert von Burg <eitch@eitchnet.ch>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface ServiceArgument extends Serializable {
|
||||||
|
|
||||||
|
// marker interface
|
||||||
|
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package ch.eitchnet.service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Robert von Burg <eitch@eitchnet.ch>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package ch.eitchnet.service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Robert von Burg <eitch@eitchnet.ch>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public enum ServiceResultState {
|
||||||
|
|
||||||
|
SUCCESS, WARNING, FAILED;
|
||||||
|
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package ch.eitchnet.service;
|
||||||
|
|
||||||
|
import ch.eitchnet.privilege.handler.PrivilegeHandler;
|
||||||
|
import ch.eitchnet.privilege.model.Certificate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Robert von Burg <eitch@eitchnet.ch>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue