Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CONF
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UvA
CONF
Commits
c0f77bfa
Commit
c0f77bfa
authored
Oct 18, 2017
by
Spiros Koulouzis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implemented monitoring message API
parent
a2209702
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
278 additions
and
4 deletions
+278
-4
DeployDao.java
...-api/src/main/java/nl/uva/sne/drip/api/dao/DeployDao.java
+0
-1
MonitorringMessageDao.java
...n/java/nl/uva/sne/drip/api/dao/MonitorringMessageDao.java
+27
-0
ConfigurationService.java
...ava/nl/uva/sne/drip/api/service/ConfigurationService.java
+0
-1
MonitorringMessageService.java
...l/uva/sne/drip/api/service/MonitorringMessageService.java
+73
-0
ToscaService.java
...c/main/java/nl/uva/sne/drip/api/service/ToscaService.java
+0
-2
MonitorringMessageController.java
...va/sne/drip/api/v1/rest/MonitorringMessageController.java
+84
-0
MonitorringMessage.java
...rip/drip/commons/data/v1/external/MonitorringMessage.java
+94
-0
No files found.
drip-api/src/main/java/nl/uva/sne/drip/api/dao/DeployDao.java
View file @
c0f77bfa
...
...
@@ -16,7 +16,6 @@
package
nl
.
uva
.
sne
.
drip
.
api
.
dao
;
import
nl.uva.sne.drip.drip.commons.data.v1.external.DeployResponse
;
import
nl.uva.sne.drip.drip.commons.data.v1.external.Key
;
import
nl.uva.sne.drip.drip.commons.data.v1.external.ansible.AnsibleResult
;
import
org.springframework.data.mongodb.repository.MongoRepository
;
import
org.springframework.data.mongodb.repository.Query
;
...
...
drip-api/src/main/java/nl/uva/sne/drip/api/dao/MonitorringMessageDao.java
0 → 100644
View file @
c0f77bfa
/*
* Copyright 2017 S. Koulouzis, Wang Junchao, Huan Zhou, Yang Hu
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
nl
.
uva
.
sne
.
drip
.
api
.
dao
;
import
nl.uva.sne.drip.drip.commons.data.v1.external.MonitorringMessage
;
import
org.springframework.data.mongodb.repository.MongoRepository
;
/**
*
* @author S. Koulouzis
*/
public
interface
MonitorringMessageDao
extends
MongoRepository
<
MonitorringMessage
,
String
>
{
}
drip-api/src/main/java/nl/uva/sne/drip/api/service/ConfigurationService.java
View file @
c0f77bfa
...
...
@@ -19,7 +19,6 @@ import java.io.IOException;
import
java.util.List
;
import
java.util.Map
;
import
nl.uva.sne.drip.api.exception.NotFoundException
;
import
nl.uva.sne.drip.commons.utils.Constants
;
import
nl.uva.sne.drip.drip.commons.data.v1.external.ConfigurationRepresentation
;
import
nl.uva.sne.drip.commons.utils.Converter
;
import
nl.uva.sne.drip.drip.commons.data.v1.external.User
;
...
...
drip-api/src/main/java/nl/uva/sne/drip/api/service/MonitorringMessageService.java
0 → 100644
View file @
c0f77bfa
/*
* Copyright 2017 S. Koulouzis, Wang Junchao, Huan Zhou, Yang Hu
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
nl
.
uva
.
sne
.
drip
.
api
.
service
;
import
java.util.List
;
import
nl.uva.sne.drip.api.dao.MonitorringMessageDao
;
import
nl.uva.sne.drip.api.exception.NotFoundException
;
import
nl.uva.sne.drip.drip.commons.data.v1.external.DeployResponse
;
import
nl.uva.sne.drip.drip.commons.data.v1.external.MonitorringMessage
;
import
nl.uva.sne.drip.drip.commons.data.v1.external.User
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.security.access.prepost.PostAuthorize
;
import
org.springframework.security.access.prepost.PostFilter
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.security.core.context.SecurityContextHolder
;
import
org.springframework.stereotype.Service
;
/**
*
* @author S. Koulouzis
*/
@Service
@PreAuthorize
(
"isAuthenticated()"
)
public
class
MonitorringMessageService
{
@Autowired
private
MonitorringMessageDao
dao
;
@PostAuthorize
(
"(returnObject.owner == authentication.name) or (hasRole('ROLE_ADMIN'))"
)
public
MonitorringMessage
delete
(
String
id
)
{
MonitorringMessage
tr
=
dao
.
findOne
(
id
);
if
(
tr
==
null
)
{
throw
new
NotFoundException
();
}
dao
.
delete
(
tr
);
return
tr
;
}
@PostFilter
(
"(filterObject.owner == authentication.name) or (hasRole('ROLE_ADMIN'))"
)
public
List
<
MonitorringMessage
>
findAll
()
{
return
dao
.
findAll
();
}
@PostAuthorize
(
"(returnObject.owner == authentication.name) or (hasRole('ROLE_ADMIN'))"
)
public
MonitorringMessage
findOne
(
String
id
)
{
return
dao
.
findOne
(
id
);
}
@PostAuthorize
(
"(hasRole('ROLE_ADMIN'))"
)
public
void
deleteAll
()
{
dao
.
deleteAll
();
}
public
MonitorringMessage
save
(
MonitorringMessage
message
)
{
User
user
=
(
User
)
SecurityContextHolder
.
getContext
().
getAuthentication
().
getPrincipal
();
String
owner
=
user
.
getUsername
();
message
.
setOwner
(
owner
);
return
dao
.
save
(
message
);
}
}
drip-api/src/main/java/nl/uva/sne/drip/api/service/ToscaService.java
View file @
c0f77bfa
...
...
@@ -23,9 +23,7 @@ import java.util.concurrent.TimeoutException;
import
nl.uva.sne.drip.api.dao.ToscaDao
;
import
nl.uva.sne.drip.api.exception.NotFoundException
;
import
nl.uva.sne.drip.api.rpc.DRIPCaller
;
import
nl.uva.sne.drip.api.rpc.DeployerCaller
;
import
nl.uva.sne.drip.api.rpc.TransformerCaller
;
import
nl.uva.sne.drip.commons.utils.Constants
;
import
nl.uva.sne.drip.drip.commons.data.v1.external.ToscaRepresentation
;
import
nl.uva.sne.drip.commons.utils.Converter
;
import
nl.uva.sne.drip.drip.commons.data.internal.Message
;
...
...
drip-api/src/main/java/nl/uva/sne/drip/api/v1/rest/MonitorringMessageController.java
0 → 100644
View file @
c0f77bfa
/*
* Copyright 2017 S. Koulouzis.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
nl
.
uva
.
sne
.
drip
.
api
.
v1
.
rest
;
import
com.webcohesion.enunciate.metadata.rs.ResponseCode
;
import
com.webcohesion.enunciate.metadata.rs.StatusCodes
;
import
java.util.ArrayList
;
import
java.util.List
;
import
javax.annotation.security.RolesAllowed
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
nl.uva.sne.drip.api.service.MonitorringMessageService
;
import
nl.uva.sne.drip.api.service.UserService
;
import
nl.uva.sne.drip.drip.commons.data.v1.external.MonitorringMessage
;
import
org.springframework.web.bind.annotation.RequestBody
;
/**
* This controller is responsible for storing TOSCA descriptions that can be
* used by the planner.
*
* @author S. Koulouzis
*/
@RestController
@RequestMapping
(
"/user/v1.0/monitorring_message"
)
@Component
@StatusCodes
({
@ResponseCode
(
code
=
401
,
condition
=
"Bad credentials"
)
})
public
class
MonitorringMessageController
{
@Autowired
private
MonitorringMessageService
monitorringMessageService
;
@RequestMapping
(
value
=
"/"
,
method
=
RequestMethod
.
POST
)
@RolesAllowed
({
UserService
.
USER
,
UserService
.
ADMIN
})
public
@ResponseBody
String
post
(
@RequestBody
MonitorringMessage
message
)
{
return
monitorringMessageService
.
save
(
message
).
getId
();
}
@RequestMapping
(
value
=
"/{id}"
,
method
=
RequestMethod
.
GET
,
params
=
{
"format"
})
@RolesAllowed
({
UserService
.
USER
,
UserService
.
ADMIN
})
public
@ResponseBody
MonitorringMessage
get
(
@PathVariable
(
"id"
)
String
id
,
@RequestParam
(
value
=
"format"
)
String
format
)
{
return
monitorringMessageService
.
findOne
(
id
);
}
/**
* Gets the IDs of all the stored TOSCA descriptions.
*
* @return a list of all the IDs
*/
@RequestMapping
(
value
=
"/ids"
,
method
=
RequestMethod
.
GET
)
@RolesAllowed
({
UserService
.
USER
,
UserService
.
ADMIN
})
public
@ResponseBody
List
<
String
>
getIds
()
{
List
<
MonitorringMessage
>
all
=
monitorringMessageService
.
findAll
();
List
<
String
>
ids
=
new
ArrayList
<>();
for
(
MonitorringMessage
tr
:
all
)
{
ids
.
add
(
tr
.
getId
());
}
return
ids
;
}
}
drip-commons/src/main/java/nl/uva/sne/drip/drip/commons/data/v1/external/MonitorringMessage.java
0 → 100644
View file @
c0f77bfa
/*
* Copyright 2017 S. Koulouzis, Wang Junchao, Huan Zhou, Yang Hu
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
nl
.
uva
.
sne
.
drip
.
drip
.
commons
.
data
.
v1
.
external
;
import
com.fasterxml.jackson.annotation.JsonInclude
;
import
com.webcohesion.enunciate.metadata.DocumentationExample
;
import
org.springframework.data.mongodb.core.mapping.Document
;
@Document
@JsonInclude
(
JsonInclude
.
Include
.
NON_NULL
)
public
class
MonitorringMessage
extends
OwnedObject
{
private
String
metricMame
;
private
String
subid
;
private
double
value
;
private
String
messageType
;
/**
* @return the metricMame
*/
@DocumentationExample
(
"cpuTotal"
)
public
String
getMetricMame
()
{
return
metricMame
;
}
/**
* @param metricMame the metricMame to set
*/
public
void
setMetricMame
(
String
metricMame
)
{
this
.
metricMame
=
metricMame
;
}
/**
* @return the subid
*/
@DocumentationExample
(
"1ccba0cc92174ce788695cfc0a027b57"
)
public
String
getSubid
()
{
return
subid
;
}
/**
* @param subid the subid to set
*/
public
void
setSubid
(
String
subid
)
{
this
.
subid
=
subid
;
}
/**
* @return the value
*/
@DocumentationExample
(
"91.0500021021063106"
)
public
double
getValue
()
{
return
value
;
}
/**
* @param value the value to set
*/
public
void
setValue
(
double
value
)
{
this
.
value
=
value
;
}
/**
* @return the messageType
*/
@DocumentationExample
(
"critical"
)
public
String
getMessageType
()
{
return
messageType
;
}
/**
* @param messageType the messageType to set
*/
public
void
setMessageType
(
String
messageType
)
{
this
.
messageType
=
messageType
;
}
}
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