Example usage for javax.xml.registry RegistryException RegistryException

List of usage examples for javax.xml.registry RegistryException RegistryException

Introduction

In this page you can find the example usage for javax.xml.registry RegistryException RegistryException.

Prototype

public RegistryException(Throwable cause) 

Source Link

Document

Constructs a JAXRException object initialized with the given Throwable object.

Usage

From source file:org.freebxml.omar.server.persistence.rdb.EmailAddressDAO.java

/**
 * Does a bulk update of a Collection of objects that match the type for this persister.
 *
 *///  w ww.  ja v  a 2 s  .  co  m
public void update(String parentId, List emailAddresss) throws RegistryException {
    log.debug(ServerResourceBundle.getInstance().getString("message.UpdatingEmailAddresss",
            new Object[] { new Integer(emailAddresss.size()) }));

    Statement stmt = null;

    try {
        stmt = context.getConnection().createStatement();

        Iterator iter = emailAddresss.iterator();

        while (iter.hasNext()) {
            EmailAddress emailAddress = (EmailAddress) iter.next();

            String address = emailAddress.getAddress();

            String type = emailAddress.getType();

            if (type != null) {
                type = "'" + type + "'";
            }

            String str = "UPDATE EmailAddress SET " +
            //"accesControlPolicy = null, " +
                    "SET address = '" + address + "', " + "SET type = " + type + " WHERE parent = '" + parentId
                    + "' ";
            log.trace("SQL = " + str);
            stmt.addBatch(str);
        }

        stmt.executeBatch();
    } catch (SQLException e) {
        RegistryException exception = new RegistryException(e);
        throw exception;
    } finally {
        closeStatement(stmt);
    }
}

From source file:org.freebxml.omar.server.persistence.rdb.ExternalIdentifierDAO.java

protected void loadObject(Object obj, ResultSet rs) throws RegistryException {
    try {/*from   w  w  w  .ja  v a 2  s  .com*/
        if (!(obj instanceof org.oasis.ebxml.registry.bindings.rim.ExternalIdentifier)) {
            throw new RegistryException(ServerResourceBundle.getInstance()
                    .getString("message.ExternalIdentifierTypeExpected", new Object[] { obj }));
        }

        ExternalIdentifier ei = (ExternalIdentifier) obj;
        super.loadObject(obj, rs);

        String schemeId = rs.getString("identificationScheme");

        if (schemeId != null) {
            ObjectRef or = bu.rimFac.createObjectRef();
            or.setId(schemeId);
            context.getObjectRefs().add(or);
        }

        ei.setIdentificationScheme(schemeId);

        String registryObjectId = rs.getString("registryObject");
        if (registryObjectId != null) {
            ObjectRef registryObject = bu.rimFac.createObjectRef();
            context.getObjectRefs().add(registryObject);
            registryObject.setId(registryObjectId);
            ei.setRegistryObject(registryObjectId);
        }

        String value = rs.getString("value");
        ei.setValue(value);
    } catch (SQLException e) {
        log.error(ServerResourceBundle.getInstance().getString("message.CaughtException1"), e);
        throw new RegistryException(e);
    } catch (JAXBException j) {
        log.error(ServerResourceBundle.getInstance().getString("message.CaughtException1"), j);
        throw new RegistryException(j);
    }
}

From source file:org.freebxml.omar.server.persistence.rdb.ExternalLinkDAO.java

protected void loadObject(Object obj, ResultSet rs) throws RegistryException {
    try {/*from w w w  . j  a  v a 2s  .  c  o m*/
        if (!(obj instanceof org.oasis.ebxml.registry.bindings.rim.ExternalLink)) {
            throw new RegistryException(ServerResourceBundle.getInstance()
                    .getString("message.ExternalLinkTypeExpected", new Object[] { obj }));
        }

        ExternalLink el = (ExternalLink) obj;
        super.loadObject(obj, rs);

        String externalURI = rs.getString("externalURI");
        el.setExternalURI(externalURI);
    } catch (SQLException e) {
        log.error(ServerResourceBundle.getInstance().getString("message.CaughtException1"), e);
        throw new RegistryException(e);
    }
}

From source file:org.freebxml.omar.server.persistence.rdb.ExtrinsicObjectDAO.java

protected void loadObject(Object obj, ResultSet rs) throws RegistryException {
    try {/*from   w w  w .  java  2 s. c o  m*/
        if (!(obj instanceof org.oasis.ebxml.registry.bindings.rim.ExtrinsicObject)) {
            throw new RegistryException(ServerResourceBundle.getInstance()
                    .getString("message.ExtrinsicObjectExpected", new Object[] { obj }));
        }

        ExtrinsicObject eo = (ExtrinsicObject) obj;
        super.loadObject(obj, rs);

        String isOpaque = rs.getString("isOpaque");

        if (isOpaque.equals("T")) {
            eo.setIsOpaque(true);
        } else {
            eo.setIsOpaque(false);
        }

        String mimeType = rs.getString("mimeType");
        eo.setMimeType(mimeType);

        //Now set contentVersionInfo if either contentComment and contentVersionName are non-null
        //Make sure to not set contentVersionInfo if both contentComment and contentVersionName are null
        VersionInfoType contentVersionInfo = BindingUtility.getInstance().rimFac.createVersionInfoType();
        String contentVersionName = rs.getString("contentVersionName");
        String contentComment = rs.getString("contentVersionComment");

        if ((contentVersionName != null) || (contentComment != null)) {
            if (contentVersionName != null) {
                contentVersionInfo.setVersionName(contentVersionName);
            }

            if (contentComment != null) {
                contentVersionInfo.setComment(contentComment);
            }
            eo.setContentVersionInfo(contentVersionInfo);
        }

    } catch (SQLException e) {
        log.error(ServerResourceBundle.getInstance().getString("message.CaughtException1"), e);
        throw new RegistryException(e);
    } catch (javax.xml.bind.JAXBException e) {
        log.error(ServerResourceBundle.getInstance().getString("message.CaughtException1"), e);
        throw new RegistryException(e);
    }
}

From source file:org.freebxml.omar.server.persistence.rdb.FederationDAO.java

protected void loadObject(Object obj, ResultSet rs) throws RegistryException {
    try {//from w w  w  .  ja  v  a2  s.  co m
        if (!(obj instanceof Federation)) {
            throw new RegistryException(ServerResourceBundle.getInstance()
                    .getString("message.FederationExpected", new Object[] { obj }));
        }

        Federation federation = (Federation) obj;
        super.loadObject(obj, rs);

        String replicationSyncLatency = rs.getString("replicationSyncLatency");
        federation.setReplicationSyncLatency(replicationSyncLatency);

    } catch (SQLException e) {
        log.error(ServerResourceBundle.getInstance().getString("message.CaughtException1"), e);
        throw new RegistryException(e);
    }
}

From source file:org.freebxml.omar.server.persistence.rdb.IdentifiableDAO.java

protected List getIdentifiablesIds(List identifiables) throws RegistryException {
    List ids = new ArrayList();

    try {/*  w  w  w .ja v  a  2s  .c  o  m*/
        //log.info("size: "  + identifiables.size());
        Iterator iter = identifiables.iterator();

        while (iter.hasNext()) {
            String id = BindingUtility.getInstance().getObjectId(iter.next());
            ids.add(id);
        }
    } catch (JAXRException e) {
        throw new RegistryException(e);
    }

    return ids;
}

From source file:org.freebxml.omar.server.persistence.rdb.IdentifiableDAO.java

/**
 * Check whether the object exists in the specified table.
 *//*  www  .  ja v  a 2s.c o m*/
public boolean identifiableExist(String id, String tableName) throws RegistryException {
    PreparedStatement stmt = null;

    try {
        String sql = "SELECT id FROM " + tableName + " WHERE id=?";
        stmt = context.getConnection().prepareStatement(sql);
        stmt.setString(1, id);
        log.trace("SQL = " + sql);
        ResultSet rs = stmt.executeQuery();
        boolean result = false;

        if (rs.next()) {
            result = true;
        }

        return result;
    } catch (SQLException e) {
        throw new RegistryException(e);
    } finally {
        closeStatement(stmt);
    }
}

From source file:org.freebxml.omar.server.persistence.rdb.IdentifiableDAO.java

/**
 * Returns List of ids of non-existent Identifiable.
 *///from   w  w w.java  2 s  . c o m
public List identifiablesExist(List ids, String tableName) throws RegistryException {
    List notExistIdList = new ArrayList();

    if (ids.size() == 0) {
        return notExistIdList;
    }

    Iterator iter = ids.iterator();
    Statement stmt = null;

    try {
        stmt = context.getConnection().createStatement();

        StringBuffer sql = new StringBuffer("SELECT id FROM " + tableName + " WHERE id IN (");
        List existingIdList = new ArrayList();

        /* We need to count the number of item in "IN" list. We need to split the a single
        SQL Strings if it is too long. Some database such as Oracle, does not
        allow the IN list is too long*/
        int listCounter = 0;

        while (iter.hasNext()) {
            String id = (String) iter.next();

            if (iter.hasNext() && (listCounter < identifiableExistsBatchCount)) {
                sql.append("'" + id + "',");
            } else {
                sql.append("'" + id + "')");

                //log.info("!!!!!!!!!!!!!!!!!!!" + sql.toString());
                log.trace("SQL = " + sql.toString());
                ResultSet rs = stmt.executeQuery(sql.toString());

                while (rs.next()) {
                    existingIdList.add(rs.getString("id"));
                }

                sql = new StringBuffer("SELECT id FROM " + tableName + " WHERE id IN (");
                listCounter = 0;
            }

            listCounter++;
        }

        for (int i = 0; i < ids.size(); i++) {
            String id = (String) ids.get(i);

            if (!existingIdList.contains(id)) {
                notExistIdList.add(id);
            }
        }
    } catch (SQLException e) {
        throw new RegistryException(e);
    } finally {
        closeStatement(stmt);
    }

    return notExistIdList;
}

From source file:org.freebxml.omar.server.persistence.rdb.IdentifiableDAO.java

protected void loadObject(Object obj, ResultSet rs) throws RegistryException {
    try {/*w w  w .  j av  a  2  s  .  c  om*/
        if (!(obj instanceof IdentifiableType)) {
            throw new RegistryException(ServerResourceBundle.getInstance()
                    .getString("message.IdentifiableTypeExpected", new Object[] { obj }));
        }

        IdentifiableType ident = (IdentifiableType) obj;

        SlotDAO slotDAO = new SlotDAO(context);
        slotDAO.setParent(ident);

        String id = rs.getString("id");
        ident.setId(id);

        String home = rs.getString("home");
        if (home != null) {
            ident.setHome(home);
        }

        boolean returnComposedObjects = context.getResponseOption().isReturnComposedObjects();

        if (returnComposedObjects) {
            List slots = slotDAO.getSlotsByParent(id);
            ident.getSlot().addAll(slots);
        }
    } catch (SQLException e) {
        log.error(ServerResourceBundle.getInstance().getString("message.CaughtException1"), e);
        throw new RegistryException(e);
    }
}

From source file:org.freebxml.omar.server.persistence.rdb.InternationalStringDAO.java

InternationalStringType getInternationalStringByParent(String parentId) throws RegistryException {
    InternationalStringType is = null;//  w ww  . ja  v a  2 s.  com
    PreparedStatement stmt = null;

    try {
        String tableName = getTableName();

        if (tableName.equalsIgnoreCase("Name_")) {
            is = bu.rimFac.createName();
        } else if (tableName.equalsIgnoreCase("Description")) {
            is = bu.rimFac.createDescription();
        } else if (tableName.equalsIgnoreCase("UsageDescription")) {
            is = bu.rimFac.createUsageDescription();
        }
        String sql = "SELECT * FROM " + getTableName() + " WHERE parent = ?";
        stmt = context.getConnection().prepareStatement(sql);
        stmt.setString(1, parentId);
        log.trace("SQL = " + sql); // HIEOS/BHT: (DEBUG)
        ResultSet rs = stmt.executeQuery();

        while (rs.next()) {
            String charsetName = rs.getString("charset");
            String lang = rs.getString("lang");
            String value = rs.getString("value");
            if (value != null) {
                LocalizedString ls = bu.rimFac.createLocalizedString();
                ls.setCharset(charsetName);
                ls.setLang(lang);
                ls.setValue(value);
                is.getLocalizedString().add(ls);
            }
        }
    } catch (SQLException e) {
        log.error(ServerResourceBundle.getInstance().getString("message.CaughtException1"), e);
        throw new RegistryException(e);
    } catch (JAXBException j) {
        log.error(ServerResourceBundle.getInstance().getString("message.CaughtException1"), j);
        throw new RegistryException(j);
    } finally {
        closeStatement(stmt);
    }

    return is;
}