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
fabio martelli
syncope
Commits
f80a560d
Commit
f80a560d
authored
Jan 17, 2017
by
Gianluca Filippone
Browse files
Adjusted Enactment Engine base url
parent
7f972ec8
Changes
7
Show whitespace changes
Inline
Side-by-side
core/src/test/resources/domains/MasterContent.xml
View file @
f80a560d
...
...
@@ -624,7 +624,7 @@ we are happy to inform you that the password request was execute successfully fo
<APlainAttr id="956a8440-1df7-4ed6-b156-04173ca47528" owner_id="ef028fc9-23bb-491b-828f-c923bb791bf5"
schema_id="enactmentEngineBaseURL"/>
<APlainAttrValue id="15f64e99-20cc-42ec-a77a-3396dea4248f" attribute_id="956a8440-1df7-4ed6-b156-04173ca47528"
stringValue="http://localhost:9080/choremocks/rest/v1
/choreography
"/>
stringValue="http://localhost:9080/choremocks/rest/v1"/>
<APlainAttr id="9ecee738-f994-4acd-8ee7-38f9946acdc0" owner_id="ef028fc9-23bb-491b-828f-c923bb791bf5"
schema_id="enactmentEngineUsername"/>
<APlainAttrValue id="42337c7c-7ff5-4fe6-b37c-7c7ff57fe646" attribute_id="9ecee738-f994-4acd-8ee7-38f9946acdc0"
ext/choreography/client-console/src/main/java/org/apache/syncope/client/console/panels/ChoreographyEEResourcesPanel.java
View file @
f80a560d
...
...
@@ -59,7 +59,7 @@ public class ChoreographyEEResourcesPanel extends Panel {
this
.
choreography
=
restClient
.
getChoreography
(
choreographyId
);
this
.
enactmentEngine
=
restClient
.
getChoreographyEE
(
choreography
.
getId
());
EnactmentEngineStatusTO
ee
=
restClient
.
getChoreographyEEStatus
(
choreographyId
);
EnactmentEngineStatusTO
ee
=
restClient
.
getChoreographyEEStatus
(
enactmentEngine
.
getKey
(),
choreographyId
);
double
ramPercentage
=
(
ee
.
getRamUsage
()
/
Float
.
valueOf
(
ee
.
getRamTotal
()))
*
100
;
double
storagePercentage
=
(
ee
.
getStorageUsage
()
/
Float
.
valueOf
(
ee
.
getStorageTotal
()))
*
100
;
...
...
ext/choreography/client-console/src/main/java/org/apache/syncope/client/console/rest/ChoreographyRestClient.java
View file @
f80a560d
...
...
@@ -128,8 +128,10 @@ public class ChoreographyRestClient extends BaseRestClient {
return
getService
(
ChoreographyService
.
class
).
getEnactmentEngine
(
choreographyId
);
}
public
EnactmentEngineStatusTO
getChoreographyEEStatus
(
final
String
choreographyId
)
{
return
getService
(
MonitorInterfaceService
.
class
).
getChoreographyEEStatus
(
choreographyId
);
public
EnactmentEngineStatusTO
getChoreographyEEStatus
(
final
String
enactmentEngineKey
,
final
String
choreographyId
)
{
return
getService
(
MonitorInterfaceService
.
class
).
getChoreographyEEStatus
(
enactmentEngineKey
,
choreographyId
);
}
public
List
<
VirtualMachineInfoTO
>
getChoreographyVmList
(
...
...
ext/choreography/logic/src/main/java/org/apache/syncope/core/logic/ChoreographyLogic.java
View file @
f80a560d
...
...
@@ -109,6 +109,8 @@ public class ChoreographyLogic extends AbstractLogic<AbstractBaseBean> {
private
static
final
String
SECURITY_FILTER_ENDPOINT_SCHEMA
=
"SecurityFilterEndpoint"
;
private
static
final
String
CHOREOGRAPHY_URL_PATH
=
"/choreography"
;
private
static
String
SECRET_KEY
;
static
{
...
...
@@ -187,7 +189,8 @@ public class ChoreographyLogic extends AbstractLogic<AbstractBaseBean> {
List
<
Object
>
providers
=
new
ArrayList
<>();
providers
.
add
(
new
JacksonJaxbJsonProvider
());
return
WebClient
.
create
(
StringUtils
.
removeEndIgnoreCase
(
baseURL
,
"/"
)
+
endpoint
,
providers
,
username
,
password
,
null
).
StringUtils
.
removeEndIgnoreCase
(
baseURL
,
"/"
)
+
CHOREOGRAPHY_URL_PATH
+
endpoint
,
providers
,
username
,
password
,
null
).
accept
(
MediaType
.
APPLICATION_JSON_TYPE
).
type
(
MediaType
.
APPLICATION_XML_TYPE
);
}
...
...
ext/choreography/logic/src/main/java/org/apache/syncope/core/logic/MonitorLogic.java
View file @
f80a560d
...
...
@@ -34,11 +34,16 @@ import eu.chorevolution.idm.common.types.EventType;
import
eu.chorevolution.idm.common.types.InstanceStatusType
;
import
java.util.ArrayList
;
import
java.util.LinkedList
;
import
java.util.Map
;
import
javax.ws.rs.WebApplicationException
;
import
javax.ws.rs.core.MediaType
;
import
javax.ws.rs.core.Response
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.cxf.jaxrs.client.WebClient
;
import
org.apache.syncope.common.lib.to.AnyObjectTO
;
import
org.apache.syncope.common.lib.to.AttrTO
;
import
org.apache.syncope.common.lib.to.PlainSchemaTO
;
import
org.apache.syncope.common.lib.types.SchemaType
;
import
org.apache.syncope.core.persistence.api.dao.ChoreographyDAO
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
...
...
@@ -46,8 +51,10 @@ import org.apache.syncope.core.persistence.api.dao.EventDAO;
import
org.apache.syncope.core.persistence.api.entity.Event
;
import
org.apache.syncope.core.persistence.api.entity.ChoreographyInstance
;
import
org.apache.syncope.core.persistence.api.dao.ChoreographyInstanceDAO
;
import
org.apache.syncope.core.persistence.api.dao.NotFoundException
;
import
org.apache.syncope.core.persistence.api.entity.group.GPlainAttr
;
import
org.apache.syncope.core.persistence.api.entity.group.Group
;
import
org.apache.syncope.core.spring.security.Encryptor
;
@Component
public
class
MonitorLogic
extends
AbstractTransactionalLogic
<
AbstractBaseBean
>
{
...
...
@@ -61,11 +68,21 @@ public class MonitorLogic extends AbstractTransactionalLogic<AbstractBaseBean> {
@Autowired
private
EventDAO
eventDAO
;
private
static
final
String
MONITOR_BASE_URL
=
"http://localhost:9080/choremocks/rest/v1/monitoring
"
;
private
static
final
String
ENACTMENT_ENGINE_TYPE
=
"ENACTMENT ENGINE
"
;
private
static
final
String
MONITOR_USERNAME
=
"admin
"
;
private
static
final
String
ENACTMENT_ENGINE_BASE_URL
=
"enactmentEngineBaseURL
"
;
private
static
final
String
MONITOR_PASSWORD
=
"admin"
;
private
static
final
String
ENACTMENT_ENGINE_USERNAME
=
"enactmentEngineUsername"
;
private
static
final
String
ENACTMENT_ENGINE_PASSWORD
=
"enactmentEnginePassword"
;
private
static
final
String
MONITOR_URL_PATH
=
"/monitoring"
;
@Autowired
private
AnyObjectLogic
anyObjectLogic
;
@Autowired
private
SchemaLogic
schemaLogic
;
@Override
protected
AbstractBaseBean
resolveReference
(
final
Method
method
,
final
Object
...
args
)
...
...
@@ -74,12 +91,53 @@ public class MonitorLogic extends AbstractTransactionalLogic<AbstractBaseBean> {
throw
new
UnresolvedReferenceException
();
}
private
WebClient
getMonitorWebClient
(
final
String
endpoint
)
throws
Exception
{
private
WebClient
getMonitorWebClient
(
final
String
enactmentEngineKey
,
final
String
endpoint
)
throws
Exception
{
AnyObjectTO
enactmentEngine
=
anyObjectLogic
.
read
(
enactmentEngineKey
);
if
(!
ENACTMENT_ENGINE_TYPE
.
equals
(
enactmentEngine
.
getType
()))
{
throw
new
NotFoundException
(
"Enactment Engine instance with key "
+
enactmentEngineKey
);
}
return
getMonitorWebClient
(
enactmentEngine
,
endpoint
);
}
private
WebClient
getMonitorWebClient
(
final
AnyObjectTO
enactmentEngine
,
final
String
endpoint
)
throws
Exception
{
Map
<
String
,
AttrTO
>
plainAttrs
=
enactmentEngine
.
getPlainAttrMap
();
String
baseURL
=
null
;
if
(
plainAttrs
.
containsKey
(
ENACTMENT_ENGINE_BASE_URL
))
{
List
<
String
>
values
=
plainAttrs
.
get
(
ENACTMENT_ENGINE_BASE_URL
).
getValues
();
if
(!
values
.
isEmpty
())
{
baseURL
=
values
.
get
(
0
);
}
}
if
(
baseURL
==
null
)
{
throw
new
IllegalArgumentException
(
"Could not find "
+
ENACTMENT_ENGINE_BASE_URL
+
" for "
+
enactmentEngine
.
getKey
());
}
String
username
=
null
;
if
(
plainAttrs
.
containsKey
(
ENACTMENT_ENGINE_USERNAME
))
{
List
<
String
>
values
=
plainAttrs
.
get
(
ENACTMENT_ENGINE_USERNAME
).
getValues
();
if
(!
values
.
isEmpty
())
{
username
=
values
.
get
(
0
);
}
}
String
password
=
null
;
if
(
plainAttrs
.
containsKey
(
ENACTMENT_ENGINE_PASSWORD
))
{
List
<
String
>
values
=
plainAttrs
.
get
(
ENACTMENT_ENGINE_PASSWORD
).
getValues
();
if
(!
values
.
isEmpty
())
{
PlainSchemaTO
enactmentEnginePasswordSchema
=
schemaLogic
.
read
(
SchemaType
.
PLAIN
,
ENACTMENT_ENGINE_PASSWORD
);
password
=
Encryptor
.
getInstance
(
enactmentEnginePasswordSchema
.
getSecretKey
()).
decode
(
values
.
get
(
0
),
enactmentEnginePasswordSchema
.
getCipherAlgorithm
());
}
}
List
<
Object
>
providers
=
new
ArrayList
<>();
providers
.
add
(
new
JacksonJaxbJsonProvider
());
return
WebClient
.
create
(
StringUtils
.
removeEndIgnoreCase
(
MONITOR_BASE_URL
,
"/"
)
+
endpoint
,
providers
,
MONITOR_USERNAME
,
MONITOR_PASSWORD
,
null
).
StringUtils
.
removeEndIgnoreCase
(
baseURL
,
"/"
)
+
MONITOR_URL_PATH
+
endpoint
,
providers
,
username
,
password
,
null
).
accept
(
MediaType
.
APPLICATION_JSON_TYPE
).
type
(
MediaType
.
APPLICATION_XML_TYPE
);
}
...
...
@@ -742,7 +800,7 @@ public class MonitorLogic extends AbstractTransactionalLogic<AbstractBaseBean> {
public
EnactmentEngineStatusTO
getEnactmentEngineStatus
(
final
String
enactmentEngineKey
)
{
try
{
WebClient
webClient
=
getMonitorWebClient
(
"/ee"
);
WebClient
webClient
=
getMonitorWebClient
(
enactmentEngineKey
,
"/ee"
);
Response
response
=
webClient
.
get
();
if
(
response
.
getStatus
()
==
Response
.
Status
.
OK
.
getStatusCode
()
&&
response
.
hasEntity
())
{
...
...
@@ -760,7 +818,7 @@ public class MonitorLogic extends AbstractTransactionalLogic<AbstractBaseBean> {
List
<
VirtualMachineInfoTO
>
list
=
new
ArrayList
<>();
try
{
WebClient
webClient
=
getMonitorWebClient
(
"/ee/vm"
);
WebClient
webClient
=
getMonitorWebClient
(
enactmentEngineKey
,
"/ee/vm"
);
Response
response
=
webClient
.
get
();
if
(
response
.
getStatus
()
==
Response
.
Status
.
OK
.
getStatusCode
()
&&
response
.
hasEntity
())
{
...
...
@@ -779,9 +837,11 @@ public class MonitorLogic extends AbstractTransactionalLogic<AbstractBaseBean> {
return
list
;
}
public
EnactmentEngineStatusTO
getChoreographyEEStatus
(
final
String
choreographyId
)
{
public
EnactmentEngineStatusTO
getChoreographyEEStatus
(
final
String
enactmentEngineKey
,
final
String
choreographyId
)
{
try
{
WebClient
webClient
=
getMonitorWebClient
(
"/chor/"
+
choreographyId
);
WebClient
webClient
=
getMonitorWebClient
(
enactmentEngineKey
,
"/chor/"
+
choreographyId
);
Response
response
=
webClient
.
get
();
if
(
response
.
getStatus
()
==
Response
.
Status
.
OK
.
getStatusCode
()
&&
response
.
hasEntity
())
{
...
...
@@ -802,7 +862,7 @@ public class MonitorLogic extends AbstractTransactionalLogic<AbstractBaseBean> {
List
<
VirtualMachineInfoTO
>
list
=
new
ArrayList
<>();
try
{
WebClient
webClient
=
getMonitorWebClient
(
"/chor/"
+
choreographyId
+
"/vm"
);
WebClient
webClient
=
getMonitorWebClient
(
enactmentEngineKey
,
"/chor/"
+
choreographyId
+
"/vm"
);
Response
response
=
webClient
.
get
();
if
(
response
.
getStatus
()
==
Response
.
Status
.
OK
.
getStatusCode
()
&&
response
.
hasEntity
())
{
...
...
ext/choreography/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/MonitorInterfaceService.java
View file @
f80a560d
...
...
@@ -224,12 +224,15 @@ public interface MonitorInterfaceService extends JAXRSService {
/**
* Returns the enactment engine associated to the choreography
*
* @param enactmentEngineKey enactment engine key
* @param choreographyId choreography id
* @return status of enactment engine for the choreography
*/
@GET
@Path
(
"{choreographyId}/eeStatus"
)
EnactmentEngineStatusTO
getChoreographyEEStatus
(
@NotNull
@PathParam
(
"choreographyId"
)
String
choreographyId
);
@Path
(
"{enactmentEngineKey}/{choreographyId}/eeStatus"
)
EnactmentEngineStatusTO
getChoreographyEEStatus
(
@NotNull
@PathParam
(
"enactmentEngineKey"
)
String
enactmentEngineKey
,
@NotNull
@PathParam
(
"choreographyId"
)
String
choreographyId
);
/**
* Returns the enactment engine associated to the choreography
...
...
ext/choreography/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/MonitorInterfaceServiceImpl.java
View file @
f80a560d
...
...
@@ -126,8 +126,10 @@ public class MonitorInterfaceServiceImpl extends AbstractServiceImpl implements
}
@Override
public
EnactmentEngineStatusTO
getChoreographyEEStatus
(
final
String
choreographyId
)
{
return
logic
.
getChoreographyEEStatus
(
choreographyId
);
public
EnactmentEngineStatusTO
getChoreographyEEStatus
(
final
String
enactmentEngineKey
,
final
String
choreographyId
)
{
return
logic
.
getChoreographyEEStatus
(
enactmentEngineKey
,
choreographyId
);
}
@Override
...
...
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