use of org.dom4j.DocumentException in project zm-mailbox by Zimbra.
the class ReloadLocalConfig method handle.
@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
try {
LC.reload();
} catch (DocumentException e) {
ZimbraLog.misc.error("Failed to reload LocalConfig", e);
throw AdminServiceException.FAILURE("Failed to reload LocalConfig", e);
} catch (ConfigException e) {
ZimbraLog.misc.error("Failed to reload LocalConfig", e);
throw AdminServiceException.FAILURE("Failed to reload LocalConfig", e);
}
ZimbraLog.misc.info("LocalConfig reloaded");
reloadLCOnAllImapDaemons();
ZimbraSoapContext zsc = getZimbraSoapContext(context);
return zsc.jaxbToElement(new ReloadLocalConfigResponse());
}
use of org.dom4j.DocumentException in project zm-mailbox by Zimbra.
the class Zimbra method startup.
/**
* Initialize the various subsystems at server/CLI startup time.
* @param forMailboxd true if this is the mailboxd process; false for CLI processes
* @throws ServiceException
*/
private static synchronized void startup(boolean forMailboxd) throws ServiceException {
if (sInited)
return;
sIsMailboxd = forMailboxd;
if (sIsMailboxd) {
FirstServlet.waitForInitialization();
}
Provisioning prov = Provisioning.getInstance();
Server server = prov.getLocalServer();
alwaysOnClusterId = server.getAlwaysOnClusterId();
setSystemProperties();
validateJavaOptions();
logVersionAndSysInfo();
SoapTransport.setDefaultUserAgent("ZCS", BuildInfo.VERSION);
checkForClasses();
ZimbraApplication app = ZimbraApplication.getInstance();
ZimbraPerf.prepare(ZimbraPerf.ServerID.ZIMBRA);
DbPool.startup();
app.initializeZimbraDb(forMailboxd);
if (!Versions.checkVersions()) {
Zimbra.halt("Data version mismatch. Reinitialize or upgrade the backend data store.");
}
DbPool.loadSettings();
String tzFilePath = LC.timezone_file.value();
try {
File tzFile = new File(tzFilePath);
WellKnownTimeZones.loadFromFile(tzFile);
} catch (Throwable t) {
Zimbra.halt("Unable to load timezones from " + tzFilePath, t);
}
if (prov instanceof LdapProv) {
((LdapProv) prov).waitForLdapServer();
if (forMailboxd) {
AttributeManager.loadLdapSchemaExtensionAttrs((LdapProv) prov);
}
}
if (server.isMailSSLClientCertOCSPEnabled()) {
// Activate OCSP
Security.setProperty("ocsp.enable", "true");
// Activate CRLDP
System.setProperty("com.sun.security.enableCRLDP", "true");
} else {
// Disable OCSP
Security.setProperty("ocsp.enable", "false");
// Disable CRLDP
System.setProperty("com.sun.security.enableCRLDP", "false");
}
try {
RightManager.getInstance();
} catch (ServiceException e) {
Util.halt("cannot initialize RightManager", e);
}
ZimbraHttpConnectionManager.startReaperThread();
EphemeralStore.registerFactory("ldap", LdapEphemeralStore.Factory.class.getName());
ExtensionUtil.initAll();
try {
StoreManager.getInstance().startup();
} catch (IOException e) {
throw ServiceException.FAILURE("Unable to initialize StoreManager.", e);
}
MailboxManager.getInstance();
app.startup();
if (app.supports(MemcachedConnector.class.getName())) {
MemcachedConnector.startup();
}
if (app.supports(EhcacheManager.class.getName())) {
EhcacheManager.getInstance().startup();
}
// ZimletUtil.loadZimlets();
MailboxIndex.startup();
RedoLogProvider redoLog = RedoLogProvider.getInstance();
if (sIsMailboxd) {
redoLog.startup();
} else {
redoLog.initRedoLogManager();
}
System.setProperty("ical4j.unfolding.relaxed", "true");
MailboxManager.getInstance().startup();
app.initialize(sIsMailboxd);
if (sIsMailboxd) {
SessionCache.startup();
AuthTokenRegistry.startup(prov.getConfig(Provisioning.A_zimbraAuthTokenNotificationInterval).getIntAttr(Provisioning.A_zimbraAuthTokenNotificationInterval, 60000));
dbSessionCleanup();
if (!redoLog.isSlave()) {
boolean useDirectBuffers = server.isMailUseDirectBuffers();
IoBuffer.setUseDirectBuffer(useDirectBuffers);
ZimbraLog.misc.info("MINA setUseDirectBuffers(" + useDirectBuffers + ")");
ServerManager.getInstance().startServers();
}
if (app.supports(WaitSetMgr.class.getName())) {
WaitSetMgr.startup();
}
if (app.supports(MemoryStats.class.getName())) {
MemoryStats.startup();
}
if (app.supports(ScheduledTaskManager.class.getName())) {
ScheduledTaskManager.startup();
}
if (app.supports(PurgeThread.class.getName())) {
PurgeThread.startup();
}
if (app.supports(AutoProvisionThread.class.getName())) {
AutoProvisionThread.switchAutoProvThreadIfNecessary();
}
if (LC.smtp_to_lmtp_enabled.booleanValue()) {
int smtpPort = LC.smtp_to_lmtp_port.intValue();
int lmtpPort = Provisioning.getInstance().getLocalServer().getLmtpBindPort();
SmtpToLmtp smtpServer = SmtpToLmtp.startup(smtpPort, "localhost", lmtpPort);
smtpServer.setRecipientValidator(new SmtpRecipientValidator());
}
if (app.supports(AclPushTask.class)) {
long pushInterval = server.getSharingUpdatePublishInterval();
sTimer.schedule(new AclPushTask(), pushInterval, pushInterval);
}
if (app.supports(ExternalAccountManagerTask.class)) {
long interval = server.getExternalAccountStatusCheckInterval();
sTimer.schedule(new ExternalAccountManagerTask(), interval, interval);
}
Server localServer = Provisioning.getInstance().getLocalServer();
String provPort = localServer.getAttr(Provisioning.A_zimbraMailPort);
String lcPort = LC.zimbra_mail_service_port.value();
if (!lcPort.equals(provPort)) {
LocalConfig lc;
try {
lc = new LocalConfig(null);
lc.set(LC.zimbra_mail_service_port.key(), provPort);
lc.save();
LC.reload();
} catch (DocumentException | ConfigException | IOException e) {
ZimbraLog.misc.warn("Cannot set LC zimbra_mail_service_port", e);
}
}
// should be last, so that other subsystems can add dynamic stats counters
if (app.supports(ZimbraPerf.class.getName())) {
ZimbraPerf.initialize(ZimbraPerf.ServerID.ZIMBRA);
}
}
ExtensionUtil.postInitAll();
// Register the service with ZooKeeper
if (sIsMailboxd && isAlwaysOn()) {
try {
CuratorManager curatorManager = CuratorManager.getInstance();
if (curatorManager == null) {
throw ServiceException.FAILURE("ZooKeeper addresses not configured.", null);
}
curatorManager.start();
} catch (Exception e) {
throw ServiceException.FAILURE("Unable to start Distributed Lock service.", e);
}
}
sInited = true;
}
use of org.dom4j.DocumentException in project Openfire by igniterealtime.
the class PresenceManagerImpl method getLastPresenceStatus.
@Override
public String getLastPresenceStatus(User user) {
String username = user.getUsername();
String presenceStatus = null;
String presenceXML = offlinePresenceCache.get(username);
if (presenceXML == null) {
loadOfflinePresence(username);
}
presenceXML = offlinePresenceCache.get(username);
if (presenceXML != null) {
// If the cached answer is no data, return null.
if (presenceXML.equals(NULL_STRING)) {
return null;
}
// Otherwise, parse out the status from the XML.
try {
// Parse the element
Document element = DocumentHelper.parseText(presenceXML);
presenceStatus = element.getRootElement().elementTextTrim("status");
} catch (DocumentException e) {
Log.error(LocaleUtils.getLocalizedString("admin.error"), e);
}
}
return presenceStatus;
}
use of org.dom4j.DocumentException in project ats-framework by Axway.
the class XmlText method init.
private void init(String xmlText) throws XMLException {
Document document = null;
try {
document = new SAXReader().read(new StringReader(xmlText));
} catch (DocumentException e) {
throw new XMLException("Error parsing XML text:\n" + xmlText, e);
}
this.root = document.getRootElement();
}
use of org.dom4j.DocumentException in project summer by foxsugar.
the class PayUtil method readStringXml.
public void readStringXml(String xml) {
Document doc = null;
try {
// 读取并解析XML文档
// SAXReader就是一个管道,用一个流的方式,把xml文件读出来
//
// SAXReader reader = new SAXReader(); //User.hbm.xml表示你要解析的xml文档
// Document document = reader.read(new File("User.hbm.xml"));
// 下面的是通过解析xml字符串的
// 将字符串转为XML
doc = DocumentHelper.parseText(xml);
// 获取根节点
Element rootElt = doc.getRootElement();
// 拿到根节点的名称
System.out.println("根节点:" + rootElt.getName());
// 获取根节点下的子节点head
Iterator iter = rootElt.elementIterator("head");
// 遍历head节点
while (iter.hasNext()) {
Element recordEle = (Element) iter.next();
// 拿到head节点下的子节点title值
String title = recordEle.elementTextTrim("title");
System.out.println("title:" + title);
// 获取子节点head下的子节点script
Iterator iters = recordEle.elementIterator("script");
// 遍历Header节点下的Response节点
while (iters.hasNext()) {
Element itemEle = (Element) iters.next();
// 拿到head下的子节点script下的字节点username的值
String username = itemEle.elementTextTrim("username");
String password = itemEle.elementTextTrim("password");
System.out.println("username:" + username);
System.out.println("password:" + password);
}
}
// /获取根节点下的子节点body
Iterator iterss = rootElt.elementIterator("body");
// 遍历body节点
while (iterss.hasNext()) {
Element recordEless = (Element) iterss.next();
// 拿到body节点下的子节点result值
String result = recordEless.elementTextTrim("result");
System.out.println("result:" + result);
// 获取子节点body下的子节点form
Iterator itersElIterator = recordEless.elementIterator("form");
// 遍历Header节点下的Response节点
while (itersElIterator.hasNext()) {
Element itemEle = (Element) itersElIterator.next();
// 拿到body下的子节点form下的字节点banlce的值
String banlce = itemEle.elementTextTrim("banlce");
String subID = itemEle.elementTextTrim("subID");
System.out.println("banlce:" + banlce);
System.out.println("subID:" + subID);
}
}
} catch (DocumentException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
Aggregations