Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Genesys Backend
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
17
Issues
17
List
Boards
Labels
Service Desk
Milestones
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Genesys PGR
Genesys Backend
Commits
a86bd449
Commit
a86bd449
authored
Jul 24, 2014
by
Matija Obreza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Crop is AclAware
parent
ffec74c0
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
27 additions
and
13 deletions
+27
-13
src/main/java/org/genesys2/server/model/impl/Crop.java
src/main/java/org/genesys2/server/model/impl/Crop.java
+2
-1
src/main/java/org/genesys2/server/model/impl/CropRule.java
src/main/java/org/genesys2/server/model/impl/CropRule.java
+5
-0
src/main/java/org/genesys2/server/service/impl/CropServiceImpl.java
...ava/org/genesys2/server/service/impl/CropServiceImpl.java
+3
-3
src/main/java/org/genesys2/server/servlet/controller/rest/CropsController.java
...esys2/server/servlet/controller/rest/CropsController.java
+7
-7
src/main/webapp/WEB-INF/jsp/crop/index.jsp
src/main/webapp/WEB-INF/jsp/crop/index.jsp
+4
-0
src/main/webapp/client/index.html
src/main/webapp/client/index.html
+6
-2
No files found.
src/main/java/org/genesys2/server/model/impl/Crop.java
View file @
a86bd449
...
...
@@ -35,6 +35,7 @@ import javax.persistence.Transient;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.genesys2.server.model.AclAwareModel
;
import
org.genesys2.server.model.GlobalVersionedAuditedModel
;
import
org.genesys2.server.servlet.controller.rest.serialization.CropSerializer
;
import
org.hibernate.annotations.Type
;
...
...
@@ -50,7 +51,7 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize;
@Table
(
name
=
"crop"
)
@Indexed
@JsonSerialize
(
using
=
CropSerializer
.
class
)
public
class
Crop
extends
GlobalVersionedAuditedModel
{
public
class
Crop
extends
GlobalVersionedAuditedModel
implements
AclAwareModel
{
private
static
final
long
serialVersionUID
=
-
2686341831839109257L
;
...
...
src/main/java/org/genesys2/server/model/impl/CropRule.java
View file @
a86bd449
...
...
@@ -95,4 +95,9 @@ public class CropRule extends BusinessModel {
public
void
setCrop
(
Crop
crop
)
{
this
.
crop
=
crop
;
}
@Override
public
String
toString
()
{
return
"CropRule included="
+
included
+
" genus="
+
genus
+
" species="
+
species
+
" crop="
+
crop
.
getShortName
();
}
}
src/main/java/org/genesys2/server/service/impl/CropServiceImpl.java
View file @
a86bd449
...
...
@@ -234,7 +234,7 @@ public class CropServiceImpl implements CropService {
* Update a crop record in Genesys
*/
@Override
@PreAuthorize
(
"hasRole('ADMINISTRATOR')"
)
@PreAuthorize
(
"hasRole('ADMINISTRATOR')
or hasPermission(#crop, 'ADMINISTRATION')
"
)
@Transactional
(
readOnly
=
false
)
public
Crop
updateCrop
(
Crop
crop
,
String
name
,
String
description
,
String
i18n
)
{
LOG
.
info
(
"Updating crop "
+
crop
);
...
...
@@ -264,7 +264,7 @@ public class CropServiceImpl implements CropService {
}
@Override
@PreAuthorize
(
"hasRole('ADMINISTRATOR')"
)
@PreAuthorize
(
"hasRole('ADMINISTRATOR')
or hasPermission(#crop, 'ADMINISTRATION')
"
)
@Transactional
(
readOnly
=
false
)
public
CropRule
addCropRule
(
Crop
crop
,
String
genus
,
String
species
,
boolean
included
)
{
if
(
crop
==
null
||
StringUtils
.
isBlank
(
genus
))
{
...
...
@@ -274,7 +274,7 @@ public class CropServiceImpl implements CropService {
final
CropRule
rule
=
new
CropRule
();
rule
.
setCrop
(
crop
);
rule
.
setGenus
(
genus
);
rule
.
setSpecies
(
species
);
rule
.
setSpecies
(
StringUtils
.
defaultIfBlank
(
species
,
null
)
);
rule
.
setIncluded
(
included
);
cropRuleRepository
.
save
(
rule
);
return
rule
;
...
...
src/main/java/org/genesys2/server/servlet/controller/rest/CropsController.java
View file @
a86bd449
...
...
@@ -47,7 +47,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
@Controller
@PreAuthorize
(
"isAuthenticated()"
)
@RequestMapping
(
value
=
{
"/api/v0
"
,
"/json/v0
"
})
@RequestMapping
(
value
=
{
"/api/v0
/crops"
,
"/json/v0/crops
"
})
public
class
CropsController
extends
RestController
{
@Autowired
...
...
@@ -65,7 +65,7 @@ public class CropsController extends RestController {
* @return
* @throws AuthorizationException
*/
@RequestMapping
(
value
=
"
/crops
"
,
method
=
RequestMethod
.
GET
,
produces
=
{
MediaType
.
APPLICATION_JSON_VALUE
})
@RequestMapping
(
value
=
""
,
method
=
RequestMethod
.
GET
,
produces
=
{
MediaType
.
APPLICATION_JSON_VALUE
})
public
@ResponseBody
Object
listCrops
()
{
LOG
.
info
(
"Listing crops"
);
...
...
@@ -79,7 +79,7 @@ public class CropsController extends RestController {
* @return
* @throws ValidationException
*/
@RequestMapping
(
value
=
"
/crops"
,
method
=
RequestMethod
.
PUT
,
produces
=
{
MediaType
.
APPLICATION_JSON_VALUE
})
@RequestMapping
(
value
=
"
"
,
method
=
{
RequestMethod
.
PUT
,
RequestMethod
.
POST
}
,
produces
=
{
MediaType
.
APPLICATION_JSON_VALUE
})
public
@ResponseBody
Object
createCrop
(
@RequestBody
CropJson
cropJson
)
throws
ValidationException
{
LOG
.
info
(
"Creating crop"
);
...
...
@@ -114,7 +114,7 @@ public class CropsController extends RestController {
* @return
* @throws AuthorizationException
*/
@RequestMapping
(
value
=
"/
crops/
{shortName}"
,
method
=
RequestMethod
.
GET
,
produces
=
{
MediaType
.
APPLICATION_JSON_VALUE
})
@RequestMapping
(
value
=
"/{shortName}"
,
method
=
RequestMethod
.
GET
,
produces
=
{
MediaType
.
APPLICATION_JSON_VALUE
})
public
@ResponseBody
Object
getCrop
(
@PathVariable
(
"shortName"
)
String
shortName
)
throws
AuthorizationException
{
LOG
.
info
(
"Getting crop "
+
shortName
);
...
...
@@ -127,7 +127,7 @@ public class CropsController extends RestController {
* @return
* @throws AuthorizationException
*/
@RequestMapping
(
value
=
"/
crops/
{shortName}/descriptors"
,
method
=
RequestMethod
.
GET
,
produces
=
{
MediaType
.
APPLICATION_JSON_VALUE
})
@RequestMapping
(
value
=
"/{shortName}/descriptors"
,
method
=
RequestMethod
.
GET
,
produces
=
{
MediaType
.
APPLICATION_JSON_VALUE
})
public
@ResponseBody
Object
getCropDescriptors
(
@PathVariable
(
"shortName"
)
String
shortName
)
throws
AuthorizationException
{
LOG
.
info
(
"Getting crop descriptors "
+
shortName
);
...
...
@@ -142,7 +142,7 @@ public class CropsController extends RestController {
* @return
* @throws AuthorizationException
*/
@RequestMapping
(
value
=
"/
crops/
{shortName}/rules"
,
method
=
RequestMethod
.
GET
,
produces
=
{
MediaType
.
APPLICATION_JSON_VALUE
})
@RequestMapping
(
value
=
"/{shortName}/rules"
,
method
=
RequestMethod
.
GET
,
produces
=
{
MediaType
.
APPLICATION_JSON_VALUE
})
public
@ResponseBody
Object
getCropRules
(
@PathVariable
(
"shortName"
)
String
shortName
)
throws
AuthorizationException
{
LOG
.
info
(
"Getting crop rules "
+
shortName
);
...
...
@@ -157,7 +157,7 @@ public class CropsController extends RestController {
* @return
* @throws AuthorizationException
*/
@RequestMapping
(
value
=
"/
crops/
{shortName}/taxa"
,
method
=
RequestMethod
.
GET
,
produces
=
{
MediaType
.
APPLICATION_JSON_VALUE
})
@RequestMapping
(
value
=
"/{shortName}/taxa"
,
method
=
RequestMethod
.
GET
,
produces
=
{
MediaType
.
APPLICATION_JSON_VALUE
})
public
@ResponseBody
Object
getCropTaxa
(
@PathVariable
(
"shortName"
)
String
shortName
)
throws
AuthorizationException
{
LOG
.
info
(
"Getting crop taxa "
+
shortName
);
...
...
src/main/webapp/WEB-INF/jsp/crop/index.jsp
View file @
a86bd449
...
...
@@ -17,6 +17,10 @@
<c:out
value=
"
${
crop
.
getName
(
pageContext
.
response
.
locale
)
}
"
/>
</h1>
<security:authorize
access=
"hasRole('ADMINISTRATOR') or hasPermission(#crop, 'ADMINISTRATION')"
>
<a
href=
"
<c:url
value=
"/acl/${crop.class.name}/${crop.id}/permissions"
><c:param
name=
"back"
>
/c/${crop.shortName}
</c:param></c:url>
"
class=
"close"
>
<spring:message
code=
"edit-acl"
/></a>
</security:authorize>
<div
class=
"free-text"
>
<c:out
value=
"
${
crop
.
getDescription
(
pageContext
.
response
.
locale
)
}
"
/>
</div>
...
...
src/main/webapp/client/index.html
View file @
a86bd449
...
...
@@ -5,8 +5,6 @@
<title>
Demo
</title>
</head>
<body>
<script
src=
"../html/js/main.js"
></script>
<script
src=
"../html/js/client.js"
></script>
<a
href=
"index.html"
>
Index
</a>
<a
href=
"crop.html"
>
Crop
</a>
<div
class=
"form-horizontal"
>
...
...
@@ -23,6 +21,12 @@
<button
class=
"rest-api"
x-url=
"/methods"
>
List methods
</button>
<button
class=
"json-api"
x-url=
"/crops"
>
List crops JSON
</button>
<button
class=
"json-api"
x-url=
"/methods"
>
List methods JSON
</button>
<content
tag=
"javascript"
>
<script
src=
"../html/js/main.js"
></script>
<script
src=
"../html/js/client.js"
></script>
</content>
</body>
</html>
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