@Test public void givenGuidWhenXmlNotXMLThenReturnNotXsdValid() throws Exception { final String str = "<invalidTag>This is an invalid Tag</invalidTag>"; final InputStream is = new ByteArrayInputStream(str.getBytes()); when(workspaceClient.getObject(any(), any())) .thenReturn(Response.status(Status.OK).entity(is).build()); when(handlerIO.getInputStreamFromWorkspace(any())).thenReturn(is); final CheckSedaValidationStatus status = utils.checkSedaValidation(params, new ItemStatus()); assertTrue(CheckSedaValidationStatus.NOT_XSD_VALID.equals(status)); }
public CheckSedaValidationStatus checkSedaValidation(WorkerParameters params, ItemStatus itemStatus) { ParametersChecker.checkNullOrEmptyParameters(params); InputStream input = null; try { input = checkExistenceManifest(); if (checkMultiManifest()) { return CheckSedaValidationStatus.MORE_THAN_ONE_MANIFEST; } if (!checkFolderContentNumber()) { return CheckSedaValidationStatus.MORE_THAN_ONE_FOLDER_CONTENT; } ValidationXsdUtils.getInstance().checkWithXSD(input, SEDA_VALIDATION_FILE); return CheckSedaValidationStatus.VALID; } catch (ProcessingException | IOException e) { LOGGER.error("Manifest xml file is not valid with the XSD", e); return CheckSedaValidationStatus.NO_FILE; } catch (final XMLStreamException e) { LOGGER.error("This is not an xml file", e); return CheckSedaValidationStatus.NOT_XML_FILE; } catch (final SAXException e) { LOGGER.error("The xml file is not conform with XSD Schema : ", e); if (e.getCause() == null) { JsonNode errorNode = JsonHandler.createObjectNode().put(SedaConstants.EV_DET_TECH_DATA, e.getMessage()); itemStatus.setEvDetailData(errorNode.toString()); return CheckSedaValidationStatus.NOT_XSD_VALID; } return CheckSedaValidationStatus.NOT_XML_FILE; } finally { IOUtils.closeQuietly(input); } }
SedaUtils { public CheckSedaValidationStatus checkSedaValidation(WorkerParameters params, ItemStatus itemStatus) { ParametersChecker.checkNullOrEmptyParameters(params); InputStream input = null; try { input = checkExistenceManifest(); if (checkMultiManifest()) { return CheckSedaValidationStatus.MORE_THAN_ONE_MANIFEST; } if (!checkFolderContentNumber()) { return CheckSedaValidationStatus.MORE_THAN_ONE_FOLDER_CONTENT; } ValidationXsdUtils.getInstance().checkWithXSD(input, SEDA_VALIDATION_FILE); return CheckSedaValidationStatus.VALID; } catch (ProcessingException | IOException e) { LOGGER.error("Manifest xml file is not valid with the XSD", e); return CheckSedaValidationStatus.NO_FILE; } catch (final XMLStreamException e) { LOGGER.error("This is not an xml file", e); return CheckSedaValidationStatus.NOT_XML_FILE; } catch (final SAXException e) { LOGGER.error("The xml file is not conform with XSD Schema : ", e); if (e.getCause() == null) { JsonNode errorNode = JsonHandler.createObjectNode().put(SedaConstants.EV_DET_TECH_DATA, e.getMessage()); itemStatus.setEvDetailData(errorNode.toString()); return CheckSedaValidationStatus.NOT_XSD_VALID; } return CheckSedaValidationStatus.NOT_XML_FILE; } finally { IOUtils.closeQuietly(input); } } }
SedaUtils { public CheckSedaValidationStatus checkSedaValidation(WorkerParameters params, ItemStatus itemStatus) { ParametersChecker.checkNullOrEmptyParameters(params); InputStream input = null; try { input = checkExistenceManifest(); if (checkMultiManifest()) { return CheckSedaValidationStatus.MORE_THAN_ONE_MANIFEST; } if (!checkFolderContentNumber()) { return CheckSedaValidationStatus.MORE_THAN_ONE_FOLDER_CONTENT; } ValidationXsdUtils.getInstance().checkWithXSD(input, SEDA_VALIDATION_FILE); return CheckSedaValidationStatus.VALID; } catch (ProcessingException | IOException e) { LOGGER.error("Manifest xml file is not valid with the XSD", e); return CheckSedaValidationStatus.NO_FILE; } catch (final XMLStreamException e) { LOGGER.error("This is not an xml file", e); return CheckSedaValidationStatus.NOT_XML_FILE; } catch (final SAXException e) { LOGGER.error("The xml file is not conform with XSD Schema : ", e); if (e.getCause() == null) { JsonNode errorNode = JsonHandler.createObjectNode().put(SedaConstants.EV_DET_TECH_DATA, e.getMessage()); itemStatus.setEvDetailData(errorNode.toString()); return CheckSedaValidationStatus.NOT_XSD_VALID; } return CheckSedaValidationStatus.NOT_XML_FILE; } finally { IOUtils.closeQuietly(input); } } protected  SedaUtils(HandlerIO handlerIO); }
SedaUtils { public CheckSedaValidationStatus checkSedaValidation(WorkerParameters params, ItemStatus itemStatus) { ParametersChecker.checkNullOrEmptyParameters(params); InputStream input = null; try { input = checkExistenceManifest(); if (checkMultiManifest()) { return CheckSedaValidationStatus.MORE_THAN_ONE_MANIFEST; } if (!checkFolderContentNumber()) { return CheckSedaValidationStatus.MORE_THAN_ONE_FOLDER_CONTENT; } ValidationXsdUtils.getInstance().checkWithXSD(input, SEDA_VALIDATION_FILE); return CheckSedaValidationStatus.VALID; } catch (ProcessingException | IOException e) { LOGGER.error("Manifest xml file is not valid with the XSD", e); return CheckSedaValidationStatus.NO_FILE; } catch (final XMLStreamException e) { LOGGER.error("This is not an xml file", e); return CheckSedaValidationStatus.NOT_XML_FILE; } catch (final SAXException e) { LOGGER.error("The xml file is not conform with XSD Schema : ", e); if (e.getCause() == null) { JsonNode errorNode = JsonHandler.createObjectNode().put(SedaConstants.EV_DET_TECH_DATA, e.getMessage()); itemStatus.setEvDetailData(errorNode.toString()); return CheckSedaValidationStatus.NOT_XSD_VALID; } return CheckSedaValidationStatus.NOT_XML_FILE; } finally { IOUtils.closeQuietly(input); } } protected  SedaUtils(HandlerIO handlerIO); Map<String, String> getBinaryDataObjectIdToGuid(); Map<String, List<String>> getObjectGroupIdToBinaryDataObjectId(); Map<String, String> getObjectGroupIdToGuid(); Map<String, String> getUnitIdToGuid(); Map<String, String> getBinaryDataObjectIdToGroupId(); Map<String, String> getUnitIdToGroupId(); Map<String, Object> getMandatoryValues(WorkerParameters params); CheckSedaValidationStatus checkSedaValidation(WorkerParameters params, ItemStatus itemStatus); ExtractUriResponse getAllDigitalObjectUriFromManifest(); Map<String, Map<String, String>> checkSupportedDataObjectVersion(WorkerParameters params); SedaUtilInfo getDataObjectInfo(XMLEventReader evenReader); Map<String, List<DataObjectInfo>> manifestVersionList(XMLEventReader evenReader); Map<String, Map<String, String>> compareVersionList(XMLEventReader eventReader); long computeTotalSizeOfObjectsInManifest(WorkerParameters params); }
SedaUtils { public CheckSedaValidationStatus checkSedaValidation(WorkerParameters params, ItemStatus itemStatus) { ParametersChecker.checkNullOrEmptyParameters(params); InputStream input = null; try { input = checkExistenceManifest(); if (checkMultiManifest()) { return CheckSedaValidationStatus.MORE_THAN_ONE_MANIFEST; } if (!checkFolderContentNumber()) { return CheckSedaValidationStatus.MORE_THAN_ONE_FOLDER_CONTENT; } ValidationXsdUtils.getInstance().checkWithXSD(input, SEDA_VALIDATION_FILE); return CheckSedaValidationStatus.VALID; } catch (ProcessingException | IOException e) { LOGGER.error("Manifest xml file is not valid with the XSD", e); return CheckSedaValidationStatus.NO_FILE; } catch (final XMLStreamException e) { LOGGER.error("This is not an xml file", e); return CheckSedaValidationStatus.NOT_XML_FILE; } catch (final SAXException e) { LOGGER.error("The xml file is not conform with XSD Schema : ", e); if (e.getCause() == null) { JsonNode errorNode = JsonHandler.createObjectNode().put(SedaConstants.EV_DET_TECH_DATA, e.getMessage()); itemStatus.setEvDetailData(errorNode.toString()); return CheckSedaValidationStatus.NOT_XSD_VALID; } return CheckSedaValidationStatus.NOT_XML_FILE; } finally { IOUtils.closeQuietly(input); } } protected  SedaUtils(HandlerIO handlerIO); Map<String, String> getBinaryDataObjectIdToGuid(); Map<String, List<String>> getObjectGroupIdToBinaryDataObjectId(); Map<String, String> getObjectGroupIdToGuid(); Map<String, String> getUnitIdToGuid(); Map<String, String> getBinaryDataObjectIdToGroupId(); Map<String, String> getUnitIdToGroupId(); Map<String, Object> getMandatoryValues(WorkerParameters params); CheckSedaValidationStatus checkSedaValidation(WorkerParameters params, ItemStatus itemStatus); ExtractUriResponse getAllDigitalObjectUriFromManifest(); Map<String, Map<String, String>> checkSupportedDataObjectVersion(WorkerParameters params); SedaUtilInfo getDataObjectInfo(XMLEventReader evenReader); Map<String, List<DataObjectInfo>> manifestVersionList(XMLEventReader evenReader); Map<String, Map<String, String>> compareVersionList(XMLEventReader eventReader); long computeTotalSizeOfObjectsInManifest(WorkerParameters params); static final String NAMESPACE_URI; static final String XSI_URI; static final String NB_AU_EXISTING; static final String INVALID_DATAOBJECT_VERSION; static final String VALID_DATAOBJECT_VERSION; static final String SEDA_XSD_VERSION; }