Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
CHOReVOLUTION
enactment-engine
Commits
8d37b84b
Commit
8d37b84b
authored
Oct 06, 2016
by
Alessio Carenini
Browse files
Integration with identity manager (notification)
parent
3f030564
Changes
1
Hide whitespace changes
Inline
Side-by-side
ee2/brooklyn-library/software/webapp/src/main/java/org/apache/brooklyn/entity/webapp/chorevolution/ChoreographyImpl.java
View file @
8d37b84b
...
...
@@ -18,6 +18,7 @@ package org.apache.brooklyn.entity.webapp.chorevolution;
import
java.io.BufferedReader
;
import
java.io.IOException
;
import
java.io.InputStreamReader
;
import
java.net.URI
;
import
java.net.URL
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
...
...
@@ -30,9 +31,7 @@ import java.util.concurrent.ExecutorService;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.atomic.AtomicInteger
;
import
javax.ws.rs.client.ClientBuilder
;
import
javax.ws.rs.client.WebTarget
;
import
javax.ws.rs.core.MediaType
;
import
javax.xml.bind.JAXBException
;
import
javax.xml.namespace.QName
;
import
javax.xml.soap.MessageFactory
;
import
javax.xml.soap.SOAPBody
;
...
...
@@ -55,8 +54,11 @@ import org.apache.brooklyn.api.location.Location;
import
org.apache.brooklyn.core.entity.AbstractApplication
;
import
org.apache.brooklyn.core.entity.lifecycle.Lifecycle
;
import
org.apache.brooklyn.core.entity.lifecycle.ServiceStateLogic
;
import
org.apache.brooklyn.core.location.cloud.CloudLocationConfig
;
import
org.apache.brooklyn.entity.webapp.tomcat.Tomcat8Server
;
import
org.apache.cxf.endpoint.Client
;
import
org.apache.brooklyn.util.http.HttpTool
;
import
org.apache.http.HttpHeaders
;
import
org.apache.http.auth.UsernamePasswordCredentials
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -75,7 +77,7 @@ import eu.chorevolution.datamodel.deployment.DeploymentLocation;
public
class
ChoreographyImpl
extends
AbstractApplication
implements
Choreography
{
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
ChoreographyImpl
.
class
);
private
static
final
String
idm_ep_notification
=
"/chors/%s/%s/notifyCompletion"
;
private
static
final
String
tenant
=
null
;
@Override
...
...
@@ -86,14 +88,28 @@ public class ChoreographyImpl extends AbstractApplication implements Choreograph
public
void
postStart
(
Collection
<?
extends
Location
>
locations
)
{
eu
.
chorevolution
.
datamodel
.
Choreography
chor
=
getChorSpec
();
/*
Client client = ClientBuilder.newClient(config);
WebTarget target = client.target(getBaseURI());
// Get XML
String xmlResponse = target.path("rest").path("todo").request()
.accept(MediaType.TEXT_XML).get(String.class);
*/
Map
<
String
,
String
>
headers
=
new
HashMap
<
String
,
String
>();
headers
.
put
(
HttpHeaders
.
CONTENT_TYPE
,
"application/xml"
);
for
(
Location
l:
locations
)
{
String
idm_endpoint
=
l
.
getConfig
(
CloudLocationConfig
.
IDENTITY_MANAGER_ENDPOINT
);
String
idm_user
=
l
.
getConfig
(
CloudLocationConfig
.
IDENTITY_MANAGER_ENDPOINT_USERNAME
);
String
idm_pass
=
l
.
getConfig
(
CloudLocationConfig
.
IDENTITY_MANAGER_ENDPOINT_PASSWORD
);
if
(
idm_endpoint
!=
null
)
{
String
chor_xml
;
try
{
chor_xml
=
chor
.
getXML
();
HttpTool
.
httpPost
(
HttpTool
.
httpClientBuilder
().
uri
(
idm_endpoint
).
credentials
(
new
UsernamePasswordCredentials
(
idm_user
,
idm_pass
)).
build
(),
URI
.
create
(
String
.
format
(
idm_ep_notification
,
getId
(),
"CREATE"
)),
headers
,
chor_xml
.
getBytes
());
}
catch
(
JAXBException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
catch
(
XMLStreamException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
}
}
}
public
eu
.
chorevolution
.
datamodel
.
Choreography
getChorSpec
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment