@PreAuthorize("hasRole('" + StandardEntitlement.CONNECTOR_HISTORY_DELETE + "')") public void delete(final String key) { ConnInstanceHistoryConf connInstanceHistoryConf = connInstanceHistoryConfDAO.find(key); if (connInstanceHistoryConf == null) { throw new NotFoundException("Connector History Conf '" + key + "'"); } connInstanceHistoryConfDAO.delete(key); }
@PreAuthorize("hasRole('" + StandardEntitlement.CONNECTOR_HISTORY_LIST + "')") @Transactional(readOnly = true) public List<ConnInstanceHistoryConfTO> list(final String key) { ConnInstance connInstance = connInstanceDAO.find(key); if (connInstance == null) { throw new NotFoundException("Connector '" + key + "'"); } return connInstanceHistoryConfDAO.findByEntity(connInstance).stream(). map(binder::getConnInstanceHistoryConfTO).collect(Collectors.toList()); }
connInstanceHistoryConf.setEntity(connInstance); connInstanceHistoryConf.setConf(current); connInstanceHistoryConfDAO.save(connInstanceHistoryConf); List<ConnInstanceHistoryConf> history = connInstanceHistoryConfDAO.findByEntity(connInstance); long maxHistorySize = confDAO.find("connector.conf.history.size", 10L); if (maxHistorySize < history.size()) { connInstanceHistoryConfDAO.delete(history.get(history.size() - 1).getKey());
@Override protected ConnInstanceHistoryConfTO resolveReference(final Method method, final Object... args) throws UnresolvedReferenceException { if (!"list".equals(method.getName())) { try { String key = (String) args[0]; return binder.getConnInstanceHistoryConfTO(connInstanceHistoryConfDAO.find(key)); } catch (Throwable ignore) { LOG.debug("Unresolved reference", ignore); throw new UnresolvedReferenceException(ignore); } } throw new UnresolvedReferenceException(); }
@Override public void delete(final String key) { ConnInstance connInstance = find(key); if (connInstance == null) { return; } connInstance.getResources().stream(). map(Entity::getKey).collect(Collectors.toList()). forEach(resource -> resourceDAO.delete(resource)); connInstanceHistoryConfDAO.deleteByEntity(connInstance); entityManager().remove(connInstance); connRegistry.unregisterConnector(key); } }
@PreAuthorize("hasRole('" + StandardEntitlement.CONNECTOR_HISTORY_RESTORE + "')") public void restore(final String key) { ConnInstanceHistoryConf connInstanceHistoryConf = connInstanceHistoryConfDAO.find(key); if (connInstanceHistoryConf == null) { throw new NotFoundException("Connector History Conf '" + key + "'"); } binder.update(connInstanceHistoryConf.getConf()); }