Skip to content

Commit 88ea0f4

Browse files
authored
Merge pull request #2253 from zlamalp/cabinet
RPC: Added API methods for managing publication systems
2 parents 8e0b6d8 + 8cc5294 commit 88ea0f4

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

perun-rpc/src/main/java/cz/metacentrum/perun/rpc/ApiCaller.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import cz.metacentrum.perun.cabinet.api.CabinetManager;
1010
import cz.metacentrum.perun.cabinet.model.Category;
1111
import cz.metacentrum.perun.cabinet.model.Publication;
12+
import cz.metacentrum.perun.cabinet.model.PublicationSystem;
1213
import cz.metacentrum.perun.cabinet.model.Thanks;
1314
import cz.metacentrum.perun.core.api.PerunClient;
1415
import cz.metacentrum.perun.registrar.model.Application;
@@ -422,6 +423,10 @@ public Publication getPublicationById(int id) throws PerunException {
422423
return getCabinetManager().getPublicationById(id);
423424
}
424425

426+
public PublicationSystem getPublicationSystemById(int id) throws PerunException {
427+
return getCabinetManager().getPublicationSystemById(id);
428+
}
429+
425430
public ApiCaller(ServletContext context, PerunPrincipal perunPrincipal, PerunClient client) throws InternalErrorException {
426431
Perun perun = WebApplicationContextUtils.getWebApplicationContext(context).getBean("perun", Perun.class);
427432

perun-rpc/src/main/java/cz/metacentrum/perun/rpc/methods/CabinetManagerMethod.java

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,46 @@ public List<PublicationSystem> call(ApiCaller ac, Deserializer parms) throws Pe
3232
}
3333
},
3434

35+
/*#
36+
* Deletes PublicationSystem by its ID.
37+
*
38+
* @param id int ID of PublicationSystem to delete.
39+
* @throw CabinetException When Category doesn't exists or has publications
40+
*/
41+
deletePublicationSystem {
42+
public Void call(ApiCaller ac, Deserializer parms) throws PerunException {
43+
ac.stateChangingCheck();
44+
ac.getCabinetManager().deletePublicationSystem(ac.getSession(), ac.getPublicationSystemById(parms.readInt("id")));
45+
return null;
46+
}
47+
},
48+
49+
/*#
50+
* Creates new PublicationSystem.
51+
*
52+
* @param pubsys PublicationSystem Publication system to create.
53+
* @return PublicationSystem Created PublicationSystem with ID set.
54+
*/
55+
createPublicationSystem {
56+
public PublicationSystem call(ApiCaller ac, Deserializer parms) throws PerunException {
57+
ac.stateChangingCheck();
58+
return ac.getCabinetManager().createPublicationSystem(ac.getSession(), parms.read("pubsys", PublicationSystem.class));
59+
}
60+
},
61+
62+
/*#
63+
* Updates PublicationSystem by its ID.
64+
*
65+
* @param pubsys PublicationSystem Publication system to update.
66+
* @return PublicationSystem Created PublicationSystem with ID set.
67+
*/
68+
updatePublicationSystem {
69+
public PublicationSystem call(ApiCaller ac, Deserializer parms) throws PerunException {
70+
ac.stateChangingCheck();
71+
return ac.getCabinetManager().updatePublicationSystem(ac.getSession(), parms.read("pubsys", PublicationSystem.class));
72+
}
73+
},
74+
3575
/*#
3676
* Return list of all Categories in Perun or empty list of none present.
3777
*

0 commit comments

Comments
 (0)