Java Code Examples for org.apache.ranger.plugin.model.RangerServiceDef#setId()
The following examples show how to use
org.apache.ranger.plugin.model.RangerServiceDef#setId() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PublicAPIsv2.java From ranger with Apache License 2.0 | 6 votes |
@PUT @Path("/api/servicedef/name/{name}") @PreAuthorize("hasRole('ROLE_SYS_ADMIN')") @Produces({ "application/json", "application/xml" }) public RangerServiceDef updateServiceDefByName(RangerServiceDef serviceDef, @PathParam("name") String name) { // serviceDef.name is immutable // if serviceDef.name is specified, it should be same as the param 'name' if(serviceDef.getName() == null) { serviceDef.setName(name); } else if(!serviceDef.getName().equals(name)) { throw restErrorUtil.createRESTException(HttpServletResponse.SC_BAD_REQUEST , "serviceDef name mismatch", true); } // ignore serviceDef.id - if specified. Retrieve using the given name and use id from the retrieved object RangerServiceDef existingServiceDef = getServiceDefByName(name); serviceDef.setId(existingServiceDef.getId()); if(StringUtils.isEmpty(serviceDef.getGuid())) { serviceDef.setGuid(existingServiceDef.getGuid()); } return serviceREST.updateServiceDef(serviceDef); }
Example 2
Source File: PublicAPIsv2.java From ranger with Apache License 2.0 | 5 votes |
@PUT @Path("/api/servicedef/{id}") @PreAuthorize("hasRole('ROLE_SYS_ADMIN')") @Produces({ "application/json", "application/xml" }) public RangerServiceDef updateServiceDef(RangerServiceDef serviceDef, @PathParam("id") Long id) { // if serviceDef.id is specified, it should be same as param 'id' if(serviceDef.getId() == null) { serviceDef.setId(id); } else if(!serviceDef.getId().equals(id)) { throw restErrorUtil.createRESTException(HttpServletResponse.SC_BAD_REQUEST , "serviceDef id mismatch", true); } return serviceREST.updateServiceDef(serviceDef); }