private void checkApiControllerExists(Map<String, byte[]> zipContent, Properties pageProperties) throws SInvalidPageZipInconsistentException, SInvalidPageZipMissingAPropertyException { final Set<String> entrySet = zipContent.keySet(); final String declaredApis = pageProperties.getProperty(API_EXTENSIONS); if (declaredApis == null || declaredApis.isEmpty()) { throw new SInvalidPageZipMissingAPropertyException(API_EXTENSIONS); } final String[] apis = declaredApis.split(","); for (final String api : apis) { final String classFileName = pageProperties.getProperty(api.trim() + "." + CLASS_FILENAME); if (classFileName == null || classFileName.isEmpty()) { throw new SInvalidPageZipMissingAPropertyException(api.trim() + "." + CLASS_FILENAME); } if (!entrySet.contains(classFileName.trim())) { throw new SInvalidPageZipInconsistentException(String.format("RestAPIController %s has not been found in archive.", classFileName.trim())); } } }
private void checkApiControllerExists(Map<String, byte[]> zipContent, Properties pageProperties) throws SInvalidPageZipInconsistentException, SInvalidPageZipMissingAPropertyException { final Set<String> entrySet = zipContent.keySet(); final String declaredApis = pageProperties.getProperty(API_EXTENSIONS); if (declaredApis == null || declaredApis.isEmpty()) { throw new SInvalidPageZipMissingAPropertyException(API_EXTENSIONS); } final String[] apis = declaredApis.split(","); for (final String api : apis) { final String classFileName = pageProperties.getProperty(api.trim() + "." + CLASS_FILENAME); if (classFileName == null || classFileName.isEmpty()) { throw new SInvalidPageZipMissingAPropertyException(api.trim() + "." + CLASS_FILENAME); } if (!entrySet.contains(classFileName.trim())) { throw new SInvalidPageZipInconsistentException(String.format("RestAPIController %s has not been found in archive.", classFileName.trim())); } } }
Properties readPageZip(final byte[] content, final boolean provided) throws SInvalidPageZipMissingIndexException, SInvalidPageZipMissingAPropertyException, SInvalidPageZipInconsistentException, SInvalidPageZipMissingPropertiesException, SInvalidPageTokenException { final Properties pageProperties; if (content == null) { throw new SInvalidPageZipInconsistentException("Content can't be null"); } try { final Map<String, byte[]> zipContent = unzip(content); pageProperties = helper.loadPageProperties(zipContent); if (isAnAPIExtension(pageProperties)) { checkApiControllerExists(zipContent, pageProperties); } else { checkZipContainsRequiredEntries(zipContent); } checkPageNameIsValid(pageProperties.getProperty(PageService.PROPERTIES_NAME), provided); checkPageDisplayNameIsValid(pageProperties.getProperty(PageService.PROPERTIES_DISPLAY_NAME)); } catch (final IOException e) { throw new SInvalidPageZipInconsistentException("Error while reading zip file", e); } return pageProperties; }
Properties readPageZip(final byte[] content, final boolean provided) throws SInvalidPageZipMissingIndexException, SInvalidPageZipMissingAPropertyException, SInvalidPageZipInconsistentException, SInvalidPageZipMissingPropertiesException, SInvalidPageTokenException { final Properties pageProperties; if (content == null) { throw new SInvalidPageZipInconsistentException("Content can't be null"); } try { final Map<String, byte[]> zipContent = unzip(content); pageProperties = helper.loadPageProperties(zipContent); if (isAnAPIExtension(pageProperties)) { checkApiControllerExists(zipContent, pageProperties); } else { checkZipContainsRequiredEntries(zipContent); } checkPageNameIsValid(pageProperties.getProperty(PageService.PROPERTIES_NAME), provided); checkPageDisplayNameIsValid(pageProperties.getProperty(PageService.PROPERTIES_DISPLAY_NAME)); } catch (final IOException e) { throw new SInvalidPageZipInconsistentException("Error while reading zip file", e); } return pageProperties; }
@Override public SPage addPage(final SPage page, final byte[] content) throws SObjectCreationException, SObjectAlreadyExistsException, SInvalidPageZipException, SInvalidPageTokenException { try { checkZipContainsRequiredEntries(unzip(content)); checkPageNameIsValid(page.getName(), page.isProvided()); checkPageDisplayNameIsValid(page.getDisplayName()); return insertPage(page, content); } catch (final IOException e) { throw new SInvalidPageZipInconsistentException("Error while reading zip file", e); } }
@Override public SPage addPage(final SPage page, final byte[] content) throws SObjectCreationException, SObjectAlreadyExistsException, SInvalidPageZipException, SInvalidPageTokenException { try { checkZipContainsRequiredEntries(unzip(content)); checkPageNameIsValid(page.getName(), page.isProvided()); checkPageDisplayNameIsValid(page.getDisplayName()); return insertPage(page, content); } catch (final IOException e) { throw new SInvalidPageZipInconsistentException("Error while reading zip file", e); } }