Skip to content

Commit 99ee414

Browse files
committed
Using simple APIs
1 parent e8e748d commit 99ee414

File tree

2 files changed

+14
-31
lines changed

2 files changed

+14
-31
lines changed

phase4-peppol-server-webapp/src/main/java/com/helger/phase4/peppol/server/api/Phase4API.java

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import javax.annotation.Nonnull;
2020

2121
import com.helger.peppol.servicedomain.EPeppolNetwork;
22+
import com.helger.phase4.peppol.server.APConfig;
2223
import com.helger.photon.api.APIDescriptor;
2324
import com.helger.photon.api.APIPath;
2425
import com.helger.photon.api.IAPIExceptionMapper;
@@ -44,8 +45,10 @@ public static void init (@Nonnull final IAPIRegistry aAPIRegistry)
4445
{
4546
final IAPIExceptionMapper aExceptionMapper = new APIExceptionMapper ();
4647

48+
final EPeppolNetwork eStage = APConfig.getPeppolStage ();
49+
4750
{
48-
final APIDescriptor aSendTest = new APIDescriptor (APIPath.post ("/sendtest/{" +
51+
final APIDescriptor aSendTest = new APIDescriptor (APIPath.post ("/sendas4/{" +
4952
PARAM_SENDER_ID +
5053
"}/{" +
5154
PARAM_RECEIVER_ID +
@@ -55,30 +58,12 @@ public static void init (@Nonnull final IAPIRegistry aAPIRegistry)
5558
PARAM_PROCESS_ID +
5659
"}/{" +
5760
PARAM_COUNTRY_CODE_C1 +
58-
"}"),
59-
new APIPostSendDocument (EPeppolNetwork.TEST));
61+
"}"), new APIPostSendDocument (eStage));
6062
aSendTest.setExceptionMapper (aExceptionMapper);
6163
aAPIRegistry.registerAPI (aSendTest);
6264
}
6365
{
64-
final APIDescriptor aSendProd = new APIDescriptor (APIPath.post ("/sendprod/{" +
65-
PARAM_SENDER_ID +
66-
"}/{" +
67-
PARAM_RECEIVER_ID +
68-
"}/{" +
69-
PARAM_DOC_TYPE_ID +
70-
"}/{" +
71-
PARAM_PROCESS_ID +
72-
"}/{" +
73-
PARAM_COUNTRY_CODE_C1 +
74-
"}"),
75-
new APIPostSendDocument (EPeppolNetwork.PRODUCTION));
76-
aSendProd.setExceptionMapper (aExceptionMapper);
77-
aAPIRegistry.registerAPI (aSendProd);
78-
}
79-
{
80-
final APIDescriptor aSendTestSbdh = new APIDescriptor (APIPath.post ("/sendtestsbdh"),
81-
new APIPostSendDocument (EPeppolNetwork.TEST));
66+
final APIDescriptor aSendTestSbdh = new APIDescriptor (APIPath.post ("/sendsbdh"), new APIPostSendSBDH (eStage));
8267
aSendTestSbdh.setExceptionMapper (aExceptionMapper);
8368
aAPIRegistry.registerAPI (aSendTestSbdh);
8469
}

phase4-peppol-server-webapp/src/main/java/com/helger/phase4/peppol/server/servlet/Phase4PeppolWebAppListener.java

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,8 @@ protected void initGlobalSettings ()
141141
HttpDebugger.setEnabled (false);
142142

143143
// Sanity check
144-
if (CommandMap.getDefaultCommandMap ()
145-
.createDataContentHandler (CMimeType.MULTIPART_RELATED.getAsString ()) == null)
144+
if (CommandMap.getDefaultCommandMap ().createDataContentHandler (CMimeType.MULTIPART_RELATED.getAsString ()) ==
145+
null)
146146
throw new IllegalStateException ("No DataContentHandler for MIME Type '" +
147147
CMimeType.MULTIPART_RELATED.getAsString () +
148148
"' is available. There seems to be a problem with the dependencies/packaging");
@@ -190,20 +190,18 @@ public void onEndRequest (@Nonnull final IAS4IncomingMessageMetadata aMessageMet
190190
if (SimpleFileIO.writeFile (aFile,
191191
AS4IncomingHelper.getIncomingMetadataAsJson (aMessageMetadata)
192192
.getAsJsonString (JsonWriterSettings.DEFAULT_SETTINGS_FORMATTED),
193-
StandardCharsets.UTF_8)
194-
.isFailure ())
193+
StandardCharsets.UTF_8).isFailure ())
195194
LOGGER.error ("Failed to write metadata to '" + aFile.getAbsolutePath () + "'");
196195
else
197196
LOGGER.info ("Wrote metadata to '" + aFile.getAbsolutePath () + "'");
198197
}
199198
});
200199

201200
// Store the outgoings file as well
202-
AS4DumpManager.setOutgoingDumper (new AS4OutgoingDumperFileBased ( (eMsgMode,
203-
sMessageID,
204-
nTry) -> StorageHelper.getStorageFile (sMessageID,
205-
nTry,
206-
".as4out")));
201+
AS4DumpManager.setOutgoingDumper (new AS4OutgoingDumperFileBased ( (eMsgMode, sMessageID, nTry) -> StorageHelper
202+
.getStorageFile (sMessageID,
203+
nTry,
204+
".as4out")));
207205
}
208206

209207
private static void _initPeppolAS4 ()
@@ -309,7 +307,7 @@ private static void _initPeppolAS4 ()
309307
LOGGER.error ("Failed to do a reverse search of the certificate", ex);
310308
}
311309

312-
// TODO separate to test and production
310+
// Seeparate to test and production
313311
final EPeppolNetwork eStage = APConfig.getPeppolStage ();
314312
final PeppolCAChecker aAPCAChecker = eStage.isTest () ? PeppolCertificateChecker.peppolTestAP ()
315313
: PeppolCertificateChecker.peppolProductionAP ();

0 commit comments

Comments
 (0)