Package org.openengsb.core.api.persistence

Examples of org.openengsb.core.api.persistence.PersistenceException


        if (storageFile.exists()) {
            try {
                return FileUtils.readLines(storageFile);
            } catch (IOException e) {
                LOGGER.error("Error reading \"{}\"", storageFile);
                throw new PersistenceException(e);
            }
        }
        return new ArrayList<String>();
    }
View Full Code Here


    private void writeStorageFile(List<String> imports) throws PersistenceException {
        LOGGER.debug("write imports to \"{}\"", storageFile);
        try {
            FileUtils.writeLines(storageFile, imports);
        } catch (IOException e) {
            throw new PersistenceException(e);
        }

    }
View Full Code Here

        if (storageFile.exists()) {
            try {
                lines = FileUtils.readLines(storageFile);
            } catch (IOException e) {
                LOGGER.error("Error reading \"{}\"", storageFile);
                throw new PersistenceException(e);
            }
            for (String line : lines) {
                if (!line.equals("")) {
                    String[] splitLine = line.split(SEPARATOR);
                    ret.put(splitLine[1], splitLine[0]);
View Full Code Here

            for (Entry<String, String> entry : globals.entrySet()) {
                IOUtils.write(
                    entry.getValue() + SEPARATOR + entry.getKey() + IOUtils.LINE_SEPARATOR, os);
            }
        } catch (IOException ex) {
            throw new PersistenceException(ex);
        } finally {
            IOUtils.closeQuietly(os);
        }
    }
View Full Code Here

                    collection.add(entity.toObject());
                }
                return collection;
            }
        } catch (ClassNotFoundException e) {
            throw new PersistenceException(e);
        } catch (InstantiationException e) {
            throw new PersistenceException(e);
        } catch (IllegalAccessException e) {
            throw new PersistenceException(e);
        }
    }
View Full Code Here

        List<ConnectorConfigurationJPAEntity> oldEntities = searchForMetadata(config
            .getMetaData());

        if (oldEntities.size() > 1) {
            throw new PersistenceException(
                "Unexpected error: Found more than 1 object fitting the metadata!");
        }

        ConnectorConfigurationJPAEntity entity = ConnectorConfigurationJPAEntity
            .generateFromConfigItem(config);
        if (oldEntities.size() == 1) {
            ConnectorConfigurationJPAEntity old = oldEntities.get(0);
            old.setConnectorType(entity.getConnectorType());
            old.setDomainType(entity.getDomainType());
            old.setAttributes(entity.getAttributes());
            old.setProperties(entity.getProperties());
            try {
                synchronized (entityManager) {
                    entityManager.merge(old);
                }
            } catch (Exception ex) {
                throw new PersistenceException(ex);
            }

            LOGGER.info("updated ConnectorConfiguration");
        } else {
            try {
                synchronized (entityManager) {
                    entityManager.persist(entity);
                }
            } catch (Exception ex) {
                throw new PersistenceException(ex);
            }
            LOGGER.info("inserted ConnectorConfiguration");
        }
    }
View Full Code Here

        Preconditions
            .checkNotNull(metadata.get(Constants.CONNECTOR_PERSISTENT_ID), "No Id set!");

        List<ConnectorConfigurationJPAEntity> ret = searchForMetadata(metadata);
        if (ret.size() == 0) {
            throw new PersistenceException(
                "Configuration to delete could not be found!");
        }
        synchronized (entityManager) {
            for (ConnectorConfigurationJPAEntity entity : ret) {
                try {
                    entityManager.remove(entity);
                } catch (Exception ex) {
                    throw new PersistenceException(ex);
                }
            }
        }
        LOGGER.info("removed ConnectorConfiguration");
    }
View Full Code Here

            query.select(from);
            query.where(cb.and(predicates.toArray(new Predicate[predicates.size()])));
            try {
                return entityManager.createQuery(query).getResultList();
            } catch (Exception ex) {
                throw new PersistenceException(ex);
            }
        }
    }
View Full Code Here

        try {
            Class<?> clazz = this.getClass().getClassLoader()
                .loadClass(this.className);
            return ConstructorUtils.invokeConstructor(clazz, this.strValue);
        } catch (ClassNotFoundException e) {
            throw new PersistenceException(e);
        } catch (NoSuchMethodException e) {
            throw new PersistenceException(e);
        } catch (IllegalAccessException e) {
            throw new PersistenceException(e);
        } catch (InvocationTargetException e) {
            throw new PersistenceException(e);
        } catch (InstantiationException e) {
            throw new PersistenceException(e);
        }
    }
View Full Code Here

    @Override
    public void persist(ConfigItem<E> config) throws PersistenceException, InvalidConfigurationException {
        List<ConfigItem<E>> alreadyContained = searchForMetadata(config.getMetaData());
        if (alreadyContained.size() > 1) {
            throw new PersistenceException("Could not persist, since there are already to many configs");
        } else {
            if (alreadyContained.size() == 1) {
                data.remove(alreadyContained.get(0));
            }
            data.add(config);
View Full Code Here

TOP

Related Classes of org.openengsb.core.api.persistence.PersistenceException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.