Search in sources :

Example 1 with ClientCertificateValidationResult

use of com.helger.pd.indexer.clientcert.ClientCertificateValidationResult in project phoss-directory by phax.

the class IndexerResource method createOrUpdateParticipant.

@PUT
public Response createOrUpdateParticipant(@Context @Nonnull final HttpServletRequest aHttpServletRequest, @Nonnull final String sParticipantID) {
    final String sLogPrefix = "[createOrUpdateParticipant] ";
    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 + "'");
        return Response.status(Status.BAD_REQUEST).build();
    }
    // Queue for handling
    if (PDMetaManager.getIndexerMgr().queueWorkItem(aPI, EIndexerWorkItemType.CREATE_UPDATE, aResult.getClientID(), _getRequestingHost(aHttpServletRequest)).isUnchanged()) {
        if (LOGGER.isInfoEnabled())
            LOGGER.info(sLogPrefix + "Ignoring duplicate CREATE/UPDATE request for '" + aPI.getURIEncoded() + "'");
    }
    // And done
    return Response.noContent().build();
}
Also used : IIdentifierFactory(com.helger.peppolid.factory.IIdentifierFactory) ClientCertificateValidationResult(com.helger.pd.indexer.clientcert.ClientCertificateValidationResult) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier) PUT(javax.ws.rs.PUT)

Example 2 with ClientCertificateValidationResult

use of com.helger.pd.indexer.clientcert.ClientCertificateValidationResult in project phoss-directory by phax.

the class IndexerResource method deleteParticipant.

@DELETE
@Path("{participantID}")
public Response deleteParticipant(@Context @Nonnull final HttpServletRequest aHttpServletRequest, @PathParam("participantID") @Nonnull final String sParticipantID) {
    final String sLogPrefix = "[deleteParticipant] ";
    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 + "'");
        return Response.status(Status.BAD_REQUEST).build();
    }
    // Queue for handling
    if (PDMetaManager.getIndexerMgr().queueWorkItem(aPI, EIndexerWorkItemType.DELETE, aResult.getClientID(), _getRequestingHost(aHttpServletRequest)).isUnchanged()) {
        if (LOGGER.isInfoEnabled())
            LOGGER.info(sLogPrefix + "Ignoring duplicate DELETE request for '" + aPI.getURIEncoded() + "'");
    }
    // And done
    return Response.noContent().build();
}
Also used : IIdentifierFactory(com.helger.peppolid.factory.IIdentifierFactory) ClientCertificateValidationResult(com.helger.pd.indexer.clientcert.ClientCertificateValidationResult) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE)

Example 3 with ClientCertificateValidationResult

use of com.helger.pd.indexer.clientcert.ClientCertificateValidationResult 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();
}
Also used : IIdentifierFactory(com.helger.peppolid.factory.IIdentifierFactory) ClientCertificateValidationResult(com.helger.pd.indexer.clientcert.ClientCertificateValidationResult) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Aggregations

ClientCertificateValidationResult (com.helger.pd.indexer.clientcert.ClientCertificateValidationResult)3 IParticipantIdentifier (com.helger.peppolid.IParticipantIdentifier)3 IIdentifierFactory (com.helger.peppolid.factory.IIdentifierFactory)3 Path (javax.ws.rs.Path)2 DELETE (javax.ws.rs.DELETE)1 GET (javax.ws.rs.GET)1 PUT (javax.ws.rs.PUT)1