3 * Copyright (C) 2015 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
10 package eu
.etaxonomy
.taxeditor
.util
;
13 import java
.io
.FileOutputStream
;
14 import java
.io
.IOException
;
15 import java
.io
.ObjectOutputStream
;
17 import org
.apache
.log4j
.Logger
;
18 import org
.hibernate
.cfg
.Configuration
;
20 import eu
.etaxonomy
.taxeditor
.remoting
.cache
.CdmModelCacher
;
27 public class Serializer
{
28 private static final Logger logger
= Logger
.getLogger(Serializer
.class);
31 public static String HB_CONFIG_SER_FILE_NAME
= "hibernate.cfg.ser";
33 public static boolean checkDir(String dirString
) {
34 if(dirString
== null || dirString
.isEmpty()) {
35 logger
.warn("Directory not set or set to empty string");
39 File dir
= new File(dirString
);
42 logger
.warn("Directory does not exist");
49 public static void serializeHbConfig() {
51 Configuration configuration
= CdmModelCacher
.buildConfiguration();
52 String hbConfigDir
= System
.getProperty("hb.config.dir");
53 if(checkDir(hbConfigDir
)) {
55 FileOutputStream fileOut
= new FileOutputStream(hbConfigDir
+ File
.separator
+ HB_CONFIG_SER_FILE_NAME
);
56 ObjectOutputStream out
= new ObjectOutputStream(fileOut
);
57 out
.writeObject(configuration
);
60 logger
.info("Serialized configuration object");
61 } catch(IOException i
) {
67 public static void main(String
[] args
) {