Skip to content

Commit

Permalink
Merge pull request #2253 from zlamalp/cabinet
Browse files Browse the repository at this point in the history
RPC: Added API methods for managing publication systems
  • Loading branch information
zlamalp authored Jun 11, 2019
2 parents 8e0b6d8 + 8cc5294 commit 88ea0f4
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import cz.metacentrum.perun.cabinet.api.CabinetManager;
import cz.metacentrum.perun.cabinet.model.Category;
import cz.metacentrum.perun.cabinet.model.Publication;
import cz.metacentrum.perun.cabinet.model.PublicationSystem;
import cz.metacentrum.perun.cabinet.model.Thanks;
import cz.metacentrum.perun.core.api.PerunClient;
import cz.metacentrum.perun.registrar.model.Application;
Expand Down Expand Up @@ -422,6 +423,10 @@ public Publication getPublicationById(int id) throws PerunException {
return getCabinetManager().getPublicationById(id);
}

public PublicationSystem getPublicationSystemById(int id) throws PerunException {
return getCabinetManager().getPublicationSystemById(id);
}

public ApiCaller(ServletContext context, PerunPrincipal perunPrincipal, PerunClient client) throws InternalErrorException {
Perun perun = WebApplicationContextUtils.getWebApplicationContext(context).getBean("perun", Perun.class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,46 @@ public List<PublicationSystem> call(ApiCaller ac, Deserializer parms) throws Pe
}
},

/*#
* Deletes PublicationSystem by its ID.
*
* @param id int ID of PublicationSystem to delete.
* @throw CabinetException When Category doesn't exists or has publications
*/
deletePublicationSystem {
public Void call(ApiCaller ac, Deserializer parms) throws PerunException {
ac.stateChangingCheck();
ac.getCabinetManager().deletePublicationSystem(ac.getSession(), ac.getPublicationSystemById(parms.readInt("id")));
return null;
}
},

/*#
* Creates new PublicationSystem.
*
* @param pubsys PublicationSystem Publication system to create.
* @return PublicationSystem Created PublicationSystem with ID set.
*/
createPublicationSystem {
public PublicationSystem call(ApiCaller ac, Deserializer parms) throws PerunException {
ac.stateChangingCheck();
return ac.getCabinetManager().createPublicationSystem(ac.getSession(), parms.read("pubsys", PublicationSystem.class));
}
},

/*#
* Updates PublicationSystem by its ID.
*
* @param pubsys PublicationSystem Publication system to update.
* @return PublicationSystem Created PublicationSystem with ID set.
*/
updatePublicationSystem {
public PublicationSystem call(ApiCaller ac, Deserializer parms) throws PerunException {
ac.stateChangingCheck();
return ac.getCabinetManager().updatePublicationSystem(ac.getSession(), parms.read("pubsys", PublicationSystem.class));
}
},

/*#
* Return list of all Categories in Perun or empty list of none present.
*
Expand Down

0 comments on commit 88ea0f4

Please sign in to comment.