/** * Handle all statistics AFTER the context was shut down. Depending on {@link * #isHandleStatisticsOnEnd()} this method is called or not. */ @OverrideOnDemand protected void handleStatisticsOnEnd() { // serialize statistics try { final File aDestPath = WebFileIO.getDataIO().getFile(getStatisticsFilename()); final IMicroDocument aDoc = StatisticsExporter.getAsXMLDocument(); aDoc.getDocumentElement().setAttribute("location", "shutdown"); aDoc.getDocumentElement() .setAttribute( "datetime", PDTWebDateHelper.getAsStringXSD(PDTFactory.getCurrentDateTime())); SimpleFileIO.writeFile( aDestPath, MicroWriter.getXMLString(aDoc), XMLWriterSettings.DEFAULT_XML_CHARSET_OBJ); } catch (final Throwable t) { s_aLogger.error("Failed to write statistics on context shutdown.", t); } }
@Override public CommandResult execute(final IPartnershipFactoryWithPartners partFx, final Object[] params) throws OpenAS2Exception { if (params.length < 3) return new CommandResult(ECommandResultType.TYPE_INVALID_PARAM_COUNT, getUsage()); final IMicroDocument doc = new MicroDocument(); final IMicroElement root = doc.appendElement("partnership"); for (int nIndex = 0; nIndex < params.length; nIndex++) { final String param = (String) params[nIndex]; final int pos = param.indexOf('='); if (nIndex == 0) { root.setAttribute("name", param); } else if (nIndex == 1) { final IMicroElement elem = root.appendElement("sender"); elem.setAttribute("name", param); } else if (nIndex == 2) { final IMicroElement elem = root.appendElement("receiver"); elem.setAttribute("name", param); } else if (pos == 0) { return new CommandResult(ECommandResultType.TYPE_ERROR, "incoming parameter missing name"); } else if (pos > 0) { final IMicroElement elem = root.appendElement("attribute"); elem.setAttribute("name", param.substring(0, pos)); elem.setAttribute("value", param.substring(pos + 1)); } else return new CommandResult(ECommandResultType.TYPE_ERROR, "incoming parameter missing value"); } final XMLPartnershipFactory aXMLPartnershipFactory = (XMLPartnershipFactory) partFx; final Partnership aPartnership = aXMLPartnershipFactory.loadPartnership(root, aXMLPartnershipFactory.getPartnerMap()); if (aXMLPartnershipFactory.getPartnershipByName(aPartnership.getName()) != null) return new CommandResult( ECommandResultType.TYPE_ERROR, "A partnership with name '" + aPartnership.getName() + "' is already present!"); // add the partnership to the list of available partnerships partFx.addPartnership(aPartnership); return new CommandResult(ECommandResultType.TYPE_OK); }