BATCHEE-109 removing SecurityService
diff --git a/extensions/pom.xml b/extensions/pom.xml
index f62bf8d..35b0869 100644
--- a/extensions/pom.xml
+++ b/extensions/pom.xml
@@ -29,7 +29,6 @@
<packaging>pom</packaging>
<modules>
- <module>shiro</module>
<module>extras</module>
<module>beanio</module>
<module>camel</module>
diff --git a/extensions/shiro/derby.log b/extensions/shiro/derby.log
deleted file mode 100644
index 7cae70f..0000000
--- a/extensions/shiro/derby.log
+++ /dev/null
@@ -1,13 +0,0 @@
-----------------------------------------------------------------
-Thu Aug 29 16:16:53 CEST 2013:
-Booting Derby version The Apache Software Foundation - Apache Derby - 10.10.1.1 - (1458268): instance a816c00e-0140-ca6f-1a53-0000057b50d8
-on database directory /opt/dev/github/batchee/shiro/target/RUNTIMEDB with class loader sun.misc.Launcher$AppClassLoader@3b6cdbb8
-Loaded from file:/home/a185558/.m2/repository/org/apache/derby/derby/10.10.1.1/derby-10.10.1.1.jar
-java.vendor=Oracle Corporation
-java.runtime.version=1.7.0_25-b15
-user.dir=/opt/dev/github/batchee/shiro
-os.name=Linux
-os.arch=amd64
-os.version=3.8.0-19-generic
-derby.system.home=null
-Database Class Loader started - derby.database.classpath=''
diff --git a/extensions/shiro/pom.xml b/extensions/shiro/pom.xml
deleted file mode 100644
index 5327e44..0000000
--- a/extensions/shiro/pom.xml
+++ /dev/null
@@ -1,50 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You 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.
--->
-<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>
-
- <parent>
- <artifactId>batchee-extensions</artifactId>
- <groupId>org.apache.batchee</groupId>
- <version>0.4-incubating-SNAPSHOT</version>
- </parent>
-
- <artifactId>batchee-shiro</artifactId>
- <name>BatchEE :: Extensions :: Shiro</name>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.batchee</groupId>
- <artifactId>batchee-jbatch</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.shiro</groupId>
- <artifactId>shiro-core</artifactId>
- <version>1.2.2</version>
- </dependency>
-
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-jdk14</artifactId>
- <version>1.7.5</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
-</project>
diff --git a/extensions/shiro/src/main/java/org/apache/batchee/shiro/ShiroSecurityService.java b/extensions/shiro/src/main/java/org/apache/batchee/shiro/ShiroSecurityService.java
deleted file mode 100644
index bdccb58..0000000
--- a/extensions/shiro/src/main/java/org/apache/batchee/shiro/ShiroSecurityService.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.apache.batchee.shiro;
-
-import org.apache.batchee.container.services.security.DefaultSecurityService;
-
-import java.util.Properties;
-
-import static org.apache.shiro.SecurityUtils.getSubject;
-
-public class ShiroSecurityService extends DefaultSecurityService {
- private String instancePrefix;
- private String permissionPrefix;
- private String jobNamePrefix;
-
- private boolean isAuthenticatedAndAuthorized(final String permission) {
- return getSubject().isAuthenticated() && getSubject().isPermitted(permission);
- }
-
- @Override
- public boolean isAuthorized(final long instanceId) {
- return isAuthenticatedAndAuthorized(instancePrefix + instanceId);
- }
-
- @Override
- public boolean isAuthorized(final String perm) {
- return isAuthenticatedAndAuthorized(permissionPrefix + perm);
- }
-
- @Override
- public boolean isAuthorizedJobName(String jobName) {
- return isAuthenticatedAndAuthorized(jobNamePrefix + jobName);
- }
-
- @Override
- public String getLoggedUser() {
- if (getSubject().isAuthenticated()) {
- return getSubject().getPrincipal().toString();
- }
- return super.getLoggedUser();
- }
-
- @Override
- public void init(final Properties batchConfig) {
- super.init(batchConfig);
- permissionPrefix = batchConfig.getProperty("security.job.permission-prefix", "jbatch:");
- instancePrefix = permissionPrefix + batchConfig.getProperty("security.job.permission-prefix", "instance:");
- jobNamePrefix = permissionPrefix + batchConfig.getProperty("security.job.permission-prefix", "jobName:");
- }
-}
diff --git a/extensions/shiro/src/test/java/org/apache/batchee/shiro/ShiroTest.java b/extensions/shiro/src/test/java/org/apache/batchee/shiro/ShiroTest.java
deleted file mode 100644
index f21b086..0000000
--- a/extensions/shiro/src/test/java/org/apache/batchee/shiro/ShiroTest.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.apache.batchee.shiro;
-
-import org.apache.shiro.SecurityUtils;
-import org.apache.shiro.authc.UsernamePasswordToken;
-import org.apache.shiro.config.IniSecurityManagerFactory;
-import org.apache.shiro.subject.Subject;
-import org.apache.shiro.util.ThreadContext;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-import javax.batch.api.Batchlet;
-import javax.batch.operations.JobOperator;
-import javax.batch.operations.JobSecurityException;
-import javax.batch.runtime.BatchRuntime;
-import java.util.Properties;
-
-public class ShiroTest {
- @BeforeClass
- public static void initShiro() {
- SecurityUtils.setSecurityManager(new IniSecurityManagerFactory("classpath:shiro.ini").getInstance());
- }
-
- @AfterClass
- public static void resetShiro() {
- ThreadContext.unbindSubject();
- ThreadContext.unbindSecurityManager();
- ThreadContext.remove();
- }
-
- @Test
- public void authorized() {
- run("user1");
- }
-
- @Test(expectedExceptions = JobSecurityException.class)
- public void notAuthorized() {
- run("user2");
- }
-
- @Test(expectedExceptions = JobSecurityException.class)
- public void notLogged() {
- runJob();
- }
-
- private static void run(final String user) {
- final Subject subject = SecurityUtils.getSubject();
- subject.login(new UsernamePasswordToken(user, "userpwd"));
- try {
- runJob();
- } finally {
- subject.logout();
- }
- }
-
- private static void runJob() {
- final JobOperator jobOperator = BatchRuntime.getJobOperator();
- jobOperator.start("job", new Properties());
- }
-
- public static class ABatchlet implements Batchlet {
- @Override
- public String process() throws Exception {
- return null;
- }
-
- @Override
- public void stop() throws Exception {
- // no-op
- }
- }
-}
diff --git a/extensions/shiro/src/test/resources/META-INF/batch-jobs/job.xml b/extensions/shiro/src/test/resources/META-INF/batch-jobs/job.xml
deleted file mode 100644
index b646ad8..0000000
--- a/extensions/shiro/src/test/resources/META-INF/batch-jobs/job.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- See the NOTICE file distributed with this work for additional information
- regarding copyright ownership. 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.
--->
-<job id="shiro" xmlns="http://xmlns.jcp.org/xml/ns/javaee" version="1.0">
- <step id="step1">
- <batchlet ref="org.apache.batchee.shiro.ShiroTest$ABatchlet" />
- </step>
-</job>
diff --git a/extensions/shiro/src/test/resources/batchee.properties b/extensions/shiro/src/test/resources/batchee.properties
deleted file mode 100644
index 7e99e9b..0000000
--- a/extensions/shiro/src/test/resources/batchee.properties
+++ /dev/null
@@ -1,17 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You 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.
-
-SecurityService = org.apache.batchee.shiro.ShiroSecurityService
diff --git a/extensions/shiro/src/test/resources/shiro.ini b/extensions/shiro/src/test/resources/shiro.ini
deleted file mode 100644
index 06eb421..0000000
--- a/extensions/shiro/src/test/resources/shiro.ini
+++ /dev/null
@@ -1,22 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You 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.
-
-[users]
-user1 = userpwd, start
-user2 = userpwd
-
-[roles]
-start = jbatch:start
diff --git a/jbatch/src/main/java/org/apache/batchee/container/impl/JobOperatorImpl.java b/jbatch/src/main/java/org/apache/batchee/container/impl/JobOperatorImpl.java
index bde0b87..d3b69d5 100755
--- a/jbatch/src/main/java/org/apache/batchee/container/impl/JobOperatorImpl.java
+++ b/jbatch/src/main/java/org/apache/batchee/container/impl/JobOperatorImpl.java
@@ -28,7 +28,6 @@
import org.apache.batchee.spi.JobExecutionCallbackService;
import org.apache.batchee.spi.JobXMLLoaderService;
import org.apache.batchee.spi.PersistenceManagerService;
-import org.apache.batchee.spi.SecurityService;
import javax.batch.operations.JobExecutionAlreadyCompleteException;
import javax.batch.operations.JobExecutionIsRunningException;
@@ -109,7 +108,6 @@
private final PersistenceManagerService persistenceManagerService;
private final JobXMLLoaderService xmlLoaderService;
private final JobStatusManagerService statusManagerService;
- private final SecurityService securityService;
private final JobExecutionCallbackService callbackService;
public JobOperatorImpl() {
@@ -119,7 +117,6 @@
persistenceManagerService = servicesManager.service(PersistenceManagerService.class);
xmlLoaderService = servicesManager.service(JobXMLLoaderService.class);
statusManagerService = servicesManager.service(JobStatusManagerService.class);
- securityService = servicesManager.service(SecurityService.class);
callbackService = servicesManager.service(JobExecutionCallbackService.class);
} catch (RuntimeException e) {
LOGGER.log(Level.SEVERE, "Error while booting BatchEE", e);
@@ -129,10 +126,6 @@
@Override
public long start(final String jobXMLName, final Properties jobParameters) throws JobStartException, JobSecurityException {
- if (!securityService.isAuthorized(Permissions.START.name)) {
- throw new JobSecurityException("The current user is not authorized to perform this operation");
- }
-
/*
* The whole point of this method is to have JobStartException serve as a blanket exception for anything other
* than the rest of the more specific exceptions declared on the throws clause. So we won't log but just rethrow.
@@ -165,10 +158,6 @@
@Override
public void abandon(final long executionId) throws NoSuchJobExecutionException, JobExecutionIsRunningException, JobSecurityException {
- if (!securityService.isAuthorized(persistenceManagerService.getJobInstanceIdByExecutionId(executionId))) {
- throw new JobSecurityException("The current user is not authorized to perform this operation");
- }
-
final InternalJobExecution jobEx = persistenceManagerService.jobOperatorGetJobExecution(executionId);
// if it is not in STARTED or STARTING state, mark it as ABANDONED
@@ -187,18 +176,12 @@
@Override
public InternalJobExecution getJobExecution(final long executionId)
throws NoSuchJobExecutionException, JobSecurityException {
- if (!securityService.isAuthorized(persistenceManagerService.getJobInstanceIdByExecutionId(executionId))) {
- throw new JobSecurityException("The current user is not authorized to perform this operation");
- }
return kernelService.getJobExecution(executionId);
}
@Override
public List<JobExecution> getJobExecutions(final JobInstance instance)
throws NoSuchJobInstanceException, JobSecurityException {
- if (!securityService.isAuthorized(instance.getInstanceId())) {
- throw new JobSecurityException("The current user is not authorized to perform this operation");
- }
// Mediate between one
final List<JobExecution> executions = new ArrayList<JobExecution>();
@@ -215,22 +198,12 @@
@Override
public JobInstance getJobInstance(long executionId)
throws NoSuchJobExecutionException, JobSecurityException {
- if (!securityService.isAuthorized(persistenceManagerService.getJobInstanceIdByExecutionId(executionId))) {
- throw new JobSecurityException("The current user is not authorized to perform this operation");
- }
return kernelService.getJobInstance(executionId);
}
@Override
public int getJobInstanceCount(String jobName) throws NoSuchJobException, JobSecurityException {
- int jobInstanceCount;
- if (securityService.isAuthorized(JBATCH_ADMIN)) {
- // Do an unfiltered query
- jobInstanceCount = persistenceManagerService.jobOperatorGetJobInstanceCount(jobName);
- } else {
- jobInstanceCount = persistenceManagerService.jobOperatorGetJobInstanceCount(jobName, securityService.getLoggedUser());
- }
-
+ final int jobInstanceCount = persistenceManagerService.jobOperatorGetJobInstanceCount(jobName);
if (jobInstanceCount > 0) {
return jobInstanceCount;
}
@@ -249,13 +222,7 @@
throw new IllegalArgumentException("Count should be a positive integer (or 0, which will return an empty list)");
}
- final List<Long> instanceIds;
- if (securityService.isAuthorized(JBATCH_ADMIN)) {
- // Do an unfiltered query
- instanceIds = persistenceManagerService.jobOperatorGetJobInstanceIds(jobName, start, count);
- } else {
- instanceIds = persistenceManagerService.jobOperatorGetJobInstanceIds(jobName, securityService.getLoggedUser(), start, count);
- }
+ final List<Long> instanceIds = persistenceManagerService.jobOperatorGetJobInstanceIds(jobName, start, count);
// get the jobinstance ids associated with this job name
@@ -265,9 +232,7 @@
// get the job instance obj, add it to the list
final JobStatus jobStatus = statusManagerService.getJobStatus(id);
final JobInstance jobInstance = jobStatus.getJobInstance();
- if (securityService.isAuthorized(jobInstance.getInstanceId())) {
- jobInstances.add(jobInstance);
- }
+ jobInstances.add(jobInstance);
}
// send the list of objs back to caller
return jobInstances;
@@ -282,22 +247,12 @@
*/
@Override
public Set<String> getJobNames() throws JobSecurityException {
- final Set<String> jobNames = new HashSet<String>();
- final Set<String> jobNamesFromDb = persistenceManagerService.getJobNames();
- for (String jobName : jobNamesFromDb) {
- if (securityService.isAuthorizedJobName(jobName)) {
- jobNames.add(jobName);
- }
- }
- return jobNames;
+ return new HashSet<String>(persistenceManagerService.getJobNames());
}
@Override
public Properties getParameters(final long executionId) throws NoSuchJobExecutionException, JobSecurityException {
final JobInstance requestedJobInstance = kernelService.getJobInstance(executionId);
- if (!securityService.isAuthorized(requestedJobInstance.getInstanceId())) {
- throw new JobSecurityException("The current user is not authorized to perform this operation");
- }
return persistenceManagerService.getParameters(executionId);
}
@@ -316,11 +271,9 @@
// for every job instance id
for (final long id : executionIds) {
try {
- if (securityService.isAuthorized(persistenceManagerService.getJobInstanceIdByExecutionId(id))) {
- if (kernelService.isExecutionRunning(id)) {
- final InternalJobExecution jobEx = kernelService.getJobExecution(id);
- jobExecutions.add(jobEx.getExecutionId());
- }
+ if (kernelService.isExecutionRunning(id)) {
+ final InternalJobExecution jobEx = kernelService.getJobExecution(id);
+ jobExecutions.add(jobEx.getExecutionId());
}
} catch (final NoSuchJobExecutionException e) {
throw new IllegalStateException("Just found execution with id = " + id + " in table, but now seeing it as gone", e);
@@ -337,10 +290,7 @@
if (jobEx == null) {
throw new NoSuchJobExecutionException("Job Execution: " + executionId + " not found");
}
- if (securityService.isAuthorized(persistenceManagerService.getJobInstanceIdByExecutionId(executionId))) {
- return persistenceManagerService.getStepExecutionsForJobExecution(executionId);
- }
- throw new JobSecurityException("The current user is not authorized to perform this operation");
+ return persistenceManagerService.getStepExecutionsForJobExecution(executionId);
}
@Override
@@ -367,10 +317,6 @@
private long restartInternal(final long oldExecutionId, final Properties restartParameters)
throws JobExecutionAlreadyCompleteException, NoSuchJobExecutionException, JobExecutionNotMostRecentException, JobRestartException, JobSecurityException {
- if (!securityService.isAuthorized(persistenceManagerService.getJobInstanceIdByExecutionId(oldExecutionId))) {
- throw new JobSecurityException("The current user is not authorized to perform this operation");
- }
-
final StringWriter jobParameterWriter = new StringWriter();
if (restartParameters != null) {
try {
@@ -387,10 +333,6 @@
@Override
public void stop(final long executionId) throws NoSuchJobExecutionException, JobExecutionNotRunningException, JobSecurityException {
- if (!securityService.isAuthorized(persistenceManagerService.getJobInstanceIdByExecutionId(executionId))) {
- throw new JobSecurityException("The current user is not authorized to perform this operation");
- }
-
kernelService.stopJob(executionId);
}
diff --git a/jbatch/src/main/java/org/apache/batchee/container/impl/jobinstance/JobExecutionHelper.java b/jbatch/src/main/java/org/apache/batchee/container/impl/jobinstance/JobExecutionHelper.java
index da241aa..03ea794 100755
--- a/jbatch/src/main/java/org/apache/batchee/container/impl/jobinstance/JobExecutionHelper.java
+++ b/jbatch/src/main/java/org/apache/batchee/container/impl/jobinstance/JobExecutionHelper.java
@@ -30,7 +30,6 @@
import org.apache.batchee.jaxb.JSLJob;
import org.apache.batchee.jaxb.JSLProperties;
import org.apache.batchee.spi.PersistenceManagerService;
-import org.apache.batchee.spi.SecurityService;
import javax.batch.operations.JobExecutionAlreadyCompleteException;
import javax.batch.operations.JobExecutionNotMostRecentException;
@@ -72,12 +71,11 @@
private static JobInstance getNewJobInstance(final ServicesManager servicesManager, final String name, final String jobXml) {
return servicesManager.service(PersistenceManagerService.class).createJobInstance(
- name, servicesManager.service(SecurityService.class).getLoggedUser(), jobXml);
+ name, jobXml);
}
private static JobInstance getNewSubJobInstance(final ServicesManager servicesManager, final String name) {
- return servicesManager.service(PersistenceManagerService.class).createSubJobInstance(
- name, servicesManager.service(SecurityService.class).getLoggedUser());
+ return servicesManager.service(PersistenceManagerService.class).createSubJobInstance(name);
}
private static JobStatus createNewJobStatus(final JobStatusManagerService statusManagerService, final JobInstance jobInstance) {
diff --git a/jbatch/src/main/java/org/apache/batchee/container/services/ServicesManager.java b/jbatch/src/main/java/org/apache/batchee/container/services/ServicesManager.java
index 1dd0b06..4aefa33 100755
--- a/jbatch/src/main/java/org/apache/batchee/container/services/ServicesManager.java
+++ b/jbatch/src/main/java/org/apache/batchee/container/services/ServicesManager.java
@@ -28,7 +28,6 @@
import org.apache.batchee.container.services.loader.DefaultJobXMLLoaderService;
import org.apache.batchee.container.services.locator.SingletonLocator;
import org.apache.batchee.container.services.persistence.MemoryPersistenceManagerService;
-import org.apache.batchee.container.services.security.DefaultSecurityService;
import org.apache.batchee.container.services.status.DefaultJobStatusManager;
import org.apache.batchee.container.services.transaction.DefaultBatchTransactionService;
import org.apache.batchee.container.util.BatchContainerConstants;
@@ -39,7 +38,6 @@
import org.apache.batchee.spi.JobExecutionCallbackService;
import org.apache.batchee.spi.JobXMLLoaderService;
import org.apache.batchee.spi.PersistenceManagerService;
-import org.apache.batchee.spi.SecurityService;
import org.apache.batchee.spi.TransactionManagementService;
import java.io.IOException;
@@ -65,7 +63,6 @@
SERVICE_IMPL_CLASS_NAMES.put(BatchThreadPoolService.class.getName(), DefaultThreadPoolService.class.getName());
SERVICE_IMPL_CLASS_NAMES.put(BatchKernelService.class.getName(), DefaultBatchKernel.class.getName());
SERVICE_IMPL_CLASS_NAMES.put(JobXMLLoaderService.class.getName(), DefaultJobXMLLoaderService.class.getName());
- SERVICE_IMPL_CLASS_NAMES.put(SecurityService.class.getName(), DefaultSecurityService.class.getName());
SERVICE_IMPL_CLASS_NAMES.put(JobExecutionCallbackService.class.getName(), SimpleJobExecutionCallbackService.class.getName());
SERVICE_IMPL_CLASS_NAMES.put(DataRepresentationService.class.getName(), DefaultDataRepresentationService.class.getName());
try {
diff --git a/jbatch/src/main/java/org/apache/batchee/container/services/persistence/JDBCPersistenceManagerService.java b/jbatch/src/main/java/org/apache/batchee/container/services/persistence/JDBCPersistenceManagerService.java
index 56101b5..fa7d095 100755
--- a/jbatch/src/main/java/org/apache/batchee/container/services/persistence/JDBCPersistenceManagerService.java
+++ b/jbatch/src/main/java/org/apache/batchee/container/services/persistence/JDBCPersistenceManagerService.java
@@ -68,10 +68,8 @@
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Date;
-import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
-import java.util.Map;
import java.util.Properties;
import java.util.Set;
@@ -441,26 +439,6 @@
}
@Override
- public int jobOperatorGetJobInstanceCount(final String jobName, final String appTag) {
- Connection conn = null;
- PreparedStatement statement = null;
- ResultSet rs = null;
- try {
- conn = getConnection();
- statement = conn.prepareStatement(dictionary.getCountJobInstanceByNameAndTag());
- statement.setString(1, jobName);
- statement.setString(2, appTag);
- rs = statement.executeQuery();
- rs.next();
- return rs.getInt("jobinstancecount"); // not a column name so ok
- } catch (final SQLException e) {
- throw new PersistenceException(e);
- } finally {
- cleanupConnection(conn, rs, statement);
- }
- }
-
- @Override
public int jobOperatorGetJobInstanceCount(final String jobName) {
Connection conn = null;
PreparedStatement statement = null;
@@ -479,39 +457,6 @@
}
}
-
- @Override
- public List<Long> jobOperatorGetJobInstanceIds(final String jobName, final String appTag, final int start, final int count) {
- Connection conn = null;
- PreparedStatement statement = null;
- ResultSet rs = null;
-
- final List<Long> data = new ArrayList<Long>();
- try {
- conn = getConnection();
- statement = conn.prepareStatement(dictionary.getFindJoBInstanceIds());
- statement.setObject(1, jobName);
- statement.setObject(2, appTag);
- rs = statement.executeQuery();
- while (rs.next()) {
- data.add(rs.getLong(dictionary.jobInstanceColumns(0)));
- }
- } catch (final SQLException e) {
- throw new PersistenceException(e);
- } finally {
- cleanupConnection(conn, rs, statement);
- }
-
- if (!data.isEmpty()) {
- try {
- return data.subList(start, start + count);
- } catch (final IndexOutOfBoundsException oobEx) {
- return data.subList(start, data.size());
- }
- }
- return data;
- }
-
@Override
public List<Long> jobOperatorGetJobInstanceIds(final String jobName, final int start, final int count) {
Connection conn = null;
@@ -545,32 +490,6 @@
}
@Override
- public Map<Long, String> jobOperatorGetExternalJobInstanceData() {
- Connection conn = null;
- PreparedStatement statement = null;
- ResultSet rs = null;
-
- final Map<Long, String> data = new HashMap<Long, String>();
-
- try {
- conn = getConnection();
-
- // Filter out 'subjob' parallel execution entries which start with the special character
- statement = conn.prepareStatement(dictionary.getFindExternalJobInstances());
- rs = statement.executeQuery();
- while (rs.next()) {
- data.put(rs.getLong(dictionary.jobInstanceColumns(0)), rs.getString(dictionary.jobInstanceColumns(3)));
- }
- } catch (final SQLException e) {
- throw new PersistenceException(e);
- } finally {
- cleanupConnection(conn, rs, statement);
- }
-
- return data;
- }
-
- @Override
public Set<String> getJobNames() {
Connection conn = null;
PreparedStatement statement = null;
@@ -1114,7 +1033,7 @@
}
@Override
- public JobInstance createSubJobInstance(final String name, final String apptag) {
+ public JobInstance createSubJobInstance(final String name) {
Connection conn = null;
PreparedStatement statement = null;
ResultSet rs = null;
@@ -1124,7 +1043,6 @@
conn = getConnection();
statement = conn.prepareStatement(dictionary.getCreateJobInstance(), Statement.RETURN_GENERATED_KEYS);
statement.setString(1, name);
- statement.setString(2, apptag);
statement.executeUpdate();
if (!conn.getAutoCommit()) {
conn.commit();
@@ -1144,7 +1062,7 @@
}
@Override
- public JobInstance createJobInstance(final String name, final String apptag, final String jobXml) {
+ public JobInstance createJobInstance(final String name, final String jobXml) {
Connection conn = null;
PreparedStatement statement = null;
ResultSet rs = null;
@@ -1153,8 +1071,7 @@
conn = getConnection();
statement = conn.prepareStatement(dictionary.getCreateJobInstanceWithJobXml(), Statement.RETURN_GENERATED_KEYS);
statement.setString(1, name);
- statement.setString(2, apptag);
- statement.setBytes(3, jobXml.getBytes(UTF_8));
+ statement.setBytes(2, jobXml.getBytes(UTF_8));
statement.executeUpdate();
if (!conn.getAutoCommit()) {
conn.commit();
diff --git a/jbatch/src/main/java/org/apache/batchee/container/services/persistence/JPAPersistenceManagerService.java b/jbatch/src/main/java/org/apache/batchee/container/services/persistence/JPAPersistenceManagerService.java
index be07489..f07af8f 100644
--- a/jbatch/src/main/java/org/apache/batchee/container/services/persistence/JPAPersistenceManagerService.java
+++ b/jbatch/src/main/java/org/apache/batchee/container/services/persistence/JPAPersistenceManagerService.java
@@ -57,10 +57,8 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
-import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
-import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.TreeSet;
@@ -148,25 +146,6 @@
}
@Override
- public Map<Long, String> jobOperatorGetExternalJobInstanceData() {
- final Map<Long, String> data = new HashMap<Long, String>();
- final EntityManager em = emProvider.newEntityManager();
- try {
- final List<JobInstanceEntity> list = em.createNamedQuery(JobInstanceEntity.Queries.FIND_EXTERNALS, JobInstanceEntity.class)
- .setParameter("pattern", PartitionedStepBuilder.JOB_ID_SEPARATOR)
- .getResultList();
- if (list != null) {
- for (final JobInstanceEntity elt : list) {
- data.put(elt.getJobInstanceId(), elt.getName());
- }
- }
- } finally {
- emProvider.release(em);
- }
- return data;
- }
-
- @Override
public Set<String> getJobNames() {
Set<String> jobNames = new TreeSet<String>();
final EntityManager em = emProvider.newEntityManager();
@@ -622,25 +601,16 @@
}
@Override
- public JobInstance createSubJobInstance(final String name, final String apptag) {
- return createJobInstance(name, apptag, null);
+ public JobInstance createSubJobInstance(final String name) {
+ return createJobInstance(name, null);
}
@Override
public List<Long> jobOperatorGetJobInstanceIds(final String jobName, final int start, final int count) {
- return jobOperatorGetJobInstanceIds(jobName, null, start, count);
- }
-
- @Override
- public List<Long> jobOperatorGetJobInstanceIds(final String jobName, final String appTag, final int start, final int count) {
final EntityManager em = emProvider.newEntityManager();
try {
final TypedQuery<JobInstanceEntity> query;
- if (appTag != null) {
- query = em.createNamedQuery(JobInstanceEntity.Queries.FIND_BY_NAME, JobInstanceEntity.class).setParameter("tag", appTag);
- } else {
- query = em.createNamedQuery(JobInstanceEntity.Queries.FIND_BY_NAME, JobInstanceEntity.class);
- }
+ query = em.createNamedQuery(JobInstanceEntity.Queries.FIND_BY_NAME, JobInstanceEntity.class);
query.setParameter("name", jobName);
final List<JobInstanceEntity> resultList = query
@@ -663,11 +633,10 @@
}
@Override
- public JobInstance createJobInstance(final String name, final String apptag, final String jobXml) {
+ public JobInstance createJobInstance(final String name, final String jobXml) {
final EntityManager em = emProvider.newEntityManager();
try {
final JobInstanceEntity instance = new JobInstanceEntity();
- instance.setTag(apptag);
instance.setName(name);
instance.setJobXml(jobXml);
@@ -700,19 +669,6 @@
}
@Override
- public int jobOperatorGetJobInstanceCount(final String jobName, final String appTag) {
- final EntityManager em = emProvider.newEntityManager();
- try {
- return em.createNamedQuery(JobInstanceEntity.Queries.COUNT_BY_NAME, Number.class)
- .setParameter("name", jobName)
- .setParameter("tag", appTag)
- .getSingleResult().intValue();
- } finally {
- emProvider.release(em);
- }
- }
-
- @Override
public void updateStepStatus(final long stepExecutionId, final StepStatus stepStatus) {
final EntityManager em = emProvider.newEntityManager();
try {
diff --git a/jbatch/src/main/java/org/apache/batchee/container/services/persistence/MemoryPersistenceManagerService.java b/jbatch/src/main/java/org/apache/batchee/container/services/persistence/MemoryPersistenceManagerService.java
index 78d5e68..ff988f4 100644
--- a/jbatch/src/main/java/org/apache/batchee/container/services/persistence/MemoryPersistenceManagerService.java
+++ b/jbatch/src/main/java/org/apache/batchee/container/services/persistence/MemoryPersistenceManagerService.java
@@ -43,7 +43,6 @@
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
-import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
@@ -65,7 +64,6 @@
protected static interface Structures extends Serializable {
static class JobInstanceData implements Structures {
protected JobInstanceImpl instance;
- protected String tag;
protected JobStatus status;
protected final List<ExecutionInstanceData> executions = new LinkedList<ExecutionInstanceData>();
protected final Collection<CheckpointDataKey> checkpoints = new LinkedList<CheckpointDataKey>();
@@ -117,15 +115,9 @@
@Override
public int jobOperatorGetJobInstanceCount(final String jobName) {
- return jobOperatorGetJobInstanceCount(jobName, null);
- }
-
- @Override
- public int jobOperatorGetJobInstanceCount(final String jobName, final String appTag) {
- final boolean hasTag = appTag != null;
int i = 0;
for (final Structures.JobInstanceData jobInstanceData : data.jobInstanceData.values()) {
- if (jobInstanceData.instance.getJobName().equals(jobName) && (!hasTag || appTag.equals(jobInstanceData.tag))) {
+ if (jobInstanceData.instance.getJobName().equals(jobName)) {
i++;
}
}
@@ -133,17 +125,6 @@
}
@Override
- public Map<Long, String> jobOperatorGetExternalJobInstanceData() {
- final Map<Long, String> out = new HashMap<Long, String>();
- for (final Structures.JobInstanceData jobInstanceData : data.jobInstanceData.values()) {
- if (jobInstanceData.instance.getJobName() != null && !jobInstanceData.instance.getJobName().startsWith(PartitionedStepBuilder.JOB_ID_SEPARATOR)) {
- out.put(jobInstanceData.instance.getInstanceId(), jobInstanceData.instance.getJobName());
- }
- }
- return out;
- }
-
- @Override
public Set<String> getJobNames() {
Set<String> jobNames = new HashSet<String>();
for (final Structures.JobInstanceData jobInstanceData : data.jobInstanceData.values()) {
@@ -156,18 +137,10 @@
@Override
public List<Long> jobOperatorGetJobInstanceIds(final String jobName, final int start, final int count) {
- return jobOperatorGetJobInstanceIds(jobName, null, start, count);
- }
-
- @Override
- public List<Long> jobOperatorGetJobInstanceIds(final String jobName, final String appTag, final int start, final int count) {
final List<Long> out = new LinkedList<Long>();
for (final Structures.JobInstanceData jobInstanceData : data.jobInstanceData.values()) {
if (jobInstanceData.instance.getJobName() != null && jobInstanceData.instance.getJobName().equals(jobName)) {
- final boolean hasTag = appTag != null;
- if (!hasTag || appTag.equals(jobInstanceData.tag)) {
- out.add(jobInstanceData.instance.getInstanceId());
- }
+ out.add(jobInstanceData.instance.getInstanceId());
}
}
@@ -320,12 +293,11 @@
}
@Override
- public JobInstance createJobInstance(final String name, final String apptag, final String jobXml) {
+ public JobInstance createJobInstance(final String name, final String jobXml) {
final JobInstanceImpl jobInstance = new JobInstanceImpl(data.jobInstanceIdGenerator.getAndIncrement(), jobXml);
jobInstance.setJobName(name);
final Structures.JobInstanceData jobInstanceData = new Structures.JobInstanceData();
- jobInstanceData.tag = apptag;
jobInstanceData.instance = jobInstance;
if (maxSize > 0 && data.jobInstanceData.size() >= maxSize) {
synchronized (this) {
@@ -632,8 +604,8 @@
}
@Override
- public JobInstance createSubJobInstance(final String name, final String apptag) {
- return createJobInstance(name, apptag, null);
+ public JobInstance createSubJobInstance(final String name) {
+ return createJobInstance(name, null);
}
@Override
diff --git a/jbatch/src/main/java/org/apache/batchee/container/services/persistence/jdbc/Dictionary.java b/jbatch/src/main/java/org/apache/batchee/container/services/persistence/jdbc/Dictionary.java
index 8e24433..b398c1d 100644
--- a/jbatch/src/main/java/org/apache/batchee/container/services/persistence/jdbc/Dictionary.java
+++ b/jbatch/src/main/java/org/apache/batchee/container/services/persistence/jdbc/Dictionary.java
@@ -37,18 +37,17 @@
String DELETE_CHECKPOINT = DELETE + "%s" + WHERE + "%s = ?";
String DELETE_CHECKPOINT_UNTIL = DELETE + "%s WHERE %s IN (" + SELECT + " DISTINCT t1.%s FROM %s t1 WHERE (SELECT MAX(t0.%s) FROM %s t0 WHERE t0.%s = t1.%s) < ?)";
- String[] JOB_INSTANCE_COLUMNS = { "jobInstanceId", "batchStatus", "exitStatus", "jobName", "jobXml", "latestExecution", "restartOn", "step", "tag" };
- String CREATE_JOB_INSTANCE = CREATE_TABLE + "%s(%s %s %s, %s %s, %s %s, %s %s, %s %s, %s %s, %s %s, %s %s, %s %s, PRIMARY KEY (%s))";
+ String[] JOB_INSTANCE_COLUMNS = { "jobInstanceId", "batchStatus", "exitStatus", "jobName", "jobXml", "latestExecution", "restartOn", "step" };
+ String CREATE_JOB_INSTANCE = CREATE_TABLE + "%s(%s %s %s, %s %s, %s %s, %s %s, %s %s, %s %s, %s %s, %s %s, PRIMARY KEY (%s))";
String JOB_INSTANCE_COUNT_FROM_NAME = SELECT + "count(%s) as jobinstancecount" + FROM + "%s" + WHERE + "%s = ?";
String JOB_INSTANCE_BY_ID = SELECT + "*" + FROM + "%s" + WHERE + "%s = ?";
String JOB_INSTANCE_UPDATE_STATUS = UPDATE + "%s set %s = ?, %s = ?, %s = ?, %s = ?, %s = ?, %s = ?" + WHERE + "%s = ?";
- String JOB_INSTANCE_COUNT = JOB_INSTANCE_COUNT_FROM_NAME + " and %s = ?";
- String JOB_INSTANCE_IDS = SELECT + "%s" + FROM + "%s" + WHERE + "%s = ? and %s = ? order by %s desc";
+ String JOB_INSTANCE_IDS = SELECT + "%s" + FROM + "%s" + WHERE + "%s = ? order by %s desc";
String JOB_INSTANCE_IDS_FROM_NAME = SELECT + "%s" + FROM + "%s" + WHERE + " %s = ? order by %s desc";
String JOB_NAMES = SELECT + "distinct %s" + FROM + "%s" + WHERE + "%s not like '%s'";
String EXTERNAL_JOB_INSTANCE = SELECT + "distinct %s, %s" + FROM + "%s" + WHERE + "%s not like '%s'";
- String JOB_INSTANCE_CREATE = INSERT_INTO + "%s" + "(%s, %s) VALUES(?, ?)";
- String JOB_INSTANCE_CREATE_WITH_JOB_XML = INSERT_INTO + "%s" + "(%s, %s, %s) VALUES(?, ?, ?)";
+ String JOB_INSTANCE_CREATE = INSERT_INTO + "%s" + "(%s) VALUES(?)";
+ String JOB_INSTANCE_CREATE_WITH_JOB_XML = INSERT_INTO + "%s" + "(%s, %s) VALUES(?, ?)";
String DELETE_JOB_INSTANCE = DELETE + "%s" + WHERE + "%s = ?";
String DELETE_JOB_INSTANCE_UNTIL = DELETE + "%s" + WHERE + "%s IN (" + SELECT + "distinct t1.%s" + FROM + "%s t1" + WHERE + "(" + SELECT + "max(t0.%s)" + FROM + "%s t0" +
WHERE + "t0.%s = t1.%s) < ?)";
@@ -110,7 +109,6 @@
private final String countJobInstanceByName;
private final String findJobInstance;
private final String updateJobInstanceStatus;
- private final String countJobInstanceByNameAndTag;
private final String findJoBInstanceIds;
private final String findJobInstanceIdsByName;
private final String findJobNames;
@@ -178,6 +176,7 @@
this.selectCheckpoint = String.format(SQL.SELECT_CHECKPOINT, checkpointColumns[1], checkpointTable, checkpointColumns[4], checkpointColumns[3], checkpointColumns[2]);
this.updateCheckpoint = String.format(SQL.UPDATE_CHECKPOINT, checkpointTable, checkpointColumns[1], checkpointColumns[4], checkpointColumns[3], checkpointColumns[2]);
this.deleteCheckpoint = String.format(SQL.DELETE_CHECKPOINT, checkpointTable, checkpointColumns[4]);
+ // String DELETE_CHECKPOINT_UNTIL = DELETE + "%s WHERE %s IN (" + SELECT + " DISTINCT t1.%s FROM %s t1 WHERE (SELECT MAX(t0.%s) FROM %s t0 WHERE t0.%s = t1.%s) < ?)";
this.deleteCheckpointUntil = String.format(SQL.DELETE_CHECKPOINT_UNTIL, checkpointTable, checkpointColumns[0], checkpointColumns[0], checkpointTable,
jobExecutionColumns[3], jobExecutionTable, checkpointColumns[4], jobExecutionColumns[8]);
}
@@ -192,21 +191,18 @@
jobInstanceColumns[5], database.bigint(),
jobInstanceColumns[6], database.varchar255(),
jobInstanceColumns[7], database.varchar255(),
- jobInstanceColumns[8], database.varchar255(), jobInstanceColumns[0]);
+ jobInstanceColumns[0]);
this.countJobInstanceByName = String.format(SQL.JOB_INSTANCE_COUNT_FROM_NAME, jobInstanceColumns[0], jobInstanceTable, jobInstanceColumns[3]);
this.findJobInstance = String.format(SQL.JOB_INSTANCE_BY_ID, jobInstanceTable, jobInstanceColumns[0]);
this.updateJobInstanceStatus = String.format(SQL.JOB_INSTANCE_UPDATE_STATUS, jobInstanceTable, jobInstanceColumns[1], jobInstanceColumns[2], jobInstanceColumns[5],
jobInstanceColumns[6], jobInstanceColumns[7], jobInstanceColumns[3], jobInstanceColumns[0]);
- this.countJobInstanceByNameAndTag = String.format(SQL.JOB_INSTANCE_COUNT, jobInstanceColumns[0], jobInstanceTable, jobInstanceColumns[6], jobInstanceColumns[8]);
- this.findJoBInstanceIds = String.format(SQL.JOB_INSTANCE_IDS, jobInstanceColumns[0], jobInstanceTable, jobInstanceColumns[3],
- jobInstanceColumns[8], jobInstanceColumns[0]);
+ this.findJoBInstanceIds = String.format(SQL.JOB_INSTANCE_IDS, jobInstanceColumns[0], jobInstanceTable, jobInstanceColumns[3], jobInstanceColumns[0]);
this.findJobInstanceIdsByName = String.format(SQL.JOB_INSTANCE_IDS_FROM_NAME, jobInstanceColumns[0], jobInstanceTable, jobInstanceColumns[3], jobInstanceColumns[0]);
this.findJobNames = String.format(SQL.JOB_NAMES, jobInstanceColumns[3], jobInstanceTable, jobInstanceColumns[3], PartitionedStepBuilder.JOB_ID_SEPARATOR + "%");
this.findExternalJobInstances = String.format(SQL.EXTERNAL_JOB_INSTANCE, jobInstanceColumns[0], jobInstanceColumns[3], jobInstanceTable,
jobInstanceColumns[3], PartitionedStepBuilder.JOB_ID_SEPARATOR + "%");
- this.createJobInstance = String.format(SQL.JOB_INSTANCE_CREATE, jobInstanceTable, jobInstanceColumns[3], jobInstanceColumns[8]);
- this.createJobInstanceWithJobXml = String.format(SQL.JOB_INSTANCE_CREATE_WITH_JOB_XML, jobInstanceTable, jobInstanceColumns[3],
- jobInstanceColumns[8], jobInstanceColumns[4]);
+ this.createJobInstance = String.format(SQL.JOB_INSTANCE_CREATE, jobInstanceTable, jobInstanceColumns[3]);
+ this.createJobInstanceWithJobXml = String.format(SQL.JOB_INSTANCE_CREATE_WITH_JOB_XML, jobInstanceTable, jobInstanceColumns[3], jobInstanceColumns[4]);
this.deleteJobInstance = String.format(SQL.DELETE_JOB_INSTANCE, jobInstanceTable, jobInstanceColumns[0]);
this.deleteJobInstanceUntil = String.format(SQL.DELETE_JOB_INSTANCE_UNTIL, jobInstanceTable, jobInstanceColumns[0], jobInstanceColumns[0], jobInstanceTable,
jobExecutionColumns[3], jobExecutionTable, jobExecutionColumns[8], jobInstanceColumns[0]);
@@ -352,10 +348,6 @@
return updateJobInstanceStatus;
}
- public String getCountJobInstanceByNameAndTag() {
- return countJobInstanceByNameAndTag;
- }
-
public String getFindJoBInstanceIds() {
return findJoBInstanceIds;
}
@@ -520,3 +512,4 @@
return deleteStepExecutionUntil;
}
}
+
diff --git a/jbatch/src/main/java/org/apache/batchee/container/services/persistence/jpa/domain/JobInstanceEntity.java b/jbatch/src/main/java/org/apache/batchee/container/services/persistence/jpa/domain/JobInstanceEntity.java
index c005d5f..e736912 100644
--- a/jbatch/src/main/java/org/apache/batchee/container/services/persistence/jpa/domain/JobInstanceEntity.java
+++ b/jbatch/src/main/java/org/apache/batchee/container/services/persistence/jpa/domain/JobInstanceEntity.java
@@ -30,17 +30,14 @@
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
-
import java.util.List;
@Entity
@NamedQueries({
- @NamedQuery(name = JobInstanceEntity.Queries.COUNT_BY_NAME_AND_TAG, query = "select count(j) from JobInstanceEntity j where j.name = :name and j.tag = :tag"),
@NamedQuery(name = JobInstanceEntity.Queries.COUNT_BY_NAME, query = "select count(j) from JobInstanceEntity j where j.name = :name"),
@NamedQuery(name = JobInstanceEntity.Queries.FIND_FROM_EXECUTION, query = "select j from JobInstanceEntity j inner join j.executions e where e.executionId = :executionId"),
@NamedQuery(name = JobInstanceEntity.Queries.FIND_EXTERNALS, query = "select j from JobInstanceEntity j where j.name not like :pattern"),
@NamedQuery(name = JobInstanceEntity.Queries.FIND_JOBNAMES, query = "select distinct(j.name) from JobInstanceEntity j where j.name not like :pattern"),
- @NamedQuery(name = JobInstanceEntity.Queries.FIND_BY_NAME_AND_TAG, query = "select j from JobInstanceEntity j where j.name = :name and j.tag = :tag"),
@NamedQuery(name = JobInstanceEntity.Queries.FIND_BY_NAME, query = "select j from JobInstanceEntity j where j.name = :name"),
@NamedQuery(name = JobInstanceEntity.Queries.DELETE_BY_INSTANCE_ID, query = "delete from JobInstanceEntity e where e.jobInstanceId = :instanceId"),
@NamedQuery(
@@ -50,10 +47,8 @@
@Table(name=JobInstanceEntity.TABLE_NAME)
public class JobInstanceEntity {
public interface Queries {
- String COUNT_BY_NAME_AND_TAG = "org.apache.batchee.container.services.persistence.jpa.domain.JobInstanceEntity.countByNameAndTag";
String COUNT_BY_NAME = "org.apache.batchee.container.services.persistence.jpa.domain.JobInstanceEntity.countByName";
String FIND_BY_NAME = "org.apache.batchee.container.services.persistence.jpa.domain.JobInstanceEntity.findByName";
- String FIND_BY_NAME_AND_TAG = "org.apache.batchee.container.services.persistence.jpa.domain.JobInstanceEntity.findByNameAndTag";
String FIND_EXTERNALS = "org.apache.batchee.container.services.persistence.jpa.domain.JobInstanceEntity.findExternals";
String FIND_JOBNAMES = "org.apache.batchee.container.services.persistence.jpa.domain.JobInstanceEntity.findJobNames";
String FIND_FROM_EXECUTION = "org.apache.batchee.container.services.persistence.jpa.domain.JobInstanceEntity.findByExecution";
@@ -68,7 +63,6 @@
private long jobInstanceId;
private String name;
- private String tag;
@Lob
private String jobXml;
@@ -96,14 +90,6 @@
this.name = name;
}
- public String getTag() {
- return tag;
- }
-
- public void setTag(final String tag) {
- this.tag = tag;
- }
-
public void setJobXml(final String jobXml) {
this.jobXml = jobXml;
}
diff --git a/jbatch/src/main/java/org/apache/batchee/container/services/security/DefaultSecurityService.java b/jbatch/src/main/java/org/apache/batchee/container/services/security/DefaultSecurityService.java
deleted file mode 100644
index 0ace389..0000000
--- a/jbatch/src/main/java/org/apache/batchee/container/services/security/DefaultSecurityService.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.apache.batchee.container.services.security;
-
-import org.apache.batchee.spi.SecurityService;
-
-import java.util.Properties;
-
-public class DefaultSecurityService implements SecurityService {
- protected String defaultUser;
- protected boolean allowDefault;
-
- @Override
- public boolean isAuthorized(final long instanceId) {
- return isDefaultUserAuthorized();
- }
-
- @Override
- public boolean isAuthorized(final String perm) {
- return isDefaultUserAuthorized();
- }
-
- @Override
- public boolean isAuthorizedJobName(String jobName) {
- return isDefaultUserAuthorized();
- }
-
- @Override
- public String getLoggedUser() {
- return defaultUser;
- }
-
- private boolean isDefaultUserAuthorized() {
- return defaultUser.equals(getLoggedUser()) || allowDefault;
- }
-
- @Override
- public void init(final Properties batchConfig) {
- defaultUser = batchConfig.getProperty("security.user", "jbatch");
- allowDefault = "true".equalsIgnoreCase(batchConfig.getProperty("security.anonymous-allowed", "false"));
- }
-
- @Override
- public String toString() {
- return getClass().getName();
- }
-}
diff --git a/jbatch/src/main/java/org/apache/batchee/container/services/security/JAASSecurityService.java b/jbatch/src/main/java/org/apache/batchee/container/services/security/JAASSecurityService.java
deleted file mode 100644
index b97dea8..0000000
--- a/jbatch/src/main/java/org/apache/batchee/container/services/security/JAASSecurityService.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.apache.batchee.container.services.security;
-
-import javax.security.auth.Subject;
-import java.security.AccessController;
-import java.security.Principal;
-import java.util.Iterator;
-import java.util.Properties;
-
-public class JAASSecurityService extends DefaultSecurityService {
- private static boolean isAuthenticatedAndAuthorized(final String permission) {
- final Subject subject = getSubject();
- if (subject == null) {
- return false;
- }
- for (final BatchRole role : subject.getPrincipals(BatchRole.class)) {
- if (role.getName().equals(permission)) {
- return true;
- }
- }
- return false;
- }
-
- private static Subject getSubject() {
- return Subject.getSubject(AccessController.getContext());
- }
-
- @Override
- public boolean isAuthorized(final long instanceId) {
- return isAuthenticatedAndAuthorized("update");
- }
-
- @Override
- public boolean isAuthorized(final String perm) {
- return isAuthenticatedAndAuthorized(perm);
- }
-
- @Override
- public boolean isAuthorizedJobName(String jobName) {
- return isAuthenticatedAndAuthorized("read");
- }
-
- @Override
- public String getLoggedUser() {
- final Subject subject = getSubject();
- if (subject != null) {
- final Iterator<BatchUser> iterator = subject.getPrincipals(BatchUser.class).iterator();
- if (iterator.hasNext()) {
- return iterator.next().getName();
- }
- }
- return super.getLoggedUser();
- }
-
- @Override
- public void init(final Properties batchConfig) {
- super.init(batchConfig);
- }
-
- public static abstract class BatchPrincipal implements Principal {
- private final String name;
-
- public BatchPrincipal(final String name) {
- this.name = name;
- }
-
- @Override
- public String getName() {
- return name;
- }
- }
-
- public static class BatchUser extends BatchPrincipal {
- public BatchUser(final String name) {
- super(name);
- }
- }
-
- public static class BatchRole extends BatchPrincipal {
- public BatchRole(final String name) {
- super(name);
- }
- }
-}
diff --git a/jbatch/src/main/java/org/apache/batchee/spi/PersistenceManagerService.java b/jbatch/src/main/java/org/apache/batchee/spi/PersistenceManagerService.java
index 0613ea0..38019b1 100755
--- a/jbatch/src/main/java/org/apache/batchee/spi/PersistenceManagerService.java
+++ b/jbatch/src/main/java/org/apache/batchee/spi/PersistenceManagerService.java
@@ -33,7 +33,6 @@
import java.sql.Timestamp;
import java.util.Date;
import java.util.List;
-import java.util.Map;
import java.util.Properties;
import java.util.Set;
@@ -47,19 +46,10 @@
int jobOperatorGetJobInstanceCount(String jobName);
- int jobOperatorGetJobInstanceCount(String jobName, String appTag);
-
Set<String> getJobNames();
- /**
- * @deprecated replaced by {@link #getJobNames()}
- */
- Map<Long, String> jobOperatorGetExternalJobInstanceData();
-
List<Long> jobOperatorGetJobInstanceIds(String jobName, int start, int count);
- List<Long> jobOperatorGetJobInstanceIds(String jobName, String appTag, int start, int count);
-
Timestamp jobOperatorQueryJobExecutionTimestamp(long key, TimestampType timetype);
String jobOperatorQueryJobExecutionBatchStatus(long key);
@@ -92,11 +82,10 @@
* Creates a JobIntance
*
* @param name the job id from job.xml
- * @param apptag the application tag that owns this job
* @param jobXml the resolved job xml
* @return the job instance
*/
- JobInstance createJobInstance(String name, String apptag, String jobXml);
+ JobInstance createJobInstance(String name, String jobXml);
// EXECUTIONINSTANCEDATA
@@ -192,7 +181,7 @@
long getMostRecentExecutionId(long jobInstanceId);
- JobInstance createSubJobInstance(String name, String apptag);
+ JobInstance createSubJobInstance(String name);
RuntimeFlowInSplitExecution createFlowInSplitExecution(JobInstance jobInstance, BatchStatus batchStatus);
diff --git a/jbatch/src/main/java/org/apache/batchee/spi/SecurityService.java b/jbatch/src/main/java/org/apache/batchee/spi/SecurityService.java
deleted file mode 100644
index c32dbdf..0000000
--- a/jbatch/src/main/java/org/apache/batchee/spi/SecurityService.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.apache.batchee.spi;
-
-public interface SecurityService extends BatchService {
- boolean isAuthorized(long instanceId);
- boolean isAuthorized(String perm);
-
- /**
- * @return whether the current user is allowed to see the given jobName
- * @see javax.batch.operations.JobOperator#getJobNames()
- */
- boolean isAuthorizedJobName(String jobName);
-
- /**
- * @return logged user if exists or a default name for anonymous launches
- */
- String getLoggedUser();
-}
diff --git a/jbatch/src/test/java/org/apache/batchee/spi/PersistenceManagerServiceTest.java b/jbatch/src/test/java/org/apache/batchee/spi/PersistenceManagerServiceTest.java
index a281fc7..079565a 100644
--- a/jbatch/src/test/java/org/apache/batchee/spi/PersistenceManagerServiceTest.java
+++ b/jbatch/src/test/java/org/apache/batchee/spi/PersistenceManagerServiceTest.java
@@ -64,7 +64,7 @@
System.out.println("");
for (int i = 0; i < 3; i++) {
- final JobInstance instance = service.createJobInstance("test", "app", "xml");
+ final JobInstance instance = service.createJobInstance("test", "xml");
final RuntimeJobExecution exec = service.createJobExecution(instance, new Properties(), BatchStatus.COMPLETED);
final StepExecutionImpl step = service.createStepExecution(exec.getExecutionId(), new StepContextImpl("step"));
service.createStepStatus(step.getStepExecutionId()).setBatchStatus(BatchStatus.STARTED);
diff --git a/src/site/markdown/configuration.md b/src/site/markdown/configuration.md
index 5d0a679..0f14279 100644
--- a/src/site/markdown/configuration.md
+++ b/src/site/markdown/configuration.md
@@ -55,10 +55,6 @@
Note about JPA persistence service: to stay portable entities are not enhanced. Therefore you need to use a javaagent to do so.
To override a service implementation just set the key name (from the previous list) to a qualified name.
-For instance to use shiro security service create a batchee.properties with:
-
-<pre class="prettyprint linenums"><![CDATA[
-SecurityService = org.apache.batchee.shiro.ShiroSecurityService]]></pre>
Some more configuration is available in batchee.properties:
diff --git a/src/site/markdown/modules.md b/src/site/markdown/modules.md
index 01a6adc..9ba4ae7 100644
--- a/src/site/markdown/modules.md
+++ b/src/site/markdown/modules.md
@@ -32,22 +32,6 @@
Implements JBatch (aka JSR 352). More details on [configuration](./configuration.html) page.
-## Shiro
-### Dependency
-
-<pre class="prettyprint linenums"><![CDATA[
-<dependency>
- <groupId>org.apache.batchee</groupId>
- <artifactId>batchee-shiro</artifactId>
- <version>${batchee.version}</version>
-</dependency>
-]]></pre>
-
-### Goal
-
-A simple integration with Apache Shiro to check permissions when running a batch.
-
-
## Hazelcast
### Dependency
diff --git a/test/src/main/java/org/apache/batchee/test/StepLauncher.java b/test/src/main/java/org/apache/batchee/test/StepLauncher.java
index 86f9bcc..e4f0d90 100644
--- a/test/src/main/java/org/apache/batchee/test/StepLauncher.java
+++ b/test/src/main/java/org/apache/batchee/test/StepLauncher.java
@@ -29,13 +29,12 @@
import org.apache.batchee.jaxb.JSLProperties;
import org.apache.batchee.jaxb.Step;
import org.apache.batchee.spi.PersistenceManagerService;
-import org.apache.batchee.spi.SecurityService;
-import java.util.Properties;
import javax.batch.runtime.BatchStatus;
import javax.batch.runtime.JobExecution;
import javax.batch.runtime.JobInstance;
import javax.batch.runtime.StepExecution;
+import java.util.Properties;
public class StepLauncher {
private static final Properties EMPTY_PROPERTIES = new Properties();
@@ -70,7 +69,7 @@
job.getExecutionElements().add(step);
// contextual data
- final JobInstance jobInstance = persistenceManagerService.createJobInstance(step.getId(), manager.service(SecurityService.class).getLoggedUser(), null);
+ final JobInstance jobInstance = persistenceManagerService.createJobInstance(step.getId(), null);
manager.service(JobStatusManagerService.class).createJobStatus(jobInstance.getInstanceId());
final JobContextImpl jobContext = new JobContextImpl(new JobNavigator(job), EMPTY_JSL_PROPERTIES);