use of org.openstack4j.model.identity.v3.Service in project openstack4j by ContainX.
the class BaseOpenStackService method getServiceVersion.
@SuppressWarnings("rawtypes")
protected int getServiceVersion() {
OSClientSession session = OSClientSession.getCurrent();
if (session.getAuthVersion() == AuthVersion.V3) {
SortedSet<? extends Service> services = ((OSClientSession.OSClientSessionV3) session).getToken().getAggregatedCatalog().get(serviceType.getType());
Service service = ((OSClientSession.OSClientSessionV3) session).getToken().getAggregatedCatalog().get(serviceType.getType()).first();
if (services.isEmpty()) {
return 1;
}
return service.getVersion();
} else {
SortedSet<? extends Access.Service> services = ((OSClientSession.OSClientSessionV2) session).getAccess().getAggregatedCatalog().get(serviceType.getType());
Access.Service service = ((OSClientSession.OSClientSessionV2) session).getAccess().getAggregatedCatalog().get(serviceType.getType()).first();
if (services.isEmpty()) {
return 1;
}
return service.getVersion();
}
}
use of org.openstack4j.model.identity.v3.Service in project carbon-apimgt by wso2.
the class WSDL20ProcessorImpl method updateEndpointsOfSingleWSDL.
/**
* Update the endpoint information of the provided WSDL definition when an API and the environment details are
* provided
*
* @param api API
* @param environmentName name of the gateway environment
* @param environmentType type of the gateway environment
* @param wsdlDescription WSDL 2.0 definition
* @throws APIMgtWSDLException when error occurred while updating the endpoints
*/
private void updateEndpointsOfSingleWSDL(API api, String environmentName, String environmentType, Description wsdlDescription) throws APIMgtWSDLException {
Service[] serviceMap = wsdlDescription.getServices();
String organization = api.getOrganization();
try {
for (Service svc : serviceMap) {
Endpoint[] portMap = svc.getEndpoints();
for (Endpoint endpoint : portMap) {
EndpointElement element = endpoint.toElement();
String endpointTransport = determineURLTransport(endpoint.getAddress().getScheme(), api.getTransports());
setAddressUrl(element, new URI(APIUtil.getGatewayEndpoint(endpointTransport, environmentName, environmentType, organization) + api.getContext()));
}
}
} catch (URISyntaxException | APIManagementException e) {
throw new APIMgtWSDLException("Error while setting gateway access URLs in the WSDL", e);
}
}
use of org.openstack4j.model.identity.v3.Service in project carbon-apimgt by wso2.
the class WSDL20ProcessorImpl method getEndpoints.
/**
* Get endpoints defined in the provided WSDL description.
*
* @param description WSDL 2.0 description
* @return a Map of endpoint names and their URIs.
* @throws APIMgtWSDLException if error occurs while reading endpoints
*/
private Map<String, String> getEndpoints(Description description) throws APIMgtWSDLException {
Service[] services = description.getServices();
Map<String, String> serviceEndpointMap = new HashMap<>();
for (Service service : services) {
Endpoint[] endpoints = service.getEndpoints();
for (Endpoint endpoint : endpoints) {
serviceEndpointMap.put(endpoint.getName().toString(), endpoint.getAddress().toString());
}
}
return serviceEndpointMap;
}
use of org.openstack4j.model.identity.v3.Service in project webtools.servertools by eclipse.
the class Tomcat40Configuration method modifyServerPort.
/**
* Modify the port with the given id.
*
* @param id java.lang.String
* @param port int
*/
public void modifyServerPort(String id, int port) {
try {
if ("server".equals(id)) {
server.setPort(port + "");
isServerDirty = true;
firePropertyChangeEvent(MODIFY_PORT_PROPERTY, id, new Integer(port));
return;
}
int i = id.indexOf("/");
// If a connector in the instance Service
if (i < 0) {
int connNum = Integer.parseInt(id);
Connector connector = serverInstance.getConnector(connNum);
if (connector != null) {
connector.setPort(port + "");
isServerDirty = true;
firePropertyChangeEvent(MODIFY_PORT_PROPERTY, id, new Integer(port));
}
} else // Else a connector in another Service
{
int servNum = Integer.parseInt(id.substring(0, i));
int connNum = Integer.parseInt(id.substring(i + 1));
Service service = server.getService(servNum);
Connector connector = service.getConnector(connNum);
connector.setPort(port + "");
isServerDirty = true;
firePropertyChangeEvent(MODIFY_PORT_PROPERTY, id, new Integer(port));
}
} catch (Exception e) {
Trace.trace(Trace.SEVERE, "Error modifying server port " + id, e);
}
}
use of org.openstack4j.model.identity.v3.Service in project webtools.servertools by eclipse.
the class Tomcat41Configuration method getServerPorts.
/**
* Returns a list of ServerPorts that this configuration uses.
*
* @return java.util.List
*/
public List getServerPorts() {
List<ServerPort> ports = new ArrayList<ServerPort>();
// first add server port
try {
int port = Integer.parseInt(server.getPort());
ports.add(new ServerPort("server", Messages.portServer, port, "TCPIP"));
} catch (Exception e) {
// ignore
}
// add connectors
try {
String instanceServiceName = serverInstance.getService().getName();
int size = server.getServiceCount();
for (int i = 0; i < size; i++) {
Service service = server.getService(i);
int size2 = service.getConnectorCount();
for (int j = 0; j < size2; j++) {
Connector connector = service.getConnector(j);
String className = connector.getClassName();
String name = className;
String protocol = "TCPIP";
boolean advanced = true;
String[] contentTypes = null;
int port = -1;
try {
port = Integer.parseInt(connector.getPort());
} catch (Exception e) {
// ignore
}
if (HTTP_CONNECTOR.equals(className)) {
name = "HTTP Connector";
protocol = "HTTP";
contentTypes = new String[] { "web", "webservices" };
// check for AJP/1.3 Coyote connector
String protocolHandler = connector.getProtocolHandlerClassName();
if (JK_PROTOCOL_HANDLER.equals(protocolHandler)) {
name = "AJP/1.3 Connector";
protocol = "AJP/1.3";
} else {
// assume HTTP, check for HTTP SSL connector
try {
Element element = connector.getSubElement("Factory");
if (SSL_SOCKET_FACTORY.equals(element.getAttribute("className"))) {
name = "SSL Connector";
protocol = "SSL";
}
} catch (Exception e) {
// ignore
}
}
if ("HTTP".equals(protocol))
advanced = false;
} else if (APACHE_CONNECTOR.equals(className))
name = "Apache Connector";
String portId;
if (instanceServiceName != null && instanceServiceName.equals(service.getName()))
portId = Integer.toString(j);
else
portId = i + "/" + j;
if (className != null && className.length() > 0)
ports.add(new ServerPort(portId, name, port, protocol, contentTypes, advanced));
}
}
} catch (Exception e) {
Trace.trace(Trace.SEVERE, "Error getting server ports", e);
}
return ports;
}
Aggregations