private Properties getProperties(final byte[] content, final boolean checkIfItAlreadyExists, final PageService pageService) throws SInvalidPageZipMissingIndexException, SInvalidPageZipMissingAPropertyException, SInvalidPageZipInconsistentException, SInvalidPageZipMissingPropertiesException, SInvalidPageTokenException, SBonitaReadException, AlreadyExistsException { final Properties properties = pageService.readPageZip(content); if (checkIfItAlreadyExists) { final String name = properties.getProperty(PageService.PROPERTIES_NAME); final SPage pageByName = pageService.getPageByName(name); if (pageByName != null) { throw new AlreadyExistsException("A page with name " + name + " already exists"); } } return properties; }
private Properties getProperties(final byte[] content, final boolean checkIfItAlreadyExists, final PageService pageService) throws SInvalidPageZipMissingIndexException, SInvalidPageZipMissingAPropertyException, SInvalidPageZipInconsistentException, SInvalidPageZipMissingPropertiesException, SInvalidPageTokenException, SBonitaReadException, AlreadyExistsException { final Properties properties = pageService.readPageZip(content); if (checkIfItAlreadyExists) { final String name = properties.getProperty(PageService.PROPERTIES_NAME); final SPage pageByName = pageService.getPageByName(name); if (pageByName != null) { throw new AlreadyExistsException("A page with name " + name + " already exists"); } } return properties; }
private void deployPage(String resourcePath, byte[] pageContent, Long processDefinitionId, long userId, PageService pageService) throws SBonitaException { final Matcher pathMatcher = getPathMatcher(resourcePath); if (pathMatcher.matches()) { final String pageName = pathMatcher.group(1); final String extension = pathMatcher.group(2); String contentName = pageName + "." + extension; final SPage sPage = pageService.getPageByNameAndProcessDefinitionId(pageName, processDefinitionId); if (sPage != null) { pageService.updatePageContent(sPage.getId(), pageContent, contentName); } else { final Properties pageProperties = pageService.readPageZip(pageContent); final PageCreator pageCreator = new PageCreator(pageName, contentName, ContentType.FORM, processDefinitionId) .setDisplayName(pageProperties.getProperty(PageService.PROPERTIES_DISPLAY_NAME)) .setDescription(pageProperties.getProperty(PageService.PROPERTIES_DESCRIPTION)); final SPage newPage = new PageModelConverter().constructSPage(pageCreator, userId); pageService.addPage(newPage, pageContent); } } }
private void deployPage(String resourcePath, byte[] pageContent, Long processDefinitionId, long userId, PageService pageService) throws SBonitaException { final Matcher pathMatcher = getPathMatcher(resourcePath); if (pathMatcher.matches()) { final String pageName = pathMatcher.group(1); final String extension = pathMatcher.group(2); String contentName = pageName + "." + extension; final SPage sPage = pageService.getPageByNameAndProcessDefinitionId(pageName, processDefinitionId); if (sPage != null) { pageService.updatePageContent(sPage.getId(), pageContent, contentName); } else { final Properties pageProperties = pageService.readPageZip(pageContent); final PageCreator pageCreator = new PageCreator(pageName, contentName, ContentType.FORM, processDefinitionId) .setDisplayName(pageProperties.getProperty(PageService.PROPERTIES_DISPLAY_NAME)) .setDescription(pageProperties.getProperty(PageService.PROPERTIES_DESCRIPTION)); final SPage newPage = new PageModelConverter().constructSPage(pageCreator, userId); pageService.addPage(newPage, pageContent); } } }