Reducing header overuse, non-inlining selected methods (CPPOST-35).
[shibboleth/cpp-opensaml.git] / saml / binding / impl / ArtifactMap.cpp
index c22c6ef..53b1560 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  Copyright 2001-2007 Internet2
+ *  Copyright 2001-2009 Internet2
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 #include "binding/ArtifactMap.h"
 #include "binding/SAMLArtifact.h"
 
-#include <log4cpp/Category.hh>
+#include <ctime>
 #include <xercesc/util/XMLUniDefs.hpp>
+#include <xmltooling/logging.h>
 #include <xmltooling/XMLObjectBuilder.h>
+#include <xmltooling/XMLToolingConfig.h>
 #include <xmltooling/util/NDC.h>
+#include <xmltooling/util/ParserPool.h>
+#include <xmltooling/util/StorageService.h>
 #include <xmltooling/util/XMLHelper.h>
+#include <xmltooling/util/Threads.h>
 
 using namespace opensaml;
+using namespace xmltooling::logging;
 using namespace xmltooling;
-using namespace log4cpp;
 using namespace std;
 
 namespace opensaml {
@@ -204,9 +209,14 @@ void ArtifactMap::storeContent(XMLObject* content, const SAMLArtifact* artifact,
     // Serialize the root element, whatever it is, for storage.
     string xmlbuf;
     XMLHelper::serialize(root, xmlbuf);
-    m_storage->createText(
-        m_context.c_str(), SAMLArtifact::toHex(artifact->getMessageHandle()).c_str(), xmlbuf.c_str(), time(NULL) + m_artifactTTL
-        );
+    if (!m_storage->createText(
+        m_context.c_str(),
+        SAMLArtifact::toHex(artifact->getMessageHandle()).c_str(),
+        xmlbuf.c_str(),
+        time(NULL) + m_artifactTTL
+        )) {
+        throw IOException("Attempt to insert duplicate artifact into map.");
+    }
         
     // Cleanup by destroying XML.
     delete content;