use of com.helger.peppolid.IDocumentTypeIdentifier in project phoss-smp by phax.
the class PageSecureEndpointList method showListOfExistingObjects.
@Override
protected void showListOfExistingObjects(@Nonnull final WebPageExecutionContext aWPEC) {
final Locale aDisplayLocale = aWPEC.getDisplayLocale();
final HCNodeList aNodeList = aWPEC.getNodeList();
final ISMPServiceInformationManager aServiceInfoMgr = SMPMetaManager.getServiceInformationMgr();
final ICommonsList<ISMPServiceInformation> aAllServiceInfos = aServiceInfoMgr.getAllSMPServiceInformation();
// Count unique service groups
final ICommonsSet<String> aServiceGroupIDs = new CommonsHashSet<>();
aAllServiceInfos.findAllMapped(ISMPServiceInformation::getServiceGroupID, aServiceGroupIDs::add);
final boolean bHideDetails = aServiceGroupIDs.size() > 1000;
final BootstrapButtonToolbar aToolbar = new BootstrapButtonToolbar(aWPEC);
aToolbar.addButton("Create new Endpoint", createCreateURL(aWPEC), EDefaultIcon.NEW);
aToolbar.addButton("Refresh", aWPEC.getSelfHref(), EDefaultIcon.REFRESH);
if (!bHideDetails)
aToolbar.addButton("Tree view", aWPEC.getLinkToMenuItem(CMenuSecure.MENU_ENDPOINT_TREE), EDefaultIcon.MAGNIFIER);
aNodeList.addChild(aToolbar);
final HCTable aTable = new HCTable(new DTCol("Service group").setInitialSorting(ESortOrder.ASCENDING).setDataSort(0, 1, 2, 3), new DTCol("Document type ID").setDataSort(1, 0, 2, 3), new DTCol("Process ID").setDataSort(2, 0, 1, 3), new DTCol("Transport profile").setDataSort(3, 0, 1, 2), new BootstrapDTColAction(aDisplayLocale)).setID(getID());
for (final ISMPServiceInformation aServiceInfo : aAllServiceInfos) {
final ISMPServiceGroup aServiceGroup = aServiceInfo.getServiceGroup();
final IParticipantIdentifier aParticipantID = aServiceGroup.getParticipantIdentifier();
final IDocumentTypeIdentifier aDocTypeID = aServiceInfo.getDocumentTypeIdentifier();
for (final ISMPProcess aProcess : aServiceInfo.getAllProcesses()) {
final IProcessIdentifier aProcessID = aProcess.getProcessIdentifier();
for (final ISMPEndpoint aEndpoint : aProcess.getAllEndpoints()) {
final StringMap aParams = createParamMap(aServiceInfo, aProcess, aEndpoint);
final HCRow aRow = aTable.addBodyRow();
final ISimpleURL aViewURL = createViewURL(aWPEC, aServiceInfo, aParams);
aRow.addCell(new HCA(aViewURL).addChild(aServiceGroup.getID()));
aRow.addCell(NiceNameUI.getDocumentTypeID(aDocTypeID, false));
aRow.addCell(NiceNameUI.getProcessID(aDocTypeID, aProcessID, false));
final String sTransportProfile = aEndpoint.getTransportProfile();
aRow.addCell(new HCA(createViewURL(aWPEC, CMenuSecure.MENU_TRANSPORT_PROFILES, sTransportProfile)).addChild(NiceNameUI.getTransportProfile(sTransportProfile, false)));
final ISimpleURL aEditURL = createEditURL(aWPEC, aServiceInfo).addAll(aParams);
final ISimpleURL aCopyURL = createCopyURL(aWPEC, aServiceInfo).addAll(aParams);
final ISimpleURL aDeleteURL = createDeleteURL(aWPEC, aServiceInfo).addAll(aParams);
final ISimpleURL aPreviewURL = LinkHelper.getURLWithServerAndContext(aParticipantID.getURIPercentEncoded() + SMPRestFilter.PATH_SERVICES + aDocTypeID.getURIPercentEncoded());
aRow.addCell(new HCA(aViewURL).setTitle("View endpoint").addChild(EDefaultIcon.MAGNIFIER.getAsNode()), new HCTextNode(" "), new HCA(aEditURL).setTitle("Edit endpoint").addChild(EDefaultIcon.EDIT.getAsNode()), new HCTextNode(" "), new HCA(aCopyURL).setTitle("Copy endpoint").addChild(EDefaultIcon.COPY.getAsNode()), new HCTextNode(" "), new HCA(aDeleteURL).setTitle("Delete endpoint").addChild(EDefaultIcon.DELETE.getAsNode()), new HCTextNode(" "), new HCA(aPreviewURL).setTitle("Perform SMP query on endpoint").setTargetBlank().addChild(EFamFamIcon.SCRIPT_GO.getAsNode()));
}
}
}
final DataTables aDataTables = BootstrapDataTables.createDefaultDataTables(aWPEC, aTable);
aNodeList.addChild(aTable).addChild(aDataTables);
}
use of com.helger.peppolid.IDocumentTypeIdentifier in project phoss-smp by phax.
the class PageSecureEndpointTree method showListOfExistingObjects.
@Override
protected void showListOfExistingObjects(@Nonnull final WebPageExecutionContext aWPEC) {
final HCNodeList aNodeList = aWPEC.getNodeList();
final ISMPServiceGroupManager aServiceGroupMgr = SMPMetaManager.getServiceGroupMgr();
final ISMPServiceInformationManager aServiceInfoMgr = SMPMetaManager.getServiceInformationMgr();
final BootstrapButtonToolbar aToolbar = new BootstrapButtonToolbar(aWPEC);
aToolbar.addButton("Create new Endpoint", createCreateURL(aWPEC), EDefaultIcon.NEW);
aToolbar.addButton("Refresh", aWPEC.getSelfHref(), EDefaultIcon.REFRESH);
aToolbar.addButton("List view", aWPEC.getLinkToMenuItem(CMenuSecure.MENU_ENDPOINT_LIST), EDefaultIcon.MAGNIFIER);
aNodeList.addChild(aToolbar);
// Create list of service groups
final ICommonsMap<ISMPServiceGroup, ICommonsList<ISMPServiceInformation>> aMap = new CommonsHashMap<>();
aServiceInfoMgr.getAllSMPServiceInformation().forEach(x -> aMap.computeIfAbsent(x.getServiceGroup(), k -> new CommonsArrayList<>()).add(x));
final HCUL aULSG = new HCUL();
final ICommonsList<ISMPServiceGroup> aServiceGroups = aServiceGroupMgr.getAllSMPServiceGroups().getSortedInline(ISMPServiceGroup.comparator());
for (final ISMPServiceGroup aServiceGroup : aServiceGroups) {
// Print service group
final IParticipantIdentifier aParticipantID = aServiceGroup.getParticipantIdentifier();
final HCLI aLISG = aULSG.addAndReturnItem(new HCA(createViewURL(aWPEC, CMenuSecure.MENU_SERVICE_GROUPS, aServiceGroup)).addChild(aParticipantID.getURIEncoded()));
final HCUL aULDT = new HCUL();
final ICommonsList<ISMPServiceInformation> aServiceInfos = aMap.get(aServiceGroup);
if (aServiceInfos != null) {
for (final ISMPServiceInformation aServiceInfo : aServiceInfos.getSortedInline(ISMPServiceInformation.comparator())) {
final HCUL aULP = new HCUL();
final IDocumentTypeIdentifier aDocTypeID = aServiceInfo.getDocumentTypeIdentifier();
final ICommonsList<ISMPProcess> aProcesses = aServiceInfo.getAllProcesses().getSortedInline(ISMPProcess.comparator());
for (final ISMPProcess aProcess : aProcesses) {
final BootstrapTable aEPTable = new BootstrapTable(HCCol.perc(40), HCCol.perc(40), HCCol.perc(20)).setBordered(true);
final ICommonsList<ISMPEndpoint> aEndpoints = aProcess.getAllEndpoints().getSortedInline(ISMPEndpoint.comparator());
for (final ISMPEndpoint aEndpoint : aEndpoints) {
final StringMap aParams = createParamMap(aServiceInfo, aProcess, aEndpoint);
final HCRow aBodyRow = aEPTable.addBodyRow();
final String sTransportProfile = aEndpoint.getTransportProfile();
final ISimpleURL aViewURL = createViewURL(aWPEC, aServiceInfo, aParams);
aBodyRow.addCell(new HCA(aViewURL).addChild(NiceNameUI.getTransportProfile(sTransportProfile, false)));
aBodyRow.addCell(aEndpoint.getEndpointReference());
final ISimpleURL aEditURL = createEditURL(aWPEC, aServiceInfo).addAll(aParams);
final ISimpleURL aCopyURL = createCopyURL(aWPEC, aServiceInfo).addAll(aParams);
final ISimpleURL aDeleteURL = createDeleteURL(aWPEC, aServiceInfo).addAll(aParams);
final ISimpleURL aPreviewURL = LinkHelper.getURLWithServerAndContext(aParticipantID.getURIPercentEncoded() + SMPRestFilter.PATH_SERVICES + aDocTypeID.getURIPercentEncoded());
aBodyRow.addAndReturnCell(new HCA(aViewURL).setTitle("View endpoint").addChild(EDefaultIcon.MAGNIFIER.getAsNode()), new HCTextNode(" "), new HCA(aEditURL).setTitle("Edit endpoint").addChild(EDefaultIcon.EDIT.getAsNode()), new HCTextNode(" "), new HCA(aCopyURL).setTitle("Copy endpoint").addChild(EDefaultIcon.COPY.getAsNode()), new HCTextNode(" "), new HCA(aDeleteURL).setTitle("Delete endpoint").addChild(EDefaultIcon.DELETE.getAsNode()), new HCTextNode(" "), new HCA(aPreviewURL).setTitle("Perform SMP query on endpoint").setTargetBlank().addChild(EFamFamIcon.SCRIPT_GO.getAsNode())).addClass(CSS_CLASS_RIGHT);
}
// Show process + endpoints
final HCLI aLI = aULP.addItem();
final HCDiv aDiv = div(NiceNameUI.getProcessID(aDocTypeID, aProcess.getProcessIdentifier(), false));
aLI.addChild(aDiv);
if (aEndpoints.isEmpty()) {
aDiv.addChild(" ").addChild(new HCA(aWPEC.getSelfHref().addAll(createParamMap(aServiceInfo, aProcess, (ISMPEndpoint) null)).add(CPageParam.PARAM_ACTION, ACTION_DELETE_PROCESS)).setTitle("Delete process").addChild(EDefaultIcon.DELETE.getAsNode()));
} else
aLI.addChild(aEPTable);
}
// Show document types + children
final HCLI aLI = aULDT.addItem();
final HCDiv aDiv = div().addChild(NiceNameUI.getDocumentTypeID(aServiceInfo.getDocumentTypeIdentifier(), false)).addChild(" ").addChild(new HCA(LinkHelper.getURLWithServerAndContext(aParticipantID.getURIPercentEncoded() + SMPRestFilter.PATH_SERVICES + aDocTypeID.getURIPercentEncoded())).setTitle("Perform SMP query on document type ").setTargetBlank().addChild(EFamFamIcon.SCRIPT_GO.getAsNode()));
aLI.addChild(aDiv);
if (aProcesses.isEmpty()) {
aDiv.addChild(" ").addChild(new HCA(aWPEC.getSelfHref().addAll(createParamMap(aServiceInfo, (ISMPProcess) null, (ISMPEndpoint) null)).add(CPageParam.PARAM_ACTION, ACTION_DELETE_DOCUMENT_TYPE)).setTitle("Delete document type").addChild(EDefaultIcon.DELETE.getAsNode()));
} else
aLI.addChild(aULP);
}
}
if (aServiceInfos == null || aServiceInfos.isEmpty() || aULDT.hasNoChildren())
aLISG.addChild(" ").addChild(badgeInfo("This service group has no assigned endpoints!"));
else
aLISG.addChild(aULDT);
}
aNodeList.addChild(aULSG);
}
use of com.helger.peppolid.IDocumentTypeIdentifier in project phoss-smp by phax.
the class PageSecureRedirect method isActionAllowed.
@Override
protected boolean isActionAllowed(@Nonnull final WebPageExecutionContext aWPEC, @Nonnull final EWebPageFormAction eFormAction, @Nullable final ISMPRedirect aSelectedObject) {
if (eFormAction == EWebPageFormAction.VIEW || eFormAction == EWebPageFormAction.COPY || eFormAction == EWebPageFormAction.EDIT || eFormAction == EWebPageFormAction.DELETE) {
final IIdentifierFactory aIdentifierFactory = SMPMetaManager.getIdentifierFactory();
final String sServiceGroupID = aWPEC.params().getAsString(FIELD_SERVICE_GROUP_ID);
final IParticipantIdentifier aServiceGroupID = aIdentifierFactory.parseParticipantIdentifier(sServiceGroupID);
final ISMPServiceGroup aServiceGroup = SMPMetaManager.getServiceGroupMgr().getSMPServiceGroupOfID(aServiceGroupID);
if (aServiceGroup != null) {
final String sDocTypeID = aWPEC.params().getAsString(FIELD_DOCTYPE_ID);
final IDocumentTypeIdentifier aDocTypeID = aIdentifierFactory.parseDocumentTypeIdentifier(sDocTypeID);
if (aDocTypeID != null) {
aWPEC.getRequestScope().attrs().putIn(ATTR_SERVICE_GROUP, aServiceGroup);
aWPEC.getRequestScope().attrs().putIn(ATTR_DOCTYPE_ID, aDocTypeID);
return true;
}
}
return false;
}
return super.isActionAllowed(aWPEC, eFormAction, aSelectedObject);
}
use of com.helger.peppolid.IDocumentTypeIdentifier in project phoss-smp by phax.
the class PageSecureRedirect method getSelectedObject.
@Override
@Nullable
protected ISMPRedirect getSelectedObject(@Nonnull final WebPageExecutionContext aWPEC, @Nullable final String sID) {
final IIdentifierFactory aIdentifierFactory = SMPMetaManager.getIdentifierFactory();
final String sServiceGroupID = aWPEC.params().getAsString(FIELD_SERVICE_GROUP_ID);
final IParticipantIdentifier aServiceGroupID = aIdentifierFactory.parseParticipantIdentifier(sServiceGroupID);
final ISMPServiceGroup aServiceGroup = SMPMetaManager.getServiceGroupMgr().getSMPServiceGroupOfID(aServiceGroupID);
if (aServiceGroup != null) {
final String sDocTypeID = aWPEC.params().getAsString(FIELD_DOCTYPE_ID);
final IDocumentTypeIdentifier aDocTypeID = aIdentifierFactory.parseDocumentTypeIdentifier(sDocTypeID);
if (aDocTypeID != null) {
final ISMPRedirectManager aRedirectMgr = SMPMetaManager.getRedirectMgr();
return aRedirectMgr.getSMPRedirectOfServiceGroupAndDocumentType(aServiceGroup, aDocTypeID);
}
}
return null;
}
use of com.helger.peppolid.IDocumentTypeIdentifier in project phoss-smp by phax.
the class PageSecureRedirect method validateAndSaveInputParameters.
@Override
protected void validateAndSaveInputParameters(@Nonnull final WebPageExecutionContext aWPEC, @Nullable final ISMPRedirect aSelectedObject, @Nonnull final FormErrorList aFormErrors, @Nonnull final EWebPageFormAction eFormAction) {
final boolean bEdit = eFormAction.isEdit();
final ISMPServiceGroupManager aServiceGroupManager = SMPMetaManager.getServiceGroupMgr();
final ISMPServiceInformationManager aServiceInfoMgr = SMPMetaManager.getServiceInformationMgr();
final ISMPRedirectManager aRedirectMgr = SMPMetaManager.getRedirectMgr();
final IIdentifierFactory aIdentifierFactory = SMPMetaManager.getIdentifierFactory();
final String sServiceGroupID = bEdit ? aSelectedObject.getServiceGroupID() : aWPEC.params().getAsString(FIELD_SERVICE_GROUP_ID);
ISMPServiceGroup aServiceGroup = null;
final String sDocTypeID = bEdit ? aSelectedObject.getDocumentTypeIdentifier().getURIEncoded() : aWPEC.params().getAsString(FIELD_DOCTYPE_ID);
IDocumentTypeIdentifier aDocTypeID = null;
final String sRedirectTo = aWPEC.params().getAsString(FIELD_REDIRECT_TO);
final String sSubjectUniqueIdentifier = aWPEC.params().getAsString(FIELD_SUBJECT_UNIQUE_IDENTIFIER);
// TODO add certificate redirect support
final X509Certificate aCertificate = null;
final String sExtension = aWPEC.params().getAsString(FIELD_EXTENSION);
// validations
if (StringHelper.hasNoText(sServiceGroupID))
aFormErrors.addFieldError(FIELD_SERVICE_GROUP_ID, "A Service Group must be selected!");
else {
aServiceGroup = aServiceGroupManager.getSMPServiceGroupOfID(aIdentifierFactory.parseParticipantIdentifier(sServiceGroupID));
if (aServiceGroup == null)
aFormErrors.addFieldError(FIELD_SERVICE_GROUP_ID, "The provided Service Group does not exist!");
}
if (StringHelper.hasNoText(sDocTypeID))
aFormErrors.addFieldError(FIELD_DOCTYPE_ID, "Document Type ID must not be empty!");
else {
aDocTypeID = aIdentifierFactory.parseDocumentTypeIdentifier(sDocTypeID);
if (aDocTypeID == null)
aFormErrors.addFieldError(FIELD_DOCTYPE_ID, "The provided Document Type ID has an invalid syntax!");
else {
if (aServiceGroup != null) {
if (aServiceInfoMgr.getSMPServiceInformationOfServiceGroupAndDocumentType(aServiceGroup, aDocTypeID) != null)
aFormErrors.addFieldError(FIELD_DOCTYPE_ID, "At least one Endpoint is registered for this Document Type. Delete the Endpoint before you can create a Redirect.");
else if (!bEdit && aRedirectMgr.getSMPRedirectOfServiceGroupAndDocumentType(aServiceGroup, aDocTypeID) != null)
aFormErrors.addFieldError(FIELD_DOCTYPE_ID, "Another Redirect for the provided Service Group and Document Type is already present.");
}
}
}
if (StringHelper.hasNoText(sRedirectTo))
aFormErrors.addFieldError(FIELD_REDIRECT_TO, "The Redirect URL must not be empty!");
else if (URLHelper.getAsURL(sRedirectTo) == null)
aFormErrors.addFieldError(FIELD_REDIRECT_TO, "The Redirect URL is not a valid URL!");
if (StringHelper.hasNoText(sSubjectUniqueIdentifier))
aFormErrors.addFieldError(FIELD_SUBJECT_UNIQUE_IDENTIFIER, "Subject Unique Identifier must not be empty!");
if (StringHelper.hasText(sExtension)) {
final IMicroDocument aDoc = MicroReader.readMicroXML(sExtension);
if (aDoc == null)
aFormErrors.addFieldError(FIELD_EXTENSION, "The Extension must be XML content.");
}
if (aFormErrors.isEmpty()) {
if (aRedirectMgr.createOrUpdateSMPRedirect(aServiceGroup, aDocTypeID, sRedirectTo, sSubjectUniqueIdentifier, aCertificate, sExtension) == null)
aWPEC.postRedirectGetInternal(error("Error creating the Redirect for Service Group '" + sServiceGroupID + "'."));
else
aWPEC.postRedirectGetInternal(success("The Redirect for Service Group '" + sServiceGroupID + "' was successfully saved."));
}
}
Aggregations