[midPoint] [Midpoint 4.4]midpoint, .getDefaultHostname() does not exist.

Sébastien MARBRIER smarbrier at positivethinking.tech
Tue Jan 25 11:51:25 CET 2022


Hello Pavol,

I tried your proposal to impelement the method pointed by the second link but unfortunately it does not work because I can’t have access to a SystemConfigurationType object.
It is really disturbing because the only way I found to get one is ModelInteractionService.getSystemConfiguration(OperationResult parentResult) but I can’t find how to inkoke the OperationResult object in my case.

A workaround was given to me using the following piece of code:
link = midpoint.createAccountActivationLink(user);
The string is cut before SchemaConstants.ACCOUNT_ACTIVATION_PREFIX
hostName = link.substring(0, link.indexOf(SchemaConstants.ACCOUNT_ACTIVATION_PREFIX));

It is really not a proper way to do it and I am not sure it would work in a different configuration (let’s say in production)

I would assume to retrieve the system configuration would be easy using the midpoint object ?

Do you have any solution ?

Best regards,


[logo]<https://www.positivethinking.tech/>

Sébastien Marbrier  | Senior IT Consultant
smarbrier at positivethinking.tech<mailto:smarbrier at positivethinking.tech>

Tel. +41 21 601 81 00<tel:+41%2021%20601%2081%2000>

[Teams chat]<https://teams.microsoft.com/l/chat/0/0?users=smarbrier@positivethinking.tech>
 <https://teams.microsoft.com/l/chat/0/0?users=smarbrier@positivethinking.tech>
Chat with me on Teams<https://teams.microsoft.com/l/chat/0/0?users=smarbrier@positivethinking.tech>



[LinkedIn]<https://www.linkedin.com/company/the-positive-thinking-company/>  [Instagram] <https://www.instagram.com/positivethinkingcompany/>   [Vimeo] <https://twitter.com/PTC_Tech>   [Vimeo] <https://youtube.com/channel/UCfaImWa6r0IoZoUYLhbiF7w>
Avenue de cour, 135 – 1007 Lausanne
www.positivethinking.tech<https://www.positivethinking.tech/>

________________________________
Help save paper, do you really need to print this email?
The content of this email and any attachments are confidential and are intended solely for the person and/or company to whom they are addressed. The information may also be legally privileged. No employee or agent is authorized to conclude any binding agreement on behalf of Positive Thinking Company with another party by email without express written confirmation. If you have received this email in error, any use, reproduction or dissemination of this transmission is strictly prohibited. If you are not the intended recipient, please immediately notify the sender by return E-mail and delete this message, its attachments and all copies from your system. Internet communications cannot be guaranteed to be timely, secure, error or virus-free. The sender does not accept liability for any errors or omissions. Thank you for your cooperation.





From: Sébastien MARBRIER
Sent: jeudi, 20 janvier 2022 17:17
To: midPoint General Discussion <midpoint at lists.evolveum.com>
Cc: Pavol Mederly <mederly at evolveum.com>
Subject: RE: [midPoint] [Midpoint 4.4]midpoint, .getDefaultHostname() does not exist.

Hello Pavol,

Thank you for your feedback.
Indeed it is very surprising to call a private method using a Groovy code.
I am going to test your proposal.

Best regards

[logo]<https://www.positivethinking.tech/>

Sébastien Marbrier  | Senior IT Consultant
smarbrier at positivethinking.tech<mailto:smarbrier at positivethinking.tech>

Tel. +41 21 601 81 00<tel:+41%2021%20601%2081%2000>

[Teams chat]<https://teams.microsoft.com/l/chat/0/0?users=smarbrier@positivethinking.tech>
 <https://teams.microsoft.com/l/chat/0/0?users=smarbrier@positivethinking.tech>
Chat with me on Teams<https://teams.microsoft.com/l/chat/0/0?users=smarbrier@positivethinking.tech>



[LinkedIn]<https://www.linkedin.com/company/the-positive-thinking-company/>  [Instagram] <https://www.instagram.com/positivethinkingcompany/>   [Vimeo] <https://twitter.com/PTC_Tech>   [Vimeo] <https://youtube.com/channel/UCfaImWa6r0IoZoUYLhbiF7w>
Avenue de cour, 135 – 1007 Lausanne
www.positivethinking.tech<https://www.positivethinking.tech/>

________________________________
Help save paper, do you really need to print this email?
The content of this email and any attachments are confidential and are intended solely for the person and/or company to whom they are addressed. The information may also be legally privileged. No employee or agent is authorized to conclude any binding agreement on behalf of Positive Thinking Company with another party by email without express written confirmation. If you have received this email in error, any use, reproduction or dissemination of this transmission is strictly prohibited. If you are not the intended recipient, please immediately notify the sender by return E-mail and delete this message, its attachments and all copies from your system. Internet communications cannot be guaranteed to be timely, secure, error or virus-free. The sender does not accept liability for any errors or omissions. Thank you for your cooperation.


From: midPoint <midpoint-bounces at lists.evolveum.com<mailto:midpoint-bounces at lists.evolveum.com>> On Behalf Of Pavol Mederly via midPoint
Sent: jeudi, 20 janvier 2022 17:06
To: midpoint at lists.evolveum.com<mailto:midpoint at lists.evolveum.com>
Cc: Pavol Mederly <mederly at evolveum.com<mailto:mederly at evolveum.com>>
Subject: Re: [midPoint] [Midpoint 4.4]midpoint, .getDefaultHostname() does not exist.


Hello Sébastien,

it is really interesting. The getDefaultHostname() method is really there in 4.0.x, but it is marked as private:

https://github.com/Evolveum/midpoint/blob/6c7f51b64114c3d082688349f934abc0bf1a53e5/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/expr/MidpointFunctionsImpl.java#L1487-L1506

So (I assume) one of us developers removed it without any hesitation during his work. That's quite OK, as it is not a part of the public API.

(To be honest, some of midPoint APIs are quite volatile, although we try to provide at least basic backwards compatibility.)

It looks like Groovy allows the programmer to call even private methods.

Anyway, there is a similar method you can use - although it's again private ;)

https://github.com/Evolveum/midpoint/blob/36a1ed5d00de64149554163cc847ac6684f680f3/infra/schema/src/main/java/com/evolveum/midpoint/schema/util/SystemConfigurationTypeUtil.java#L49-L55

Or you can implement that functionality directly in your script code.

Best regards,

--

Pavol Mederly

Software developer

evolveum.com
On 20/01/2022 16:41, Sébastien MARBRIER via midPoint wrote:
Good morning Josua,

I understand this workaround but I am not sure it would work because there several possible hostname and we have to be sure to use the good one.
I keep this one as a last resort.

Thanks you very much for the suggestion.

Best regards,


[logo]<https://www.positivethinking.tech/>

Sébastien Marbrier  | Senior IT Consultant
smarbrier at positivethinking.tech<mailto:smarbrier at positivethinking.tech>

Tel. +41 21 601 81 00<tel:+41%2021%20601%2081%2000>

[Teams chat]<https://teams.microsoft.com/l/chat/0/0?users=smarbrier@positivethinking.tech>
 <https://teams.microsoft.com/l/chat/0/0?users=smarbrier@positivethinking.tech>
Chat with me on Teams<https://teams.microsoft.com/l/chat/0/0?users=smarbrier@positivethinking.tech>



[LinkedIn]<https://www.linkedin.com/company/the-positive-thinking-company/>  [Instagram] <https://www.instagram.com/positivethinkingcompany/>   [Vimeo] <https://twitter.com/PTC_Tech>   [Vimeo] <https://youtube.com/channel/UCfaImWa6r0IoZoUYLhbiF7w>
Avenue de cour, 135 – 1007 Lausanne
www.positivethinking.tech<https://www.positivethinking.tech/>

________________________________
Help save paper, do you really need to print this email?
The content of this email and any attachments are confidential and are intended solely for the person and/or company to whom they are addressed. The information may also be legally privileged. No employee or agent is authorized to conclude any binding agreement on behalf of Positive Thinking Company with another party by email without express written confirmation. If you have received this email in error, any use, reproduction or dissemination of this transmission is strictly prohibited. If you are not the intended recipient, please immediately notify the sender by return E-mail and delete this message, its attachments and all copies from your system. Internet communications cannot be guaranteed to be timely, secure, error or virus-free. The sender does not accept liability for any errors or omissions. Thank you for your cooperation.



From: midPoint <midpoint-bounces at lists.evolveum.com><mailto:midpoint-bounces at lists.evolveum.com> On Behalf Of Joshua Williams via midPoint
Sent: jeudi, 20 janvier 2022 16:14
To: midPoint General Discussion <midpoint at lists.evolveum.com><mailto:midpoint at lists.evolveum.com>
Cc: Joshua Williams <jwilliams+list at globalnaz.org><mailto:jwilliams+list at globalnaz.org>
Subject: Re: [midPoint] [Midpoint 4.4]midpoint, .getDefaultHostname() does not exist.

Good morning Sebastian,
I routed around that problem by typing out the URL I wanted

bodyMessage += “blah blah” + “https://my.midpoint.tld”

That is not the most elegant solution, but it has worked for us.

Josh


On Jan 20, 2022, at 8:00 AM, Sébastien MARBRIER via midPoint <midpoint at lists.evolveum.com<mailto:midpoint at lists.evolveum.com>> wrote:

Good afternoon,

I am currently updating a the email notification in my SystemConfiguration to send emails to the new users.

My configuration is very close to that is described in https://docs.evolveum.com/midpoint/reference/misc/self-registration/
I ensured that the property defaultHostname has been updated to  the new property publicHttpUrlPattern

                <subjectExpression>
                    <value>Texte</value>
                </subjectExpression>
                <bodyExpression>
                    <script xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                        <code>
                            import com.evolveum.midpoint.schema.constants.SchemaConstants;
                            import com.evolveum.midpoint.notifications.api.events.ModelEvent;
                            import com.evolveum.midpoint.xml.ns._public.common.common_3.NotificationMessageType;
                            import java.net.URLEncoder;
                            import java.nio.charset.StandardCharsets;

                            modelEvent = (ModelEvent) event;
                            newUser = modelEvent.getFocusContext().getObjectNew();
                            [snip]
                            bodyMessage += "blah blah " + midpoint.getDefaultHostname()  ;
                            return bodyMessage;
                        </code>
                    </script>
                </bodyExpression>
                <transport>mail</transport>
                <transport>file:xxxxx<file://xxxxx></transport>
            </simpleUserNotifier>

In the <mail> section I force the redirection to a file.

However no email is sent because for each account activation there is an exception message:

ERROR (com.evolveum.midpoint.notifications.api.NotificationManager): Event couldn't be processed; event = ModelEventImpl{id=1642688194449-0-1,requester=SimpleObjectRef{oid='00000000-0000-0000-0000-000000000002', objectType=user:00000000-0000-0000-0000-000000000002(administrator)},requestee=SimpleObjectRef{oid='8ce2d1eb-d694-4ca1-b57d-026df2404457', objectType=user:8ce2d1eb-d694-4ca1-b57d-026df2404457(name.name1)}}.
com.evolveum.midpoint.util.exception.SystemException: com.evolveum.midpoint.util.exception.ExpressionEvaluationException: Groovy Evaluation Failed: No signature of method:com.evolveum.midpoint.model.impl.expr.MidpointFunctionsImpl.getDefaultHostname() is applicable for argument types: () values: []

Here I am lost because the getDefaultHostname used to be in the SystemConfigurationType class in 3.5 but was removed as soon as 4.0.1:
https://evolveum.com/downloads/midpoint/3.5/midpoint-api-3.5-javadoc/com/evolveum/midpoint/xml/ns/_public/common/common_3/SystemConfigurationType.html
https://evolveum.com/downloads/midpoint/4.0.1/midpoint-api-4.0.1-javadoc/com/evolveum/midpoint/xml/ns/_public/common/common_3/SystemConfigurationType.html

Regarding the MidpointFunctionsImpl class. I am not able to find any reference to a getDefaultHostName method :  https://evolveum.com/downloads/midpoint/4.0.2/midpoint-4.0.2-javadoc/com/evolveum/midpoint/model/impl/expr/MidpointFunctionsImpl.html

As stated above this functionality was working in midpoint 4.0.1, could you please explain me where to find the new method or if there is something broken in 4.4 ?

Thank you very much for your precious help.

Best regards,


<image001.png><https://www.positivethinking.tech/>

Sébastien Marbrier  | Senior IT Consultant
smarbrier at positivethinking.tech<mailto:smarbrier at positivethinking.tech>

Tel. +41 21 601 81 00<tel:+41%2021%20601%2081%2000>

<image002.png><https://teams.microsoft.com/l/chat/0/0?users=smarbrier@positivethinking.tech>
 <https://teams.microsoft.com/l/chat/0/0?users=smarbrier@positivethinking.tech>
Chat with me on Teams<https://teams.microsoft.com/l/chat/0/0?users=smarbrier@positivethinking.tech>



<image003.png><https://www.linkedin.com/company/the-positive-thinking-company/>  <image004.png><https://www.instagram.com/positivethinkingcompany/>  <image005.png><https://twitter.com/PTC_Tech>  <image006.png><https://youtube.com/channel/UCfaImWa6r0IoZoUYLhbiF7w>
Avenue de cour, 135 – 1007 Lausanne
www.positivethinking.tech<https://www.positivethinking.tech/>

________________________________
Help save paper, do you really need to print this email?
The content of this email and any attachments are confidential and are intended solely for the person and/or company to whom they are addressed. The information may also be legally privileged. No employee or agent is authorized to conclude any binding agreement on behalf of Positive Thinking Company with another party by email without express written confirmation. If you have received this email in error, any use, reproduction or dissemination of this transmission is strictly prohibited. If you are not the intended recipient, please immediately notify the sender by return E-mail and delete this message, its attachments and all copies from your system. Internet communications cannot be guaranteed to be timely, secure, error or virus-free. The sender does not accept liability for any errors or omissions. Thank you for your cooperation.



________________________________
Positive Thinking Company puts security at a high priority in its conduct of business. Therefore, we have put our best efforts into ensuring that this email and its attached documents are error and virus-free. Nonetheless, full security of emails/documents cannot be ensured. Therefore, the recipient is responsible for checking the email/documents for threats with its own security measures, prior to opening it. Positive Thinking Company does not accept liability for any damage inflicted by using the content of this email/documents. If you are not the intended recipient, please notify the sender and delete this email/document.

_______________________________________________
midPoint mailing list
midPoint at lists.evolveum.com<mailto:midPoint at lists.evolveum.com>
https://lists.evolveum.com/mailman/listinfo/midpoint

________________________________
Positive Thinking Company puts security at a high priority in its conduct of business. Therefore, we have put our best efforts into ensuring that this email and its attached documents are error and virus-free. Nonetheless, full security of emails/documents cannot be ensured. Therefore, the recipient is responsible for checking the email/documents for threats with its own security measures, prior to opening it. Positive Thinking Company does not accept liability for any damage inflicted by using the content of this email/documents. If you are not the intended recipient, please notify the sender and delete this email/document.

_______________________________________________

midPoint mailing list

midPoint at lists.evolveum.com<mailto:midPoint at lists.evolveum.com>

https://lists.evolveum.com/mailman/listinfo/midpoint

________________________________
Positive Thinking Company puts security at a high priority in its conduct of business. Therefore, we have put our best efforts into ensuring that this email and its attached documents are error and virus-free. Nonetheless, full security of emails/documents cannot be ensured. Therefore, the recipient is responsible for checking the email/documents for threats with its own security measures, prior to opening it. Positive Thinking Company does not accept liability for any damage inflicted by using the content of this email/documents. If you are not the intended recipient, please notify the sender and delete this email/document.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.evolveum.com/pipermail/midpoint/attachments/20220125/d4708e90/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.png
Type: image/png
Size: 7735 bytes
Desc: image001.png
URL: <https://lists.evolveum.com/pipermail/midpoint/attachments/20220125/d4708e90/attachment-0006.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image002.png
Type: image/png
Size: 686 bytes
Desc: image002.png
URL: <https://lists.evolveum.com/pipermail/midpoint/attachments/20220125/d4708e90/attachment-0007.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image003.png
Type: image/png
Size: 2337 bytes
Desc: image003.png
URL: <https://lists.evolveum.com/pipermail/midpoint/attachments/20220125/d4708e90/attachment-0008.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image004.png
Type: image/png
Size: 2756 bytes
Desc: image004.png
URL: <https://lists.evolveum.com/pipermail/midpoint/attachments/20220125/d4708e90/attachment-0009.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image005.png
Type: image/png
Size: 2358 bytes
Desc: image005.png
URL: <https://lists.evolveum.com/pipermail/midpoint/attachments/20220125/d4708e90/attachment-0010.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image006.png
Type: image/png
Size: 2669 bytes
Desc: image006.png
URL: <https://lists.evolveum.com/pipermail/midpoint/attachments/20220125/d4708e90/attachment-0011.png>


More information about the midPoint mailing list