Returning Observer

How to get server host name and port from content creator

I created workflow that will run script from wich I try to create connection and login ticket for certain user and send that trough email to that user.

Main line is this:

Connection connectionForExternalUser = ConnectionManager.getConnection("host name", 8443, ConnectionManager.HTTP_MODE, "user name", "user pass");

When i hardcode "host name" and "port" everything works fine from SA and from CC also. But when I try to get host name trough API, one of the next examples:

  host0 = context.getConnection().getHost();

  host1 = context.getScript().getProject().getUserService().getConnection().getHost();

  host2 = context.getUserService().getConnection().getHost();

  host3 = context.getProject().getConnection().getHost();

  host4 = context.getProject().getUserService().getConnection().getHost();

  host5 = context.getElement().getProject().getConnection().getHost();

then it works from SA (it returns server host name) but not from CC (returns empty string for every case). And I found that from CC I am getting diferent context and connection object then from SA.


workflow script context: class

workflow context: class de.espirit.firstspirit.client.gui.workflow.GuiHostWorkflowContext

connection: class


workflow script context: class de.espirit.firstspirit.webedit.server.workflow.WebeditWorkflowScriptContextImpl

workflow context: class de.espirit.firstspirit.webedit.server.workflow.WebeditWorkflowContext

connection: class

So, do you have any idea how I can get server host name and server port trough workflow-script from CC?

2 Replies
Crownpeak employee

Hello Milos,

please have a look at the ServerConfigurationAgent - I think that can help.

A small example:


import de.espirit.firstspirit.server.configuration.ServerProperties;

ServerConfigurationAgent sca = context.requireSpecialist(ServerConfigurationAgent.TYPE);

String hostname = sca.getServerProperty(ServerProperties.HOST).get();

int port = sca.getServerProperty(ServerProperties.HTTP_PORT).get();

You can find a list of more accessible properties here ​.


0 Kudos
Returning Observer

Hello Michael,

Thank you for your suggestion. I did not get proper information trough ServerProperties.HOST and ServerProperties.PORT. (it returns localhost and 8000).

But I found ServerProperties.URL from where I get object and then request getHost() and getPort().


0 Kudos