Changeset 241


Ignore:
Timestamp:
03/17/10 16:16:06 (14 years ago)
Author:
oschonef
Message:
  • change logging to slf4j
  • update slf4j to 1.5.11
Location:
VirtualCollectionRegistry/trunk/VirtualCollectionRegistry
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • VirtualCollectionRegistry/trunk/VirtualCollectionRegistry/pom.xml

    r214 r241  
    209209      <groupId>org.slf4j</groupId>
    210210      <artifactId>slf4j-jdk14</artifactId>
    211       <version>1.5.10</version>
     211      <version>${slf4j.version}</version>
    212212      <scope>runtime</scope>
    213213    </dependency>
     
    216216      <groupId>org.slf4j</groupId>
    217217      <artifactId>slf4j-api</artifactId>
    218       <version>1.5.10</version>
    219       <scope>runtime</scope>
     218      <version>${slf4j.version}</version>
    220219    </dependency>
    221220
     
    235234        <hibernate.version>3.5.0-CR-2</hibernate.version>
    236235        <hibernate.jpaVersion>1.0.0-CR-1</hibernate.jpaVersion>
     236        <slf4j.version>1.5.11</slf4j.version>
    237237  </properties>
    238238</project>
  • VirtualCollectionRegistry/trunk/VirtualCollectionRegistry/src/main/java/eu/clarin/cmdi/virtualcollectionregistry/DataStore.java

    r217 r241  
    22
    33import java.util.Map;
    4 import java.util.logging.Level;
    5 import java.util.logging.Logger;
    64
    75import javax.persistence.EntityManager;
     
    97import javax.persistence.EntityTransaction;
    108import javax.persistence.Persistence;
     9
     10import org.slf4j.Logger;
     11import org.slf4j.LoggerFactory;
    1112
    1213public class DataStore {
     
    2021        } // inner class ThreadLocalEntityManager
    2122        private static final Logger logger =
    22                 Logger.getLogger(DataStore.class.getName());
     23                LoggerFactory.getLogger(DataStore.class);
    2324        private final EntityManagerFactory emf;
    2425        private final ThreadLocalEntityManager em = new ThreadLocalEntityManager();
     
    3031                                        "VirtualCollectionStore", config);
    3132                } catch (Exception e) {
    32                         logger.log(Level.SEVERE, "error initializing data store", e);
     33                        logger.error("error initializing data store", e);
    3334                        throw new VirtualCollectionRegistryException("error initializing",
    3435                                        e);
    3536                }
    36                 logger.finer("data store was successfully initialized");
     37                logger.debug("data store was successfully initialized");
    3738        }
    3839
  • VirtualCollectionRegistry/trunk/VirtualCollectionRegistry/src/main/java/eu/clarin/cmdi/virtualcollectionregistry/VirtualCollectionRegistry.java

    r237 r241  
    66import java.util.Map;
    77import java.util.concurrent.atomic.AtomicBoolean;
    8 import java.util.logging.Level;
    9 import java.util.logging.Logger;
    108
    119import javax.persistence.EntityManager;
    1210import javax.persistence.NoResultException;
    1311import javax.persistence.TypedQuery;
     12
     13import org.slf4j.Logger;
     14import org.slf4j.LoggerFactory;
    1415
    1516import eu.clarin.cmdi.virtualcollectionregistry.model.InternalPersistentIdentifierProvider;
     
    2526public class VirtualCollectionRegistry {
    2627        private static final Logger logger =
    27                 Logger.getLogger(VirtualCollectionRegistry.class.getName());
     28                LoggerFactory.getLogger(VirtualCollectionRegistry.class);
    2829        private static final VirtualCollectionRegistry s_instance =
    2930                new VirtualCollectionRegistry();
     
    4748                        throw new VirtualCollectionRegistryException("already initialized");
    4849                }
    49                 logger.fine("initialize ...");
     50                logger.debug("initializing virtual collection registry ...");
    5051                if (config != null) {
    5152                        config = Collections.unmodifiableMap(config);
     
    5758                this.marshaller   = new VirtualCollectionRegistryMarshaller();
    5859                this.intialized.set(true);
     60                logger.info("virtual collection registry successfully intialized");
    5961        }
    6062
     
    8991                        throw new NullPointerException("vc == null");
    9092                }
     93
     94                logger.debug("creating virtual collection");
    9195
    9296                VirtualCollectionValidator validator =
     
    108112                        vc.setOwner(user);
    109113                        vc.createUUID();
    110                         em.persist(vc);                 
     114                        em.persist(vc);
    111115                        em.getTransaction().commit();
    112116
     
    116120                        em.persist(pid);
    117121                        em.getTransaction().commit();
    118 
     122                        logger.debug("created virtual collection (id={}, pid={})",
     123                                             vc.getId(), pid.getIdentifier());
    119124                        return vc.getId();
    120                 } catch (Exception e) {
    121                         logger.log(Level.SEVERE,
    122                                            "error while creating virtual collection", e);
     125                } catch (VirtualCollectionRegistryException e) {
     126                        logger.debug("failed creating virtual collecion: {}",
     127                                             e.getMessage());
     128                        throw e;
     129                } catch (Exception e) {
     130                        logger.error("error while creating virtual collection", e);
    123131                        throw new VirtualCollectionRegistryException(
    124132                                        "error while creating virtual collection", e);
     
    137145                        throw new NullPointerException("vc == null");
    138146                }
    139                
     147
     148                logger.debug("updating virtual collection (id={})", id);
     149
    140150                VirtualCollectionValidator validator =
    141151                        new VirtualCollectionValidator();
     
    157167                        validator.validate(c);
    158168                        em.getTransaction().commit();
     169                        logger.debug("updated virtual collection (id={})", vc.getId());
    159170                        return vc.getId();
    160171                } catch (VirtualCollectionRegistryException e) {
     172                        logger.debug("failed updating virtual collecion (id={}): {}",
     173                                                 id, e.getMessage());
    161174                        throw e;
    162175                } catch (Exception e) {
    163                         logger.log(Level.SEVERE,
    164                        "error while updating virtual collection", e);
     176                        logger.error("error while updating virtual collection", e);
    165177                        throw new VirtualCollectionRegistryException(
    166178                                        "error while updating virtual collection", e);
     
    177189                }
    178190
     191                logger.debug("deleting virtual collection (id={})", id);
     192
    179193                try {
    180194                        EntityManager em = datastore.getEntityManager();
     
    182196                        VirtualCollection vc = em.find(VirtualCollection.class, new Long(id));
    183197                        if (vc == null) {
     198                                logger.debug("virtual collection (id={}) not found", id);
    184199                                throw new VirtualCollectionNotFoundException(id);
    185200                        }
     
    193208                        return vc.getId();
    194209                } catch (VirtualCollectionRegistryException e) {
     210                        logger.debug("failed deleting virtual collecion (id={}): {}",
     211                                         id, e.getMessage());
    195212                        throw e;
    196213                } catch (Exception e) {
    197                         logger.log(Level.SEVERE,
    198                                            "error while deleting virtual collection", e);
     214                        logger.error("error while deleting virtual collection", e);
    199215                        throw new VirtualCollectionRegistryException(
    200216                                        "error while deleting virtual collection", e);
     
    208224                }
    209225
     226                logger.debug("retrieve virtual collection (id={})", id);
     227
    210228                try {
    211229                        EntityManager em = datastore.getEntityManager();
     
    215233                        em.getTransaction().commit();
    216234                        if (vc == null) {
     235                                logger.debug("virtual collection (id={}) not found", id);
    217236                                throw new VirtualCollectionNotFoundException(id);
    218237                        }
     
    221240                        throw e;
    222241                } catch (Exception e) {
    223                         logger.log(Level.SEVERE,
    224                                            "error while retrieving virtual collection", e);
     242                        logger.error("error while retrieving virtual collection", e);
    225243                        throw new VirtualCollectionRegistryException(
    226244                                        "error while retrieving virtual collection", e);
     
    237255                        throw new IllegalArgumentException("uuid is empty");
    238256                }
     257
     258                logger.debug("retrieve virtual collection (uuid={})", uuid);
    239259
    240260                try {
     
    249269                        return vc;
    250270                } catch (NoResultException e) {
     271                        logger.debug("virtual collection (uuid={}) not found", uuid);
    251272                        throw new VirtualCollectionNotFoundException(uuid);
    252273                } catch (Exception e) {
    253                         logger.log(Level.SEVERE,
    254                                            "error while retrieving virtual collection", e);
     274                        logger.error("error while retrieving virtual collection", e);
    255275                        throw new VirtualCollectionRegistryException(
    256276                                        "error while retrieving virtual collection", e);
     
    297317                                "query invalid", e);
    298318                } catch (Exception e) {
    299                         logger.log(Level.SEVERE,
    300                                            "error while enumerating virtual collections", e);
     319                        logger.error("error while enumerating virtual collections", e);
    301320                        throw new VirtualCollectionRegistryException(
    302321                                        "error while enumerating virtual collections", e);
     
    359378                        throw e;
    360379                } catch (Exception e) {
    361                         logger.log(Level.SEVERE,
    362                                            "error while enumerating virtual collections", e);
     380                        logger.error("error while enumerating virtual collections", e);
    363381                        throw new VirtualCollectionRegistryException(
    364382                                        "error while enumerating virtual collections", e);
  • VirtualCollectionRegistry/trunk/VirtualCollectionRegistry/src/main/java/eu/clarin/cmdi/virtualcollectionregistry/VirtualCollectionRegistryMarshaller.java

    r239 r241  
    66import java.net.URL;
    77import java.util.HashMap;
    8 import java.util.logging.Level;
    9 import java.util.logging.Logger;
    108
    119import javax.xml.XMLConstants;
     
    2523import org.codehaus.jettison.mapped.MappedXMLInputFactory;
    2624import org.codehaus.jettison.mapped.MappedXMLOutputFactory;
     25import org.slf4j.Logger;
     26import org.slf4j.LoggerFactory;
    2727
    2828import eu.clarin.cmdi.virtualcollectionregistry.model.ClarinVirtualCollection;
     
    3636        private static final String ENCODING = "UTF-8";
    3737        private static final String VERSION = "1.0";
    38         private static final Logger logger = Logger
    39                         .getLogger(VirtualCollectionRegistryMarshaller.class.getName());
     38        private static final Logger logger =
     39                LoggerFactory.getLogger(VirtualCollectionRegistryMarshaller.class);
    4040        private Schema schema = null;
    4141        private XMLInputFactory xmlReaderFactory;
     
    4646        VirtualCollectionRegistryMarshaller()
    4747                        throws VirtualCollectionRegistryException {
    48                 logger.fine("initializing schemas for marshaller ...");
     48                logger.debug("initializing schemas for marshaller ...");
    4949                try {
    5050                        SchemaFactory sf = SchemaFactory
     
    6363                        jsonWriterFactory = new MappedXMLOutputFactory(mapping);
    6464                } catch (Exception e) {
    65                         logger.log(Level.SEVERE, "error initializing marshaller", e);
     65                        logger.error("error initializing marshaller", e);
    6666                        throw new VirtualCollectionRegistryException(
    6767                                        "error initializing marshaller", e);
     
    8585                        writer.close();
    8686                } catch (Exception e) {
    87                         logger
    88                                 .log(Level.WARNING, "error marshalling virtual collection", e);
     87                        logger.error("error marshalling virtual collection", e);
    8988                        throw new IOException("error marshalling virtual collection", e);
    9089                }
     
    107106                                        "virtual collection format", e.getLinkedException());
    108107                } catch (Exception e) {
    109                         logger.log(Level.WARNING, "error unmarshalling virtual collection", e);
     108                        logger.error("error unmarshalling virtual collection", e);
    110109                        throw new IOException("error unmarshalling virtual collection", e);
    111110                }
     
    139138                        writer.close();
    140139                } catch (Exception e) {
    141                         logger.log(Level.WARNING, "error marshalling virtual collections", e);
     140                        logger.error("error marshalling virtual collections", e);
    142141                        throw new IOException("error marshalling virtual collections", e);
    143142                }
     
    160159                        writer.close();
    161160                } catch (Exception e) {
    162                         logger.log(Level.WARNING, "error marshalling clarin virtual collections", e);
     161                        logger.error("error marshalling clarin virtual collections", e);
    163162                        throw new IOException("error marshalling clarin virtual collections", e);
    164163                }
Note: See TracChangeset for help on using the changeset viewer.