use of com.helger.peppolid.factory.IIdentifierFactory in project phoss-directory by phax.
the class SMPBusinessCardProvider method getBusinessCardBDXR1.
@Nullable
@VisibleForTesting
PDExtendedBusinessCard getBusinessCardBDXR1(@Nonnull final IParticipantIdentifier aParticipantID, @Nonnull final BDXRClientReadOnly aSMPClient, @Nonnull final HttpClientSettings aHCS) {
LOGGER.info("Querying BusinessCard for '" + aParticipantID.getURIEncoded() + "' from OASIS BDXR SMP v1 '" + aSMPClient.getSMPHostURI() + "'");
// First query the service group
com.helger.xsds.bdxr.smp1.ServiceGroupType aServiceGroup;
try {
aServiceGroup = aSMPClient.getServiceGroupOrNull(aParticipantID);
} catch (final SMPClientException ex) {
LOGGER.error("Error querying SMP for ServiceGroup of '" + aParticipantID.getURIEncoded() + "'", ex);
return null;
}
// If the service group is present, try querying the business card
final PDBusinessCard aBusinessCard;
try (final HttpClientManager aHCM = HttpClientManager.create(aHCS)) {
// Use the optional business card API
final HttpGet aRequest = new HttpGet(aSMPClient.getSMPHostURI() + "businesscard/" + aParticipantID.getURIPercentEncoded());
aBusinessCard = aHCM.execute(aRequest, new PDSMPHttpResponseHandlerBusinessCard());
} catch (final IOException ex) {
if ((ex instanceof HttpResponseException && ((HttpResponseException) ex).getStatusCode() == CHttp.HTTP_NOT_FOUND) || ex instanceof UnknownHostException) {
LOGGER.warn("No BusinessCard available for '" + aParticipantID.getURIEncoded() + "' - not in configured SMK/SML? - " + ex.getMessage());
} else
LOGGER.error("Error querying SMP for BusinessCard of '" + aParticipantID.getURIEncoded() + "'", ex);
return null;
}
if (aBusinessCard == null) {
// No extension present - no need to try again
LOGGER.warn("Failed to get SMP BusinessCard of " + aParticipantID.getURIEncoded());
return null;
}
// Query all document types
final IIdentifierFactory aIdentifierFactory = PDMetaManager.getIdentifierFactory();
final ICommonsList<IDocumentTypeIdentifier> aDocumentTypeIDs = BDXRClientReadOnly.getAllDocumentTypes(aServiceGroup, aIdentifierFactory, UNHANDLED_HREF_HANDLER);
return new PDExtendedBusinessCard(aBusinessCard, aDocumentTypeIDs);
}
use of com.helger.peppolid.factory.IIdentifierFactory in project phoss-directory by phax.
the class IndexerResource method checkParticipantExistence.
@GET
@Path("{participantID}")
public Response checkParticipantExistence(@Context @Nonnull final HttpServletRequest aHttpServletRequest, @PathParam("participantID") @Nonnull final String sParticipantID) throws IOException {
final String sLogPrefix = "[checkParticipantExistence] ";
final ClientCertificateValidationResult aResult = _checkClientCertificate(aHttpServletRequest, sLogPrefix);
if (aResult.isFailure())
return Response.status(Response.Status.FORBIDDEN).build();
final String sRealParticipantID = _unifyPID(sParticipantID);
if (LOGGER.isInfoEnabled())
LOGGER.info(sLogPrefix + "'" + sRealParticipantID + "'");
// Parse identifier
final IIdentifierFactory aIdentifierFactory = PDMetaManager.getIdentifierFactory();
final IParticipantIdentifier aPI = aIdentifierFactory.parseParticipantIdentifier(sRealParticipantID);
if (aPI == null)
if (LOGGER.isErrorEnabled())
LOGGER.error(sLogPrefix + "Failed to parse participant identifier '" + sRealParticipantID + "'");
// Queue for handling
if (!PDMetaManager.getStorageMgr().containsEntry(aPI))
return Response.status(Response.Status.NOT_FOUND).build();
// And done
return Response.noContent().build();
}
use of com.helger.peppolid.factory.IIdentifierFactory in project phoss-directory by phax.
the class PDQueryManager method getDocumentTypeIDLuceneQuery.
@Nullable
public static Query getDocumentTypeIDLuceneQuery(@Nonnull @Nonempty final String sQueryString) {
ValueEnforcer.notEmpty(sQueryString, "QueryString");
ValueEnforcer.notEmpty(sQueryString.trim(), "QueryString trimmed");
final IIdentifierFactory aIdentifierFactory = PDMetaManager.getIdentifierFactory();
// No casing here!
final IDocumentTypeIdentifier aDTI = aIdentifierFactory.parseDocumentTypeIdentifier(sQueryString);
if (aDTI == null) {
LOGGER.warn("Failed to convert '" + sQueryString + "' to document type ID!");
return null;
}
final Query aQuery = new TermQuery(PDField.DOCTYPE_ID.getExactMatchTerm(aDTI));
return aQuery;
}
use of com.helger.peppolid.factory.IIdentifierFactory in project peppol-commons by phax.
the class PeppolParticipantIdentifierTest method testHasDefaultScheme.
@Test
public void testHasDefaultScheme() {
final IIdentifierFactory aIF = PeppolIdentifierFactory.INSTANCE;
assertTrue(aIF.createParticipantIdentifierWithDefaultScheme("abc").hasScheme(PeppolIdentifierHelper.DEFAULT_PARTICIPANT_SCHEME));
assertFalse(new PeppolParticipantIdentifier("dummy-actorid-upis", "abc").hasDefaultScheme());
}
use of com.helger.peppolid.factory.IIdentifierFactory in project peppol-commons by phax.
the class PeppolParticipantIdentifierTest method testURIStuff.
@Test
public void testURIStuff() {
final IIdentifierFactory aIF = PeppolIdentifierFactory.INSTANCE;
final IParticipantIdentifier aID1 = new PeppolParticipantIdentifier("scheme-actorid-test", "value1");
assertEquals("scheme-actorid-test::value1", aID1.getURIEncoded());
assertEquals("scheme-actorid-test%3A%3Avalue1", aID1.getURIPercentEncoded());
final IParticipantIdentifier aID2 = aIF.parseParticipantIdentifier("scheme-actorid-test::value1");
assertTrue(aID1.hasSameContent(aID2));
assertNull(aIF.parseParticipantIdentifier("scheme1"));
assertNull(aIF.parseParticipantIdentifier(null));
assertNull(aIF.parseParticipantIdentifier(""));
assertNotNull(aIF.parseParticipantIdentifier("any-actorid-dummy::9908:976098897"));
assertNotNull(aIF.parseParticipantIdentifier("any-actorid-dummy::9908:976098897 "));
assertNotNull(aIF.parseParticipantIdentifier("any-actorid-dummy::990:976098897"));
assertNotNull(aIF.parseParticipantIdentifier("any-actorid-dummy::990976098897"));
assertNotNull(aIF.parseParticipantIdentifier("any-actorid-dummy::9909:976098896"));
assertNotNull(aIF.parseParticipantIdentifier("any-actorid-dummy::9908:976098896"));
assertNull(aIF.parseParticipantIdentifier("any-actorid-dummythatiswaytoolongforwhatisexpected::9908:976098896"));
assertNotNull(aIF.parseParticipantIdentifier("any-actorid-dummy::" + VALUE_MAX_LENGTH));
assertNull(aIF.parseParticipantIdentifier("any-actorid-dummy::" + VALUE_MAX_LENGTH_PLUS_1));
assertNull(aIF.parseParticipantIdentifier("any-actorid-dummy:9908:976098896"));
assertNull(aIF.parseParticipantIdentifier("any-actorid-dummy9908:976098896"));
}
Aggregations