automated formatting

changes most likely method order
This commit is contained in:
Mustapha Zorgati 2020-01-26 17:40:04 +01:00
parent b86f3e5b65
commit 7477092a69
11 changed files with 72 additions and 74 deletions

View File

@ -31,6 +31,17 @@ public class AbstractAccTest {
private static DataSource dataSource; private static DataSource dataSource;
private static String schemaName = null; private static String schemaName = null;
static {
String userHomeDirectroy = System.getProperty("user.home");
String propertiesFileName = userHomeDirectroy + "/taskanaUnitTest.properties";
File f = new File(propertiesFileName);
if (f.exists() && !f.isDirectory()) {
dataSource = createDataSourceFromProperties(propertiesFileName);
} else {
dataSource = createDefaultDataSource();
}
}
protected AbstractAccTest() { protected AbstractAccTest() {
// not called // not called
} }
@ -56,17 +67,6 @@ public class AbstractAccTest {
writer.generateTestData(dataSource); writer.generateTestData(dataSource);
} }
static {
String userHomeDirectroy = System.getProperty("user.home");
String propertiesFileName = userHomeDirectroy + "/taskanaUnitTest.properties";
File f = new File(propertiesFileName);
if (f.exists() && !f.isDirectory()) {
dataSource = createDataSourceFromProperties(propertiesFileName);
} else {
dataSource = createDefaultDataSource();
}
}
public static DataSource getDataSource() { public static DataSource getDataSource() {
if (dataSource == null) { if (dataSource == null) {
throw new RuntimeException("Datasource should be already initialized"); throw new RuntimeException("Datasource should be already initialized");

View File

@ -34,8 +34,10 @@ public class TaskanaEngineConfigurationTest extends AbstractAccTest {
resetDb("SOMECUSTOMSCHEMANAME"); resetDb("SOMECUSTOMSCHEMANAME");
long count = getHistoryService().createHistoryQuery().workbasketKeyIn("wbKey1").count(); long count = getHistoryService().createHistoryQuery().workbasketKeyIn("wbKey1").count();
assertEquals(0, count); assertEquals(0, count);
getHistoryService().create( getHistoryService()
AbstractAccTest.createHistoryEvent("wbKey1", "taskId1", "type1", "Some comment", "wbKey2")); .create(
AbstractAccTest.createHistoryEvent(
"wbKey1", "taskId1", "type1", "Some comment", "wbKey2"));
count = getHistoryService().createHistoryQuery().workbasketKeyIn("wbKey1").count(); count = getHistoryService().createHistoryQuery().workbasketKeyIn("wbKey1").count();
assertEquals(1, count); assertEquals(1, count);
} }

View File

@ -167,10 +167,10 @@ public class TaskHistoryEventControllerRestDocumentation {
fieldWithPath("taskHistoryEvents[].newData") fieldWithPath("taskHistoryEvents[].newData")
.description(taskHistoryEventFieldDescriptionsMap.get("newData")), .description(taskHistoryEventFieldDescriptionsMap.get("newData")),
fieldWithPath("_links.self.href").ignored(), fieldWithPath("_links.self.href").ignored(),
fieldWithPath("page.size").ignored(), fieldWithPath("page.size").ignored(),
fieldWithPath("page.totalElements").ignored(), fieldWithPath("page.totalElements").ignored(),
fieldWithPath("page.totalPages").ignored(), fieldWithPath("page.totalPages").ignored(),
fieldWithPath("page.number").ignored() fieldWithPath("page.number").ignored()
}; };
} }

View File

@ -76,7 +76,6 @@ public interface InternalTaskanaEngine {
*/ */
TaskRoutingManager getTaskRoutingManager(); TaskRoutingManager getTaskRoutingManager();
/** /**
* This method is supposed to skip further permission checks if we are already in a secured * This method is supposed to skip further permission checks if we are already in a secured
* environment. With great power comes great responsibility. * environment. With great power comes great responsibility.

View File

@ -332,31 +332,6 @@ public class TaskanaEngineImpl implements TaskanaEngine {
} }
} }
@Override
public <T> T runAsAdmin(Supplier<T> supplier) {
Subject subject = Subject.getSubject(AccessController.getContext());
if (subject == null) {
// dont add authorisation if none is available.
return supplier.get();
}
Set<Principal> principalsCopy = new HashSet<>(subject.getPrincipals());
Set<Object> privateCredentialsCopy = new HashSet<>(subject.getPrivateCredentials());
Set<Object> publicCredentialsCopy = new HashSet<>(subject.getPublicCredentials());
String adminName =
this.getEngine().getConfiguration().getRoleMap().get(TaskanaRole.ADMIN).stream()
.findFirst()
.orElseThrow(() -> new TaskanaRuntimeException("There is no admin configured"));
principalsCopy.add(new GroupPrincipal(adminName));
Subject subject1 =
new Subject(true, principalsCopy, privateCredentialsCopy, publicCredentialsCopy);
return Subject.doAs(subject1, (PrivilegedAction<T>) supplier::get);
}
@Override @Override
public void returnConnection() { public void returnConnection() {
if (mode != ConnectionManagementMode.EXPLICIT) { if (mode != ConnectionManagementMode.EXPLICIT) {
@ -421,5 +396,30 @@ public class TaskanaEngineImpl implements TaskanaEngine {
public TaskRoutingManager getTaskRoutingManager() { public TaskRoutingManager getTaskRoutingManager() {
return taskRoutingManager; return taskRoutingManager;
} }
@Override
public <T> T runAsAdmin(Supplier<T> supplier) {
Subject subject = Subject.getSubject(AccessController.getContext());
if (subject == null) {
// dont add authorisation if none is available.
return supplier.get();
}
Set<Principal> principalsCopy = new HashSet<>(subject.getPrincipals());
Set<Object> privateCredentialsCopy = new HashSet<>(subject.getPrivateCredentials());
Set<Object> publicCredentialsCopy = new HashSet<>(subject.getPublicCredentials());
String adminName =
this.getEngine().getConfiguration().getRoleMap().get(TaskanaRole.ADMIN).stream()
.findFirst()
.orElseThrow(() -> new TaskanaRuntimeException("There is no admin configured"));
principalsCopy.add(new GroupPrincipal(adminName));
Subject subject1 =
new Subject(true, principalsCopy, privateCredentialsCopy, publicCredentialsCopy);
return Subject.doAs(subject1, (PrivilegedAction<T>) supplier::get);
}
} }
} }

View File

@ -108,24 +108,6 @@ public class ScheduledJob {
this.retryCount = retryCount; this.retryCount = retryCount;
} }
/**
* This enum tracks the state of a job.
*
* @author bbr
*/
public enum State {
READY,
FAILED
}
/** This enum controls the type of a job. */
public enum Type {
CLASSIFICATIONCHANGEDJOB,
UPDATETASKSJOB,
TASKCLEANUPJOB,
WORKBASKETCLEANUPJOB;
}
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash( return Objects.hash(
@ -177,4 +159,22 @@ public class ScheduledJob {
+ arguments + arguments
+ "]"; + "]";
} }
/**
* This enum tracks the state of a job.
*
* @author bbr
*/
public enum State {
READY,
FAILED
}
/** This enum controls the type of a job. */
public enum Type {
CLASSIFICATIONCHANGEDJOB,
UPDATETASKSJOB,
TASKCLEANUPJOB,
WORKBASKETCLEANUPJOB;
}
} }

View File

@ -31,9 +31,7 @@ public interface JobMapper {
+ "</choose>" + "</choose>"
+ ", #{job.priority}, #{job.created}, #{job.due}, #{job.state}, #{job.lockedBy}, #{job.lockExpires}, #{job.type}, #{job.retryCount}, #{job.arguments,javaType=java.util.Map,typeHandler=pro.taskana.impl.persistence.MapTypeHandler} )" + ", #{job.priority}, #{job.created}, #{job.due}, #{job.state}, #{job.lockedBy}, #{job.lockExpires}, #{job.type}, #{job.retryCount}, #{job.arguments,javaType=java.util.Map,typeHandler=pro.taskana.impl.persistence.MapTypeHandler} )"
+ "</script>") + "</script>")
@Results( @Results(value = {@Result(property = "jobId", column = "JOB_ID")})
value = {
@Result(property = "jobId", column = "JOB_ID")})
Integer insertJob(@Param("job") ScheduledJob job); Integer insertJob(@Param("job") ScheduledJob job);
@Select( @Select(

View File

@ -24,8 +24,6 @@ public final class TaskanaEngineTestConfiguration {
private static DataSource dataSource; private static DataSource dataSource;
private static String schemaName = null; private static String schemaName = null;
private TaskanaEngineTestConfiguration() {}
static { static {
String userHomeDirectroy = System.getProperty("user.home"); String userHomeDirectroy = System.getProperty("user.home");
String propertiesFileName = userHomeDirectroy + "/taskanaUnitTest.properties"; String propertiesFileName = userHomeDirectroy + "/taskanaUnitTest.properties";
@ -37,6 +35,8 @@ public final class TaskanaEngineTestConfiguration {
} }
} }
private TaskanaEngineTestConfiguration() {}
/** /**
* returns the Datasource used for Junit test. If the file {user.home}/taskanaUnitTest.properties * returns the Datasource used for Junit test. If the file {user.home}/taskanaUnitTest.properties
* is present, the Datasource is created according to the properties jdbcDriver, jdbcUrl, * is present, the Datasource is created according to the properties jdbcDriver, jdbcUrl,

View File

@ -105,10 +105,10 @@ class WorkbasketAccessItemControllerRestDocumentation extends BaseRestDocumentat
.description(accessItemFieldDescriptionsMap.get("accessItems.permCustom12")), .description(accessItemFieldDescriptionsMap.get("accessItems.permCustom12")),
fieldWithPath("_links.self.href") fieldWithPath("_links.self.href")
.description(accessItemFieldDescriptionsMap.get("_links.self.href")), .description(accessItemFieldDescriptionsMap.get("_links.self.href")),
fieldWithPath("page.size").ignored(), fieldWithPath("page.size").ignored(),
fieldWithPath("page.totalElements").ignored(), fieldWithPath("page.totalElements").ignored(),
fieldWithPath("page.totalPages").ignored(), fieldWithPath("page.totalPages").ignored(),
fieldWithPath("page.number").ignored() fieldWithPath("page.number").ignored()
}; };
} }

View File

@ -109,9 +109,8 @@ class WorkbasketControllerIntTest {
} }
/** /**
* Bug Ticket TSK-1029. * Bug Ticket TSK-1029. Businessadmin is allowed to delete any workbasket ticket without user
* Businessadmin is allowed to delete any workbasket ticket without user related access * related access restrictions.
* restrictions.
*/ */
@Test @Test
void testDeleteWorkbasketAsBusinessAdminWithoutExplicitReadPermission() { void testDeleteWorkbasketAsBusinessAdminWithoutExplicitReadPermission() {