Revert "Merge branch 'feature/RM-3063_Creation_of_Groups_and_Marks' into 'master'"

This reverts commit ff362d5213, reversing
changes made to 878b423b305633aac5ca7c80cec3ee3e1c148cfe.

Conflicts:
	rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/test/util/ExceptionUtils.java
	rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/test/util/ExceptionUtilsUsageExamplesUnitTest.java
	rm-enterprise/rm-enterprise-repo/src/main/amp/config/alfresco/templates/webscripts/org/alfresco/rma/caveat/caveatgroup.delete.json.ftl
	rm-enterprise/rm-enterprise-repo/src/main/amp/config/alfresco/templates/webscripts/org/alfresco/rma/caveat/caveatgroup.post.json.ftl
	rm-enterprise/rm-enterprise-repo/src/main/amp/config/alfresco/templates/webscripts/org/alfresco/rma/caveat/caveatgroup.put.json.ftl
	rm-enterprise/rm-enterprise-repo/src/main/amp/config/alfresco/templates/webscripts/org/alfresco/rma/caveat/caveatmark.delete.json.ftl
	rm-enterprise/rm-enterprise-repo/src/main/amp/config/alfresco/templates/webscripts/org/alfresco/rma/caveat/caveatmark.post.json.ftl
	rm-enterprise/rm-enterprise-repo/src/main/amp/config/alfresco/templates/webscripts/org/alfresco/rma/caveat/caveatmark.put.json.ftl
	rm-enterprise/rm-enterprise-repo/src/main/java/org/alfresco/module/org_alfresco_module_rm/caveat/model/CaveatModel.java
	rm-enterprise/rm-enterprise-repo/src/main/java/org/alfresco/module/org_alfresco_module_rm/caveat/scheme/CaveatGroup.java
	rm-enterprise/rm-enterprise-repo/src/main/java/org/alfresco/module/org_alfresco_module_rm/caveat/scheme/CaveatSchemeService.java
	rm-enterprise/rm-enterprise-repo/src/main/java/org/alfresco/module/org_alfresco_module_rm/script/caveat/CaveatBase.java
	rm-enterprise/rm-enterprise-repo/src/main/java/org/alfresco/module/org_alfresco_module_rm/script/caveat/CaveatGroupDelete.java
	rm-enterprise/rm-enterprise-repo/src/main/java/org/alfresco/module/org_alfresco_module_rm/script/caveat/CaveatGroupPost.java
	rm-enterprise/rm-enterprise-repo/src/main/java/org/alfresco/module/org_alfresco_module_rm/script/caveat/CaveatGroupPut.java
	rm-enterprise/rm-enterprise-repo/src/main/java/org/alfresco/module/org_alfresco_module_rm/script/caveat/CaveatMarkDelete.java
	rm-enterprise/rm-enterprise-repo/src/main/java/org/alfresco/module/org_alfresco_module_rm/script/caveat/CaveatMarkPost.java
	rm-enterprise/rm-enterprise-repo/src/main/java/org/alfresco/module/org_alfresco_module_rm/script/caveat/CaveatMarkPut.java
	rm-enterprise/rm-enterprise-repo/src/unit-test/java/org/alfresco/module/org_alfresco_module_rm/script/caveat/CaveatGroupDeleteUnitTest.java
	rm-enterprise/rm-enterprise-repo/src/unit-test/java/org/alfresco/module/org_alfresco_module_rm/script/caveat/CaveatGroupPostUnitTest.java
	rm-enterprise/rm-enterprise-repo/src/unit-test/java/org/alfresco/module/org_alfresco_module_rm/script/caveat/CaveatGroupPutUnitTest.java
	rm-enterprise/rm-enterprise-repo/src/unit-test/java/org/alfresco/module/org_alfresco_module_rm/script/caveat/CaveatGroupsGetUnitTest.java
	rm-enterprise/rm-enterprise-repo/src/unit-test/java/org/alfresco/module/org_alfresco_module_rm/script/caveat/CaveatMarkPostUnitTest.java
	rm-enterprise/rm-enterprise-repo/src/unit-test/java/org/alfresco/module/org_alfresco_module_rm/script/caveat/CaveatTestUtils.java
This commit is contained in:
Tom Page
2016-03-08 10:17:31 +00:00
parent f1ac097a2b
commit 4ada2b5bf0
2 changed files with 16 additions and 102 deletions

View File

@@ -1,18 +1,17 @@
package org.alfresco.module.org_alfresco_module_rm.test.util; package org.alfresco.module.org_alfresco_module_rm.test.util;
/* /*
* #%L * #%L
* Alfresco Records Management Module * Alfresco Records Management Module
* %% * %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited * Copyright (C) 2005 - 2016 Alfresco Software Limited
* %% * %%
* This file is part of the Alfresco software. * This file is part of the Alfresco software.
* *
* If the software was purchased under a paid Alfresco license, the terms of * If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is * the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms: * provided under the following open source license terms:
* *
* Alfresco is free software: you can redistribute it and/or modify * Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by * 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 * the Free Software Foundation, either version 3 of the License, or
@@ -24,7 +23,7 @@ package org.alfresco.module.org_alfresco_module_rm.test.util;
* GNU Lesser General Public License for more details. * GNU Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public License * You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. * along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L% * #L%
*/ */
@@ -174,73 +173,5 @@ public class ExceptionUtils
{ {
throw new UnexpectedThrowableException(expected, thrownByCode); throw new UnexpectedThrowableException(expected, thrownByCode);
} }
}
/**
* Helper method to work around the difficulties of working with lambdas and checked exceptions.
* Use as follows:
* <pre>
* expectedException(WebScriptException.class, () ->
* // "Wash away" any checked exceptions in the inner code block.
* smuggleCheckedExceptions( () -> methodThrowsException())
* );
* </pre>
* @param code a block of code which is declared to throw a checked exception.
* @param <R> the return type of the block of code.
* @param <T> the type of the checked exception.
* @return the value returned by the block of code.
* @throws SmuggledException if the code block threw an exception of type T.
*/
public static <R, T extends Exception> R smuggleCheckedExceptions(final ThrowingSupplier<R, T> code)
{
try
{
return code.get();
}
catch (RuntimeException e)
{
throw e;
}
catch (Exception e)
{
throw new SmuggledException(e);
}
} }
}
/**
* Equivalent to `java.util.function.Supplier` but its method declares that it
* throws checked exceptions.
*
* @param <R> The result type of this supplier.
* @param <T> The exception type declared to be thrown by this supplier.
*/
@FunctionalInterface
public interface ThrowingSupplier<R, T extends Exception>
{
/** Gets the value */
R get() throws T;
}
/**
* A wrapper for checked exceptions so that they can be handled as unchecked exceptions, namely by not requiring
* try/catch blocks etc.
* <p/>
* This type is expected to be most useful when handling Java 8 lambdas containing code which throws checked
* exceptions.
*/
public static class SmuggledException extends RuntimeException
{
private static final long serialVersionUID = -606404592461576013L;
private final Exception e;
public SmuggledException(Exception e)
{
this.e = e;
}
public Exception getCheckedException()
{
return this.e;
}
}
}

View File

@@ -2,11 +2,11 @@
package org.alfresco.module.org_alfresco_module_rm.test.util; package org.alfresco.module.org_alfresco_module_rm.test.util;
/* /*
* #%L * #%L
* Alfresco Records Management Module * Alfresco Records Management Module
* %% * %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited * Copyright (C) 2005 - 2016 Alfresco Software Limited
* %% * %%
* This file is part of the Alfresco software. * This file is part of the Alfresco software.
* *
* If the software was purchased under a paid Alfresco license, the terms of * If the software was purchased under a paid Alfresco license, the terms of
@@ -24,20 +24,18 @@ package org.alfresco.module.org_alfresco_module_rm.test.util;
* GNU Lesser General Public License for more details. * GNU Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public License * You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. * along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L% * #L%
*/ */
import org.alfresco.module.org_alfresco_module_rm.test.util.ExceptionUtils.MissingThrowableException; import org.alfresco.module.org_alfresco_module_rm.test.util.ExceptionUtils.MissingThrowableException;
import org.alfresco.module.org_alfresco_module_rm.test.util.ExceptionUtils.SmuggledException;
import org.alfresco.module.org_alfresco_module_rm.test.util.ExceptionUtils.UnexpectedThrowableException; import org.alfresco.module.org_alfresco_module_rm.test.util.ExceptionUtils.UnexpectedThrowableException;
import org.junit.Test; import org.junit.Test;
import java.io.IOException; import java.io.IOException;
import static org.alfresco.module.org_alfresco_module_rm.test.util.ExceptionUtils.expectedException; import static org.alfresco.module.org_alfresco_module_rm.test.util.ExceptionUtils.expectedException;
import static org.alfresco.module.org_alfresco_module_rm.test.util.ExceptionUtils.smuggleCheckedExceptions;
import static org.junit.Assert.*; import static org.junit.Assert.*;
/** /**
@@ -112,20 +110,5 @@ public class ExceptionUtilsUsageExamplesUnitTest
onlySideEffectsHere("hello"); onlySideEffectsHere("hello");
return null; return null;
}); });
}
// If you use lambdas that throw checked exceptions, the standard Java 8 types are insufficient.
@Test public void smuggleCheckedExceptionsShouldHideCheckedExceptionsInAnUncheckedException()
{
SmuggledException e = expectedException(SmuggledException.class, () -> smuggleCheckedExceptions(() -> methodThrowsException()));
assertEquals(Exception.class, e.getCheckedException().getClass());
assertEquals("Checked", e.getCheckedException().getMessage());
} }
}
/** This method declares that it throws `java.lang.Exception`. */
private Object methodThrowsException() throws Exception
{
throw new Exception("Checked");
}
}