Search in sources :

Example 1 with StubObject

use of com.helger.photon.security.object.StubObject in project phase4 by phax.

the class PModeJsonConverter method getStubObject.

@Nonnull
public static StubObject getStubObject(@Nonnull final IJsonObject aElement) {
    // ID
    final String sID = aElement.getAsString(ATTR_ID);
    // Creation
    final LocalDateTime aCreationLDT = PDTWebDateHelper.getLocalDateTimeFromXSD(aElement.getAsString(ATTR_CREATIONLDT));
    final String sCreationUserID = aElement.getAsString(ATTR_CREATIONUSERID);
    // Last modification
    final LocalDateTime aLastModificationLDT = PDTWebDateHelper.getLocalDateTimeFromXSD(aElement.getAsString(ATTR_LASTMODLDT));
    final String sLastModificationUserID = aElement.getAsString(ATTR_LASTMODUSERID);
    // Deletion
    final LocalDateTime aDeletionLDT = PDTWebDateHelper.getLocalDateTimeFromXSD(aElement.getAsString(ATTR_DELETIONLDT));
    final String sDeletionUserID = aElement.getAsString(ATTR_DELETIONUSERID);
    final ICommonsOrderedMap<String, String> aCustomAttrs = new CommonsLinkedHashMap<>();
    final IJsonArray aCustom = aElement.getAsArray(ELEMENT_CUSTOM);
    if (aCustom != null)
        for (final IJsonObject eCustom : aCustom.iteratorObjects()) aCustomAttrs.put(eCustom.getAsString(ATTR_ID), eCustom.getAsString(VALUE));
    return new StubObject(sID, aCreationLDT, sCreationUserID, aLastModificationLDT, sLastModificationUserID, aDeletionLDT, sDeletionUserID, aCustomAttrs);
}
Also used : LocalDateTime(java.time.LocalDateTime) CommonsLinkedHashMap(com.helger.commons.collection.impl.CommonsLinkedHashMap) IJsonObject(com.helger.json.IJsonObject) IJsonArray(com.helger.json.IJsonArray) StubObject(com.helger.photon.security.object.StubObject) Nonnull(javax.annotation.Nonnull)

Example 2 with StubObject

use of com.helger.photon.security.object.StubObject in project peppol-practical by phax.

the class TestEndpointMicroTypeConverter method convertToNative.

@Nonnull
public TestEndpoint convertToNative(@Nonnull final IMicroElement eValue) {
    final StubObject aStubObject = getStubObject(eValue);
    final String sCompanyName = eValue.getAttributeValue(ATTR_COMPANY_NAME);
    final String sContactPerson = eValue.getAttributeValue(ATTR_CONTACT_PERSON);
    final String sParticipantIDScheme = eValue.getAttributeValue(ATTR_PARTICIPANT_ID_ISSUER);
    final String sParticipantIDValue = eValue.getAttributeValue(ATTR_PARTICIPANT_ID_VALUE);
    final String sTransportProfile = eValue.getAttributeValue(ATTR_TRANSPORT_PROFILE);
    final ESMPTransportProfile eTransportProfile = ESMPTransportProfile.getFromIDOrNull(sTransportProfile);
    final String sSMLID = eValue.getAttributeValue(ATTR_SML);
    final ISMLConfiguration aSMLInfo = PPMetaManager.getSMLConfigurationMgr().getSMLInfoOfID(sSMLID);
    if (aSMLInfo == null)
        throw new IllegalStateException("Failed to resolve SML with ID '" + sSMLID + "'");
    // Create object
    return new TestEndpoint(aStubObject, sCompanyName, sContactPerson, sParticipantIDScheme, sParticipantIDValue, eTransportProfile, aSMLInfo);
}
Also used : ESMPTransportProfile(com.helger.peppol.smp.ESMPTransportProfile) ISMLConfiguration(com.helger.peppol.domain.ISMLConfiguration) StubObject(com.helger.photon.security.object.StubObject) Nonnull(javax.annotation.Nonnull)

Aggregations

StubObject (com.helger.photon.security.object.StubObject)2 Nonnull (javax.annotation.Nonnull)2 CommonsLinkedHashMap (com.helger.commons.collection.impl.CommonsLinkedHashMap)1 IJsonArray (com.helger.json.IJsonArray)1 IJsonObject (com.helger.json.IJsonObject)1 ISMLConfiguration (com.helger.peppol.domain.ISMLConfiguration)1 ESMPTransportProfile (com.helger.peppol.smp.ESMPTransportProfile)1 LocalDateTime (java.time.LocalDateTime)1