@Test public void testNoExtraction() { Metadata m = null; AccessChecker checker = new AccessChecker(false); boolean ex = false; try { m = getMetadata(false, false); checker.check(m); } catch (AccessPermissionException e) { ex = true; } assertTrue("correct exception with no extraction, no extract for accessibility", ex); ex = false; try { m = getMetadata(false, true); checker.check(m); } catch (AccessPermissionException e) { ex = true; } assertTrue("correct exception with no extraction, no extract for accessibility", ex); }
public void check(Metadata metadata) throws AccessPermissionException { if (!needToCheck) { return; } if ("false".equals(metadata.get(AccessPermissions.EXTRACT_CONTENT))) { if (allowAccessibility) { if ("true".equals(metadata.get(AccessPermissions.EXTRACT_FOR_ACCESSIBILITY))) { return; } throw new AccessPermissionException("Content extraction for accessibility is not allowed."); } throw new AccessPermissionException("Content extraction is not allowed."); } }
AccessChecker implements Serializable { public void check(Metadata metadata) throws AccessPermissionException { if (!needToCheck) { return; } if ("false".equals(metadata.get(AccessPermissions.EXTRACT_CONTENT))) { if (allowAccessibility) { if ("true".equals(metadata.get(AccessPermissions.EXTRACT_FOR_ACCESSIBILITY))) { return; } throw new AccessPermissionException("Content extraction for accessibility is not allowed."); } throw new AccessPermissionException("Content extraction is not allowed."); } } }
AccessChecker implements Serializable { public void check(Metadata metadata) throws AccessPermissionException { if (!needToCheck) { return; } if ("false".equals(metadata.get(AccessPermissions.EXTRACT_CONTENT))) { if (allowAccessibility) { if ("true".equals(metadata.get(AccessPermissions.EXTRACT_FOR_ACCESSIBILITY))) { return; } throw new AccessPermissionException("Content extraction for accessibility is not allowed."); } throw new AccessPermissionException("Content extraction is not allowed."); } } AccessChecker();  AccessChecker(boolean allowExtractionForAccessibility); }
AccessChecker implements Serializable { public void check(Metadata metadata) throws AccessPermissionException { if (!needToCheck) { return; } if ("false".equals(metadata.get(AccessPermissions.EXTRACT_CONTENT))) { if (allowAccessibility) { if ("true".equals(metadata.get(AccessPermissions.EXTRACT_FOR_ACCESSIBILITY))) { return; } throw new AccessPermissionException("Content extraction for accessibility is not allowed."); } throw new AccessPermissionException("Content extraction is not allowed."); } } AccessChecker();  AccessChecker(boolean allowExtractionForAccessibility); void check(Metadata metadata); @Override boolean equals(Object o); @Override int hashCode(); }
AccessChecker implements Serializable { public void check(Metadata metadata) throws AccessPermissionException { if (!needToCheck) { return; } if ("false".equals(metadata.get(AccessPermissions.EXTRACT_CONTENT))) { if (allowAccessibility) { if ("true".equals(metadata.get(AccessPermissions.EXTRACT_FOR_ACCESSIBILITY))) { return; } throw new AccessPermissionException("Content extraction for accessibility is not allowed."); } throw new AccessPermissionException("Content extraction is not allowed."); } } AccessChecker();  AccessChecker(boolean allowExtractionForAccessibility); void check(Metadata metadata); @Override boolean equals(Object o); @Override int hashCode();  }