private void updateMappings(final SPage page, final Properties apiProperties) throws SObjectCreationException, SBonitaReadException, SDeletionException { final List<String> keys = getKeysOfPageMappings(apiProperties); final List<String> existingKeys = new ArrayList<>(); List<SPageMapping> mappings; do { mappings = pageMappingService.get(page.getId(), 0, MAX_RESULTS); for (final SPageMapping mapping : mappings) { if (keys.contains(mapping.getKey())) { existingKeys.add(mapping.getKey()); } else { pageMappingService.delete(mapping); } } } while (mappings.size() == MAX_RESULTS); keys.removeAll(existingKeys); for (final String key : keys) { pageMappingService.create(key, page.getId(), Collections.<String> emptyList()); } }
@Override public void pageDeleted(final SPage page) throws SBonitaReadException, SDeletionException { if (SContentType.API_EXTENSION.equals(page.getContentType())) { List<SPageMapping> mappings; do { mappings = pageMappingService.get(page.getId(), 0, MAX_RESULTS); for (final SPageMapping mapping : mappings) { pageMappingService.delete(mapping); } } while (mappings.size() == MAX_RESULTS); } }
private void addPageMapping(final SPage page, final Properties apiProperties) throws SObjectCreationException, IOException, SInvalidPageZipMissingPropertiesException { final List<String> mappings = getKeysOfPageMappings(apiProperties); for (final String mapping : mappings) { pageMappingService.create(mapping, page.getId(), Collections.<String> emptyList()); } }
@Override public PageURL resolvePageOrURL(String key, Map<String, Serializable> context, boolean executeAuthorizationRules) throws NotFoundException, ExecutionException, UnauthorizedAccessException { final PageMappingService pageMappingService = retrievePageMappingService(); try { return ModelConvertor.toPageURL(pageMappingService.resolvePageURL(pageMappingService.get(key), context, executeAuthorizationRules)); } catch (final SObjectNotFoundException e) { throw new NotFoundException(e); } catch (final SBonitaReadException e) { throw new RetrieveException(e); } catch (final SExecutionException e) { throw new ExecutionException(e); } catch (final SAuthorizationException e) { throw new UnauthorizedAccessException(e); } }
@Override public void delete(SFormMapping formMapping) throws SObjectModificationException { FormMappingLogBuilder logBuilder = getLogBuilder(ActionType.DELETED); try { recorder.recordDelete(new DeleteRecord(formMapping), FORM_MAPPING); if (formMapping.getPageMapping() != null) { pageMappingService.delete(formMapping.getPageMapping()); } log(formMapping, SQueriableLog.STATUS_OK, logBuilder, "delete", "delete"); } catch (SRecorderException | SDeletionException e) { log(formMapping, SQueriableLog.STATUS_FAIL, logBuilder, "delete", "failed to delete"); throw new SObjectModificationException(e); } }
Set<Long> updatePageMappings(long pageId) throws SBonitaReadException, SObjectModificationException, SObjectNotFoundException { List<SFormMapping> formMappings; QueryOptions queryOptions = new QueryOptions(0, 20, Collections.singletonList(new OrderByOption(SFormMapping.class, FormMappingSearchDescriptor.ID, OrderByType.ASC)), Collections.singletonList(new FilterOption(SPageMapping.class, FormMappingSearchDescriptor.PAGE_ID, pageId)), null); final Set<Long> processDefinitionIds = new HashSet<>(); do { formMappings = formMappingService.searchFormMappings(queryOptions); for (final SFormMapping formMapping : formMappings) { pageMappingService.update(formMapping.getPageMapping(), null); processDefinitionIds.add(formMapping.getProcessDefinitionId()); } queryOptions = QueryOptions.getNextPage(queryOptions); } while (formMappings.size() == 20); return processDefinitionIds; }
@Override public void pageDeleted(final SPage page) throws SBonitaReadException, SDeletionException { if (SContentType.API_EXTENSION.equals(page.getContentType())) { List<SPageMapping> mappings; do { mappings = pageMappingService.get(page.getId(), 0, MAX_RESULTS); for (final SPageMapping mapping : mappings) { pageMappingService.delete(mapping); } } while (mappings.size() == MAX_RESULTS); } }
private void addPageMapping(final SPage page, final Properties apiProperties) throws SObjectCreationException, IOException, SInvalidPageZipMissingPropertiesException { final List<String> mappings = getKeysOfPageMappings(apiProperties); for (final String mapping : mappings) { pageMappingService.create(mapping, page.getId(), Collections.<String> emptyList()); } }
@Override public PageURL resolvePageOrURL(String key, Map<String, Serializable> context, boolean executeAuthorizationRules) throws NotFoundException, ExecutionException, UnauthorizedAccessException { final PageMappingService pageMappingService = retrievePageMappingService(); try { return ModelConvertor.toPageURL(pageMappingService.resolvePageURL(pageMappingService.get(key), context, executeAuthorizationRules)); } catch (final SObjectNotFoundException e) { throw new NotFoundException(e); } catch (final SBonitaReadException e) { throw new RetrieveException(e); } catch (final SExecutionException e) { throw new ExecutionException(e); } catch (final SAuthorizationException e) { throw new UnauthorizedAccessException(e); } }
@Override public void delete(SFormMapping formMapping) throws SObjectModificationException { FormMappingLogBuilder logBuilder = getLogBuilder(ActionType.DELETED); try { recorder.recordDelete(new DeleteRecord(formMapping), FORM_MAPPING); if (formMapping.getPageMapping() != null) { pageMappingService.delete(formMapping.getPageMapping()); } log(formMapping, SQueriableLog.STATUS_OK, logBuilder, "delete", "delete"); } catch (SRecorderException | SDeletionException e) { log(formMapping, SQueriableLog.STATUS_FAIL, logBuilder, "delete", "failed to delete"); throw new SObjectModificationException(e); } }
Set<Long> updatePageMappings(long pageId) throws SBonitaReadException, SObjectModificationException, SObjectNotFoundException { List<SFormMapping> formMappings; QueryOptions queryOptions = new QueryOptions(0, 20, Collections.singletonList(new OrderByOption(SFormMapping.class, FormMappingSearchDescriptor.ID, OrderByType.ASC)), Collections.singletonList(new FilterOption(SPageMapping.class, FormMappingSearchDescriptor.PAGE_ID, pageId)), null); final Set<Long> processDefinitionIds = new HashSet<>(); do { formMappings = formMappingService.searchFormMappings(queryOptions); for (final SFormMapping formMapping : formMappings) { pageMappingService.update(formMapping.getPageMapping(), null); processDefinitionIds.add(formMapping.getProcessDefinitionId()); } queryOptions = QueryOptions.getNextPage(queryOptions); } while (formMappings.size() == 20); return processDefinitionIds; }
private void updateMappings(final SPage page, final Properties apiProperties) throws SObjectCreationException, SBonitaReadException, SDeletionException { final List<String> keys = getKeysOfPageMappings(apiProperties); final List<String> existingKeys = new ArrayList<>(); List<SPageMapping> mappings; do { mappings = pageMappingService.get(page.getId(), 0, MAX_RESULTS); for (final SPageMapping mapping : mappings) { if (keys.contains(mapping.getKey())) { existingKeys.add(mapping.getKey()); } else { pageMappingService.delete(mapping); } } } while (mappings.size() == MAX_RESULTS); keys.removeAll(existingKeys); for (final String key : keys) { pageMappingService.create(key, page.getId(), Collections.<String> emptyList()); } }
switch (target) { case SFormMapping.TARGET_INTERNAL: sPageMapping = pageMappingService.create(key, getPageIdOrNull(form, processDefinitionId), authorizationRules); break; case SFormMapping.TARGET_URL: sPageMapping = pageMappingService.create(key, form, externalUrlAdapter, authorizationRules); break; case SFormMapping.TARGET_LEGACY: sPageMapping = pageMappingService.create(key, null, legacyUrlAdapter, null); break; case SFormMapping.TARGET_UNDEFINED: break; case SFormMapping.TARGET_NONE: sPageMapping = pageMappingService.create(key, null, authorizationRules); break; default:
switch (target) { case SFormMapping.TARGET_INTERNAL: sPageMapping = pageMappingService.create(key, getPageIdOrNull(form, processDefinitionId), authorizationRules); break; case SFormMapping.TARGET_URL: sPageMapping = pageMappingService.create(key, form, externalUrlAdapter, authorizationRules); break; case SFormMapping.TARGET_LEGACY: sPageMapping = pageMappingService.create(key, null, legacyUrlAdapter, null); break; case SFormMapping.TARGET_UNDEFINED: break; case SFormMapping.TARGET_NONE: sPageMapping = pageMappingService.create(key, null, authorizationRules); break; default:
protected SPageMapping createPageMappingForExistingFormMapping(SFormMapping formMapping, String url, Long pageId) throws SObjectCreationException { String key = formMappingKeyGenerator.generateKey(formMapping.getProcessDefinitionId(), formMapping.getTask(), formMapping.getType()); if (url != null) { return pageMappingService.create(key, url, externalUrlAdapter, buildAuthorizationRules(formMapping.getType())); } else { return pageMappingService.create(key, pageId, buildAuthorizationRules(formMapping.getType())); } }
protected SPageMapping createPageMappingForExistingFormMapping(SFormMapping formMapping, String url, Long pageId) throws SObjectCreationException { String key = formMappingKeyGenerator.generateKey(formMapping.getProcessDefinitionId(), formMapping.getTask(), formMapping.getType()); if (url != null) { return pageMappingService.create(key, url, externalUrlAdapter, buildAuthorizationRules(formMapping.getType())); } else { return pageMappingService.create(key, pageId, buildAuthorizationRules(formMapping.getType())); } }