protected void checkThatInternalPageExists(Long pageId) throws SObjectModificationException { if (pageId != null) { try { pageService.getPage(pageId); } catch (SBonitaReadException | SObjectNotFoundException e) { throw new SObjectModificationException("the page with id " + pageId + " does not exists"); } } }
private Long getThemeId(final String themeName, final String applicationToken, final ImportStatus importStatus) throws SBonitaReadException, ImportException { SPage theme = pageService.getPageByName(themeName); if (theme == null) { return handleMissingTheme(themeName, applicationToken, importStatus); } return theme.getId(); }
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); } } }
Long getPageIdOrNull(String form, long processDefinitionId) throws SBonitaReadException { SPage pageByName = pageService.getPageByNameAndProcessDefinitionId(form, processDefinitionId); if (pageByName == null) { pageByName = pageService.getPageByName(form); } return pageByName == null ? null : pageByName.getId(); }
private void deleteProcessPages(Long processDefinitionId) throws SBonitaReadException, SObjectModificationException, SObjectNotFoundException { List<SPage> sPages; do { sPages = pageService.getPageByProcessDefinitionId(processDefinitionId, 0, NUMBER_OF_RESULTS); for (SPage sPage : sPages) { pageService.deletePage(sPage.getId()); } } while (sPages.size() == NUMBER_OF_RESULTS); }
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; }
public void updatePageContent(final long pageId, final byte[] content) throws UpdateException, UpdatingWithInvalidPageTokenException, UpdatingWithInvalidPageZipContentException { final SPageUpdateBuilder pageUpdateBuilder = getPageUpdateBuilder(); pageUpdateBuilder.updateLastModificationDate(System.currentTimeMillis()); pageUpdateBuilder.updateLastUpdatedBy(userIdFromSession); try { final SPage page = pageService.getPage(pageId); pageService.updatePageContent(pageId, content, page.getContentName()); pageService.updatePage(pageId, pageUpdateBuilder.done()); } catch (final SInvalidPageTokenException e) { throw new UpdatingWithInvalidPageTokenException(e.getMessage(), e); } catch (final SInvalidPageZipException e) { throw new UpdatingWithInvalidPageZipContentException(e.getMessage(), e); } catch (final SBonitaException sBonitaException) { throw new UpdateException(sBonitaException); } }
public Page getPageByNameAndProcessDefinition(String name, long processDefinitionId) throws PageNotFoundException { try { final SPage sPage = pageService.getPageByNameAndProcessDefinitionId(name, processDefinitionId); if (sPage == null) { throw new PageNotFoundException(name, PageAttribute.NAME); } return convertToPage(sPage); } catch (final SBonitaReadException e) { throw new PageNotFoundException(e); } }
public Page createPage(final String contentName, final byte[] content) throws AlreadyExistsException, CreationException, InvalidPageTokenException, InvalidPageZipContentException { try { return convertToPage(pageService.addPage(content, contentName, userIdFromSession)); } catch (final SObjectAlreadyExistsException e) { throw new AlreadyExistsException("A page already exists with the name defined in page zip content"); } catch (final SInvalidPageTokenException e) { throw new InvalidPageTokenException(e.getMessage(), e); } catch (final SInvalidPageZipException e) { throw convertException(e); } catch (final SBonitaException e) { throw new CreationException(e); } }
@Override public long executeCount(final QueryOptions queryOptions) throws SBonitaReadException { try { return pageService.getNumberOfPages(queryOptions); } catch (final SBonitaReadException e) { throw new SBonitaReadException(e); } }
public byte[] getPageContent(final long pageId) throws PageNotFoundException { try { return pageService.getPageContent(pageId); } catch (final SBonitaReadException e) { throw new PageNotFoundException(e); } catch (final SObjectNotFoundException e) { throw new PageNotFoundException(e); } }
public void deletePage(final long pageId) throws DeletionException { try { pageService.deletePage(pageId); final Set<Long> processDefinitionIds = updatePageMappings(pageId); for (final Long processDefinitionId : processDefinitionIds) { updateProcessResolution(processDefinitionId); } } catch (final SBonitaException e) { throw new DeletionException(e); } }
@Override public List<SPage> executeSearch(final QueryOptions queryOptions) throws SBonitaReadException { return pageService.searchPages(queryOptions); }
public void updatePageContent(final long pageId, final byte[] content) throws UpdateException, UpdatingWithInvalidPageTokenException, UpdatingWithInvalidPageZipContentException { final SPageUpdateBuilder pageUpdateBuilder = getPageUpdateBuilder(); pageUpdateBuilder.updateLastModificationDate(System.currentTimeMillis()); pageUpdateBuilder.updateLastUpdatedBy(userIdFromSession); try { final SPage page = pageService.getPage(pageId); pageService.updatePageContent(pageId, content, page.getContentName()); pageService.updatePage(pageId, pageUpdateBuilder.done()); } catch (final SInvalidPageTokenException e) { throw new UpdatingWithInvalidPageTokenException(e.getMessage(), e); } catch (final SInvalidPageZipException e) { throw new UpdatingWithInvalidPageZipContentException(e.getMessage(), e); } catch (final SBonitaException sBonitaException) { throw new UpdateException(sBonitaException); } }
Long getPageIdOrNull(String form, long processDefinitionId) throws SBonitaReadException { SPage pageByName = pageService.getPageByNameAndProcessDefinitionId(form, processDefinitionId); if (pageByName == null) { pageByName = pageService.getPageByName(form); } return pageByName == null ? null : pageByName.getId(); }
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 deleteProcessPages(Long processDefinitionId) throws SBonitaReadException, SObjectModificationException, SObjectNotFoundException { List<SPage> sPages; do { sPages = pageService.getPageByProcessDefinitionId(processDefinitionId, 0, NUMBER_OF_RESULTS); for (SPage sPage : sPages) { pageService.deletePage(sPage.getId()); } } while (sPages.size() == NUMBER_OF_RESULTS); }
public Page getPageByNameAndProcessDefinition(String name, long processDefinitionId) throws PageNotFoundException { try { final SPage sPage = pageService.getPageByNameAndProcessDefinitionId(name, processDefinitionId); if (sPage == null) { throw new PageNotFoundException(name, PageAttribute.NAME); } return convertToPage(sPage); } catch (final SBonitaReadException e) { throw new PageNotFoundException(e); } }
public Page createPage(final String contentName, final byte[] content) throws AlreadyExistsException, CreationException, InvalidPageTokenException, InvalidPageZipContentException { try { return convertToPage(pageService.addPage(content, contentName, userIdFromSession)); } catch (final SObjectAlreadyExistsException e) { throw new AlreadyExistsException("A page already exists with the name defined in page zip content"); } catch (final SInvalidPageTokenException e) { throw new InvalidPageTokenException(e.getMessage(), e); } catch (final SInvalidPageZipException e) { throw convertException(e); } catch (final SBonitaException e) { throw new CreationException(e); } }
@Override public long executeCount(final QueryOptions queryOptions) throws SBonitaReadException { try { return pageService.getNumberOfPages(queryOptions); } catch (final SBonitaReadException e) { throw new SBonitaReadException(e); } }