use of org.xipki.ca.dbtool.jaxb.ca.ObjectFactory in project xipki by xipki.
the class CaConfigurationDbExporter method export.
public void export() throws Exception {
CAConfigurationType caconf = new CAConfigurationType();
caconf.setVersion(VERSION);
System.out.println("exporting CA configuration from database");
exportCmpcontrol(caconf);
exportResponder(caconf);
exportEnvironment(caconf);
exportCrlsigner(caconf);
exportRequestor(caconf);
exportUser(caconf);
exportPublisher(caconf);
exportCa(caconf);
exportProfile(caconf);
exportCaalias(caconf);
exportCaHasRequestor(caconf);
exportCaHasUser(caconf);
exportCaHasPublisher(caconf);
exportCaHasProfile(caconf);
exportScep(caconf);
JAXBElement<CAConfigurationType> root = new ObjectFactory().createCAConfiguration(caconf);
try {
marshaller.marshal(root, new File(baseDir, FILENAME_CA_CONFIGURATION));
} catch (JAXBException ex) {
throw XmlUtil.convert(ex);
}
System.out.println(" exported CA configuration from database");
}
use of org.xipki.ca.dbtool.jaxb.ca.ObjectFactory in project xipki by xipki.
the class CaCertStoreDbExporter method export.
@SuppressWarnings("unchecked")
public void export() throws Exception {
CertStoreType certstore;
if (resume) {
JAXBElement<CertStoreType> root;
try {
root = (JAXBElement<CertStoreType>) unmarshaller.unmarshal(new File(baseDir, FILENAME_CA_CERTSTORE));
} catch (JAXBException ex) {
throw XmlUtil.convert(ex);
}
certstore = root.getValue();
if (certstore.getVersion() > VERSION) {
throw new InvalidInputException("could not continue with CertStore greater than " + VERSION + ": " + certstore.getVersion());
}
} else {
certstore = new CertStoreType();
certstore.setVersion(VERSION);
}
Exception exception = null;
System.out.println("exporting CA certstore from database");
try {
if (!resume) {
exportPublishQueue(certstore);
exportDeltaCrlCache(certstore);
}
File processLogFile = new File(baseDir, DbPorter.EXPORT_PROCESS_LOG_FILENAME);
Long idProcessedInLastProcess = null;
CaDbEntryType typeProcessedInLastProcess = null;
if (processLogFile.exists()) {
byte[] content = IoUtil.read(processLogFile);
if (content != null && content.length > 0) {
String str = new String(content);
int idx = str.indexOf(':');
String typeName = str.substring(0, idx).trim();
typeProcessedInLastProcess = CaDbEntryType.valueOf(typeName);
idProcessedInLastProcess = Long.parseLong(str.substring(idx + 1).trim());
}
}
if (CaDbEntryType.CRL == typeProcessedInLastProcess || typeProcessedInLastProcess == null) {
exception = exportEntries(CaDbEntryType.CRL, certstore, processLogFile, idProcessedInLastProcess);
typeProcessedInLastProcess = null;
idProcessedInLastProcess = null;
}
CaDbEntryType[] types = { CaDbEntryType.CERT, CaDbEntryType.REQUEST, CaDbEntryType.REQCERT };
for (CaDbEntryType type : types) {
if (exception == null && (type == typeProcessedInLastProcess || typeProcessedInLastProcess == null)) {
exception = exportEntries(type, certstore, processLogFile, idProcessedInLastProcess);
typeProcessedInLastProcess = null;
idProcessedInLastProcess = null;
}
}
JAXBElement<CertStoreType> root = new ObjectFactory().createCertStore(certstore);
try {
marshaller.marshal(root, new File(baseDir + File.separator + FILENAME_CA_CERTSTORE));
} catch (JAXBException ex) {
throw XmlUtil.convert(ex);
}
} catch (Exception ex) {
System.err.println("could not export CA certstore from database");
exception = ex;
}
if (exception == null) {
System.out.println(" exported CA certstore from database");
} else {
throw exception;
}
}
Aggregations