gluu
クラス | 公開メンバ関数 | 静的公開メンバ関数 | 静的公開変数類 | 限定公開メンバ関数 | 関数 | 変数 | 非公開メンバ関数 | 非公開変数類 | 全メンバ一覧
org.gluu.oxtrust.ws.rs.scim2.BulkWebService クラス
org.gluu.oxtrust.ws.rs.scim2.BulkWebService の継承関係図
Inheritance graph
org.gluu.oxtrust.ws.rs.scim2.BulkWebService 連携図
Collaboration graph

クラス

enum  Verb
 

公開メンバ関数

.ws.rs.POST Response processBulkOperations (@ApiParam(value="BulkRequest", required=true) BulkRequest request)
 
void setup ()
 
String getEndpointUrl ()
 

静的公開メンバ関数

static Response getErrorResponse (Response.Status status, String detail)
 
static Response getErrorResponse (Response.Status status, ErrorScimType scimType, String detail)
 
static Response getErrorResponse (int statusCode, ErrorScimType scimType, String detail)
 

静的公開変数類

static final String SEARCH_SUFFIX = ".search"
 

限定公開メンバ関数

void assignMetaInformation (BaseScimResource resource)
 
void executeDefaultValidation (BaseScimResource resource) throws SCIMException
 
void executeValidation (BaseScimResource resource, boolean skipRequired) throws SCIMException
 
Response prepareSearchRequest (List< String > schemas, String filter, String sortBy, String sortOrder, Integer startIndex, Integer count, String attrsList, String excludedAttrsList, SearchRequest request)
 
Response inspectPatchRequest (PatchRequest patch, Class<? extends BaseScimResource > cls)
 

関数

int getMaxCount ()
 
String getValueFromHeaders (HttpHeaders headers, String name)
 
String translateSortByAttribute (Class<? extends BaseScimResource > cls, String sortBy)
 
String getListResponseSerialized (int total, int startIndex, List< BaseScimResource > resources, String attrsList, String excludedAttrsList, boolean ignoreResults) throws IOException
 

変数

Logger log
 
AppConfiguration appConfiguration
 
ScimResourceSerializer resourceSerializer
 
ExtensionService extService
 
String endpointUrl
 

非公開メンバ関数

Response prepareRequest (BulkRequest request, String contentLength)
 
BaseScimWebService getWSForPath (String path)
 
String adjustPath (String path)
 
String getFragment (String path, BaseScimWebService service, Map< String, String > idsMap) throws Exception
 
String replaceBulkIds (String str, Map< String, String > idsMap) throws Exception
 
Pair< Response, String > execute (Verb verb, BaseScimWebService ws, String data, String fragment)
 

非公開変数類

final Pattern bulkIdPattern = Pattern.compile("bulkId:(\\w+)")
 
List< VerbavailableMethods
 
ObjectMapper mapper =new ObjectMapper()
 
String usersEndpoint
 
String groupsEndpoint
 
String fidodevicesEndpoint
 
String commonWsEndpointPrefix
 
UserWebService userWS
 
GroupWebService groupWS
 
FidoDeviceWebService fidoDeviceWS
 
HttpHeaders httpHeaders
 

詳解

SCIM Bulk Endpoint Implementation

著者
Rahat ALi Date: 05.08.2015 Re-engineered by jgomer on 2017-11-23.

クラス詳解

◆ org::gluu::oxtrust::ws::rs::scim2::BulkWebService::Verb

enum org::gluu::oxtrust::ws::rs::scim2::BulkWebService::Verb
org.gluu.oxtrust.ws.rs.scim2.BulkWebService.Verb 連携図
Collaboration graph
列挙値
DELETE
PATCH
POST
PUT

関数詳解

◆ adjustPath()

String org.gluu.oxtrust.ws.rs.scim2.BulkWebService.adjustPath ( String  path)
inlineprivate
300  {
301  return path.startsWith(commonWsEndpointPrefix) ? path : commonWsEndpointPrefix + path;
302  }
String commonWsEndpointPrefix
Definition: BulkWebService.java:86

◆ assignMetaInformation()

void org.gluu.oxtrust.ws.rs.scim2.BaseScimWebService.assignMetaInformation ( BaseScimResource  resource)
inlineprotectedinherited
102  {
103 
104  //Generate some meta information (this replaces the info client passed in the request)
105  long now=new Date().getTime();
106  String val= ISODateTimeFormat.dateTime().withZoneUTC().print(now);
107 
108  Meta meta=new Meta();
109  meta.setResourceType(ScimResourceUtil.getType(resource.getClass()));
110  meta.setCreated(val);
111  meta.setLastModified(val);
112  //For version attritute: Service provider support for this attribute is optional and subject to the service provider's support for versioning
113  //For location attribute: this will be set after current user creation in LDAP
114  resource.setMeta(meta);
115 
116  }

◆ execute()

Pair<Response, String> org.gluu.oxtrust.ws.rs.scim2.BulkWebService.execute ( Verb  verb,
BaseScimWebService  ws,
String  data,
String  fragment 
)
inlineprivate
330  {
331 
332  Response response=null;
333  String idCreated=null;
334 
335  try {
336  if (ws==userWS)
337  switch (verb){
338  case PUT:
339  UserResource user=mapper.readValue(data, UserResource.class);
340  response=userWS.updateUser(user, fragment, "id", null);
341  break;
342  case DELETE:
343  response=userWS.deleteUser(fragment);
344  break;
345  case PATCH:
346  PatchRequest pr=mapper.readValue(data, PatchRequest.class);
347  response=userWS.patchUser(pr, fragment, "id", null);
348  break;
349  case POST:
350  user=mapper.readValue(data, UserResource.class);
351  response=userWS.createUser(user, "id", null);
352  if (CREATED.getStatusCode()==response.getStatus()) {
353  user = mapper.readValue(response.getEntity().toString(), UserResource.class);
354  idCreated = user.getId();
355  }
356  break;
357  }
358 
359  else
360  if (ws==groupWS)
361  switch (verb){
362  case PUT:
363  GroupResource group=mapper.readValue(data, GroupResource.class);
364  response=groupWS.updateGroup(group, fragment, "id", null);
365  break;
366  case DELETE:
367  response=groupWS.deleteGroup(fragment);
368  break;
369  case PATCH:
370  PatchRequest pr=mapper.readValue(data, PatchRequest.class);
371  response=groupWS.patchGroup(pr, fragment, "id", null);
372  break;
373  case POST:
374  group=mapper.readValue(data, GroupResource.class);
375  response=groupWS.createGroup(group, "id", null);
376  if (CREATED.getStatusCode()==response.getStatus()) {
377  group = mapper.readValue(response.getEntity().toString(), GroupResource.class);
378  idCreated = group.getId();
379  }
380  break;
381  }
382 
383  else
384  if (ws==fidoDeviceWS)
385  switch (verb){
386  case PUT:
387  FidoDeviceResource dev=mapper.readValue(data, FidoDeviceResource.class);
388  response=fidoDeviceWS.updateDevice(dev, fragment, "id", null);
389  break;
390  case DELETE:
391  response=fidoDeviceWS.deleteDevice(fragment);
392  break;
393  case PATCH:
394  PatchRequest pr=mapper.readValue(data, PatchRequest.class);
395  response=fidoDeviceWS.patchDevice(pr, fragment, "id", null);
396  break;
397  case POST:
398  response=fidoDeviceWS.createDevice();
399  break;
400  }
401  }
402  catch (Exception e){
403  log.error(e.getMessage(), e);
404  response=getErrorResponse(Response.Status.INTERNAL_SERVER_ERROR, "Unexpected error: " + e.getMessage());
405  }
406  return new Pair<Response, String>(response, idCreated);
407 
408  }
Response createUser( @ApiParam(value="User", required=true) UserResource user, @QueryParam(QUERY_PARAM_ATTRIBUTES) String attrsList, @QueryParam(QUERY_PARAM_EXCLUDED_ATTRS) String excludedAttrsList)
Definition: UserWebService.java:96
Response deleteDevice(@PathParam("id") String id)
Definition: FidoDeviceWebService.java:196
Response patchGroup(PatchRequest request, @PathParam("id") String id, @QueryParam(QUERY_PARAM_ATTRIBUTES) String attrsList, @QueryParam(QUERY_PARAM_EXCLUDED_ATTRS) String excludedAttrsList)
Definition: GroupWebService.java:279
ObjectMapper mapper
Definition: BulkWebService.java:81
Response createGroup( @ApiParam(value="Group", required=true) GroupResource group, @QueryParam(QUERY_PARAM_ATTRIBUTES) String attrsList, @QueryParam(QUERY_PARAM_EXCLUDED_ATTRS) String excludedAttrsList)
Definition: GroupWebService.java:94
Response createDevice()
Definition: FidoDeviceWebService.java:94
FidoDeviceWebService fidoDeviceWS
Definition: BulkWebService.java:95
Response updateUser( @ApiParam(value="User", required=true) UserResource user, @PathParam("id") String id, @QueryParam(QUERY_PARAM_ATTRIBUTES) String attrsList, @QueryParam(QUERY_PARAM_EXCLUDED_ATTRS) String excludedAttrsList)
Definition: UserWebService.java:161
Response deleteGroup(@PathParam("id") String id)
Definition: GroupWebService.java:190
Logger log
Definition: BaseScimWebService.java:56
static Response getErrorResponse(Response.Status status, String detail)
Definition: BaseScimWebService.java:75
Response patchUser(PatchRequest request, @PathParam("id") String id, @QueryParam(QUERY_PARAM_ATTRIBUTES) String attrsList, @QueryParam(QUERY_PARAM_EXCLUDED_ATTRS) String excludedAttrsList)
Definition: UserWebService.java:281
Response deleteUser(@PathParam("id") String id)
Definition: UserWebService.java:192
GroupWebService groupWS
Definition: BulkWebService.java:92
UserWebService userWS
Definition: BulkWebService.java:89
Response patchDevice(PatchRequest request, @PathParam("id") String id, @QueryParam(QUERY_PARAM_ATTRIBUTES) String attrsList, @QueryParam(QUERY_PARAM_EXCLUDED_ATTRS) String excludedAttrsList)
Definition: FidoDeviceWebService.java:393
Response updateDevice(FidoDeviceResource fidoDeviceResource, @PathParam("id") String id, @QueryParam(QUERY_PARAM_ATTRIBUTES) String attrsList, @QueryParam(QUERY_PARAM_EXCLUDED_ATTRS) String excludedAttrsList)
Definition: FidoDeviceWebService.java:145
Response updateGroup( @ApiParam(value="Group", required=true) GroupResource group, @PathParam("id") String id, @QueryParam(QUERY_PARAM_ATTRIBUTES) String attrsList, @QueryParam(QUERY_PARAM_EXCLUDED_ATTRS) String excludedAttrsList)
Definition: GroupWebService.java:159

◆ executeDefaultValidation()

void org.gluu.oxtrust.ws.rs.scim2.BaseScimWebService.executeDefaultValidation ( BaseScimResource  resource) throws SCIMException
inlineprotectedinherited
118  {
119  executeValidation(resource, false);
120  }
void executeValidation(BaseScimResource resource, boolean skipRequired)
Definition: BaseScimWebService.java:122

◆ executeValidation()

void org.gluu.oxtrust.ws.rs.scim2.BaseScimWebService.executeValidation ( BaseScimResource  resource,
boolean  skipRequired 
) throws SCIMException
inlineprotectedinherited
122  {
123 
124  ResourceValidator rv=new ResourceValidator(resource, extService.getResourceExtensions(resource.getClass()));
125  if (!skipRequired){
126  rv.validateRequiredAttributes();
127  rv.validateSchemasAttribute();
128  }
129  rv.validateValidableAttributes();
130  //By section 7 of RFC 7643, we are not forced to constrain attribute values when they have a list of canonical values associated
131  //rv.validateCanonicalizedAttributes();
132  rv.validateExtendedAttributes();
133 
134  }
List< Extension > getResourceExtensions(Class<? extends BaseScimResource > cls)
Definition: ExtensionService.java:46
ExtensionService extService
Definition: BaseScimWebService.java:65

◆ getEndpointUrl()

String org.gluu.oxtrust.ws.rs.scim2.BaseScimWebService.getEndpointUrl ( )
inlineinherited
71  {
72  return endpointUrl;
73  }
String endpointUrl
Definition: BaseScimWebService.java:69

◆ getErrorResponse() [1/3]

static Response org.gluu.oxtrust.ws.rs.scim2.BaseScimWebService.getErrorResponse ( Response.Status  status,
String  detail 
)
inlinestaticinherited
75  {
76  return getErrorResponse(status.getStatusCode(), null, detail);
77  }
static Response getErrorResponse(Response.Status status, String detail)
Definition: BaseScimWebService.java:75

◆ getErrorResponse() [2/3]

static Response org.gluu.oxtrust.ws.rs.scim2.BaseScimWebService.getErrorResponse ( Response.Status  status,
ErrorScimType  scimType,
String  detail 
)
inlinestaticinherited
79  {
80  return getErrorResponse(status.getStatusCode(), scimType, detail);
81  }
static Response getErrorResponse(Response.Status status, String detail)
Definition: BaseScimWebService.java:75

◆ getErrorResponse() [3/3]

static Response org.gluu.oxtrust.ws.rs.scim2.BaseScimWebService.getErrorResponse ( int  statusCode,
ErrorScimType  scimType,
String  detail 
)
inlinestaticinherited
83  {
84 
85  ErrorResponse errorResponse = new ErrorResponse();
86  errorResponse.setStatus(String.valueOf(statusCode));
87  errorResponse.setScimType(scimType);
88  errorResponse.setDetail(detail);
89 
90  return Response.status(statusCode).entity(errorResponse).build();
91  }

◆ getFragment()

String org.gluu.oxtrust.ws.rs.scim2.BulkWebService.getFragment ( String  path,
BaseScimWebService  service,
Map< String, String >  idsMap 
) throws Exception
inlineprivate
304  {
305  int endpointLen=service.getEndpointUrl().length()+1;
306  String frag=(path.length() > endpointLen) ? path.substring(endpointLen) : "";
307  return replaceBulkIds(frag, idsMap);
308  }
String replaceBulkIds(String str, Map< String, String > idsMap)
Definition: BulkWebService.java:310

◆ getListResponseSerialized()

String org.gluu.oxtrust.ws.rs.scim2.BaseScimWebService.getListResponseSerialized ( int  total,
int  startIndex,
List< BaseScimResource resources,
String  attrsList,
String  excludedAttrsList,
boolean  ignoreResults 
) throws IOException
inlinepackageinherited
203  {
204 
205  ListResponse listResponse = new ListResponse(startIndex, resources.size(), total);
206  listResponse.setResources(resources);
207 
208  ObjectMapper mapper = new ObjectMapper();
209  SimpleModule module = new SimpleModule("ListResponseModule", Version.unknownVersion());
210  module.addSerializer(ListResponse.class, new ListResponseJsonSerializer(resourceSerializer, attrsList, excludedAttrsList, ignoreResults));
211  mapper.registerModule(module);
212 
213  return mapper.writeValueAsString(listResponse);
214 
215  }
ScimResourceSerializer resourceSerializer
Definition: BaseScimWebService.java:62

◆ getMaxCount()

int org.gluu.oxtrust.ws.rs.scim2.BaseScimWebService.getMaxCount ( )
inlinepackageinherited
93  {
94  return appConfiguration.getScimProperties().getMaxCount();
95  }
AppConfiguration appConfiguration
Definition: BaseScimWebService.java:59

◆ getValueFromHeaders()

String org.gluu.oxtrust.ws.rs.scim2.BaseScimWebService.getValueFromHeaders ( HttpHeaders  headers,
String  name 
)
inlinepackageinherited
97  {
98  List<String> values=headers.getRequestHeaders().get(name);
99  return (values==null || values.size()==0) ? null : values.get(0);
100  }

◆ getWSForPath()

BaseScimWebService org.gluu.oxtrust.ws.rs.scim2.BulkWebService.getWSForPath ( String  path)
inlineprivate
287  {
288  if (path.startsWith(usersEndpoint))
289  return userWS;
290  else
291  if (path.startsWith(groupsEndpoint))
292  return groupWS;
293  else
294  if (path.startsWith(fidodevicesEndpoint))
295  return fidoDeviceWS;
296  else
297  return null;
298  }
String usersEndpoint
Definition: BulkWebService.java:83
FidoDeviceWebService fidoDeviceWS
Definition: BulkWebService.java:95
String fidodevicesEndpoint
Definition: BulkWebService.java:85
String groupsEndpoint
Definition: BulkWebService.java:84
GroupWebService groupWS
Definition: BulkWebService.java:92
UserWebService userWS
Definition: BulkWebService.java:89

◆ inspectPatchRequest()

Response org.gluu.oxtrust.ws.rs.scim2.BaseScimWebService.inspectPatchRequest ( PatchRequest  patch,
Class<? extends BaseScimResource cls 
)
inlineprotectedinherited
217  {
218 
219  Response response=null;
220  List<String> schemas=patch.getSchemas();
221 
222  if (schemas!=null && schemas.size()==1 && schemas.get(0).equals(PATCH_REQUEST_SCHEMA_ID)) {
223  List<PatchOperation> ops = patch.getOperations();
224 
225  if (ops != null) {
226  //Adjust paths if they came prefixed
227 
228  String defSchema=ScimResourceUtil.getDefaultSchemaUrn(cls);
229  List<String> urns=extService.getUrnsOfExtensions(cls);
230  urns.add(defSchema);
231 
232  for (PatchOperation op : ops){
233  if (op.getPath()!=null)
234  op.setPath(ScimResourceUtil.adjustNotationInPath(op.getPath(), defSchema, urns));
235  }
236 
237  for (PatchOperation op : ops) {
238 
239  if (op.getType() == null)
240  response = getErrorResponse(BAD_REQUEST, ErrorScimType.INVALID_SYNTAX, "Operation '" + op.getOperation() + "' not recognized");
241  else {
242  String path = op.getPath();
243 
244  if (StringUtils.isEmpty(path) && op.getType().equals(PatchOperationType.REMOVE))
245  response = getErrorResponse(BAD_REQUEST, ErrorScimType.NO_TARGET, "Path attribute is required for remove operation");
246  else
247  if (op.getValue() == null && !op.getType().equals(PatchOperationType.REMOVE))
248  response = getErrorResponse(BAD_REQUEST, ErrorScimType.INVALID_SYNTAX, "Value attribute is required for operations other than remove");
249  }
250  if (response != null)
251  break;
252  }
253  }
254  else
255  response = getErrorResponse(BAD_REQUEST, ErrorScimType.INVALID_SYNTAX, "Patch request MUST contain the attribute 'Operations'");
256  }
257  else
258  response = getErrorResponse(BAD_REQUEST, ErrorScimType.INVALID_SYNTAX, "Wrong schema(s) supplied in Search Request");
259 
260  log.info("inspectPatchRequest. Preprocessing of patch request {}", response==null ? "passed" : "failed");
261  return response;
262 
263  }
Logger log
Definition: BaseScimWebService.java:56
static Response getErrorResponse(Response.Status status, String detail)
Definition: BaseScimWebService.java:75
ExtensionService extService
Definition: BaseScimWebService.java:65
List< String > getUrnsOfExtensions(Class<? extends BaseScimResource > cls)
Definition: ExtensionService.java:86

◆ prepareRequest()

Response org.gluu.oxtrust.ws.rs.scim2.BulkWebService.prepareRequest ( BulkRequest  request,
String  contentLength 
)
inlineprivate
191  {
192 
193  Response response=null;
194 
195  if (request.getFailOnErrors()==null)
196  request.setFailOnErrors(MAX_BULK_OPERATIONS);
197 
198  List<BulkOperation> operations=request.getOperations();
199 
200  if (operations==null || operations.size()==0)
201  response=getErrorResponse(BAD_REQUEST, ErrorScimType.INVALID_VALUE, "No operations supplied");
202  else {
203 
204  int contentLen;
205  try{
206 //log.debug("CONT LEN {}", contentLength);
207  contentLen=Integer.valueOf(contentLength);
208  }
209  catch (Exception e){
210  contentLen=MAX_BULK_PAYLOAD_SIZE;
211  }
212 
213  boolean payloadExceeded=contentLen > MAX_BULK_PAYLOAD_SIZE;
214  boolean operationsExceeded=operations.size() > MAX_BULK_OPERATIONS;
215  StringBuilder sb=new StringBuilder();
216 
217  if (payloadExceeded)
218  sb.append("The size of the bulk operation exceeds the maxPayloadSize (").
219  append(MAX_BULK_PAYLOAD_SIZE).append(" bytes). ");
220  if (operationsExceeded)
221  sb.append("The number of operations exceed the maxOperations value (").
222  append(MAX_BULK_OPERATIONS).append("). ");
223 
224  if (sb.length()>0)
225  response=getErrorResponse(REQUEST_ENTITY_TOO_LARGE, sb.toString());
226  }
227  if (response==null) {
228  try {
229 
230  for (BulkOperation operation : operations) {
231 
232  if (operation==null)
233  throw new Exception("An operation passed was found to be null");
234 
235  String path = operation.getPath();
236  if (StringUtils.isEmpty(path))
237  throw new Exception("path parameter is required");
238 
239  path=adjustPath(path);
240  operation.setPath(path);
241 
242  String method = operation.getMethod();
243  if (StringUtils.isNotEmpty(method)) {
244  method = method.toUpperCase();
245  operation.setMethod(method);
246  }
247 
248  Verb verb = Verb.valueOf(method);
249  if (!availableMethods.contains(verb))
250  throw new Exception("method not recognized: " + method);
251 
252  //Check if path passed is consistent with respect to method:
253  List<String> availableEndpoints=Arrays.asList(usersEndpoint, groupsEndpoint, fidodevicesEndpoint);
254  boolean consistent = false;
255  for (String endpoint : availableEndpoints) {
256  if (verb.equals(POST))
257  consistent = path.equals(endpoint);
258  else //Checks if there is something after the additional slash
259  consistent = path.startsWith(endpoint + "/") && (path.length() > endpoint.length() + 1);
260 
261  if (consistent)
262  break;
263  }
264  if (!consistent)
265  throw new Exception("path parameter is not consistent with method " + method);
266 
267  //Check if bulkId must be present
268  String bulkId = operation.getBulkId();
269  if (StringUtils.isEmpty(bulkId) && verb.equals(POST))
270  throw new Exception("bulkId parameter is required for method " + method);
271 
272  //Check if data must be present
273  String data=operation.getDataStr();
274  List<Verb> dataMethods=Arrays.asList(POST, PUT, PATCH);
275  if (dataMethods.contains(verb) && StringUtils.isEmpty(data))
276  throw new Exception("data parameter is required for method " + method);
277  }
278  }
279  catch (Exception e) {
280  response=getErrorResponse(BAD_REQUEST, ErrorScimType.INVALID_SYNTAX, e.getMessage());
281  }
282  }
283  return response;
284 
285  }
String adjustPath(String path)
Definition: BulkWebService.java:300
String usersEndpoint
Definition: BulkWebService.java:83
List< Verb > availableMethods
Definition: BulkWebService.java:80
static Response getErrorResponse(Response.Status status, String detail)
Definition: BaseScimWebService.java:75
String fidodevicesEndpoint
Definition: BulkWebService.java:85
String groupsEndpoint
Definition: BulkWebService.java:84

◆ prepareSearchRequest()

Response org.gluu.oxtrust.ws.rs.scim2.BaseScimWebService.prepareSearchRequest ( List< String >  schemas,
String  filter,
String  sortBy,
String  sortOrder,
Integer  startIndex,
Integer  count,
String  attrsList,
String  excludedAttrsList,
SearchRequest  request 
)
inlineprotectedinherited
167  {
168 
169  Response response=null;
170 
171  if (schemas!=null && schemas.size()==1 && schemas.get(0).equals(SEARCH_REQUEST_SCHEMA_ID)) {
172  count = count == null ? getMaxCount() : count;
173  //Per spec, a negative value SHALL be interpreted as "0" for count
174  if (count<0)
175  count=0;
176 
177  if (count <= getMaxCount()) {
178  startIndex = (startIndex == null || startIndex < 1) ? 1 : startIndex;
179 
180  if (StringUtils.isEmpty(sortOrder) || !sortOrder.equals(SortOrder.DESCENDING.getValue()))
181  sortOrder = SortOrder.ASCENDING.getValue();
182 
183  request.setSchemas(schemas);
184  request.setAttributes(attrsList);
185  request.setExcludedAttributes(excludedAttrsList);
186  request.setFilter(filter);
187  request.setSortBy(sortBy);
188  request.setSortOrder(sortOrder);
189  request.setStartIndex(startIndex);
190  request.setCount(count);
191  }
192  else
193  response = getErrorResponse(BAD_REQUEST, ErrorScimType.TOO_MANY, "Maximum number of results per page is " + getMaxCount());
194  }
195  else
196  response = getErrorResponse(BAD_REQUEST, ErrorScimType.INVALID_SYNTAX, "Wrong schema(s) supplied in Search Request");
197 
198  return response;
199 
200  }
int getMaxCount()
Definition: BaseScimWebService.java:93
static Response getErrorResponse(Response.Status status, String detail)
Definition: BaseScimWebService.java:75

◆ processBulkOperations()

.ws.rs.POST Response org.gluu.oxtrust.ws.rs.scim2.BulkWebService.processBulkOperations ( @ApiParam(value="BulkRequest", required=true) BulkRequest  request)
inline
106  {
107 
108  Response response=prepareRequest(request, getValueFromHeaders(httpHeaders, "Content-Length"));
109  if (response==null) {
110  log.debug("Executing web service method. processBulkOperations");
111 
112  int i, errors=0;
113  List<BulkOperation> operations=request.getOperations();
114  List<BulkOperation> responseOperations=new ArrayList<BulkOperation>();
115  Map<String, String> processedBulkIds=new HashMap<String, String>();
116 
117  for (i=0;i<operations.size() && errors<request.getFailOnErrors();i++){
118 
119  BulkOperation operation=operations.get(i);
120  BulkOperation operationResponse=new BulkOperation();
121  Response subResponse;
122 
123  String method=operation.getMethod();
124  String bulkId=operation.getBulkId();
125  try {
126  String path=operation.getPath();
127  BaseScimWebService service=getWSForPath(path);
128  String fragment=getFragment(path, service, processedBulkIds);
129  Verb verb = Verb.valueOf(method);
130 
131  String data=operation.getDataStr();
132  if (!verb.equals(DELETE))
133  data = replaceBulkIds(data, processedBulkIds);
134 
135  Pair<Response, String> pair=execute(verb, service, data, fragment);
136  String idCreated=pair.getSecond();
137  subResponse=pair.getFirst();
138  int status=subResponse.getStatus();
139 
140  if (familyOf(status).equals(SUCCESSFUL)) {
141  if (!verb.equals(DELETE)) {
142  if (verb.equals(POST)) { //Update bulkIds
143  processedBulkIds.put(bulkId, idCreated);
144  fragment=idCreated;
145  }
146  String loc=service.getEndpointUrl() + "/" + fragment;
147  operationResponse.setLocation(loc);
148  }
149  }
150  else {
151  operationResponse.setResponse(subResponse.getEntity());
152  errors+= familyOf(status).equals(CLIENT_ERROR) || familyOf(status).equals(SERVER_ERROR) ? 1 : 0;
153  }
154 
155  subResponse.close();
156  operationResponse.setStatus(Integer.toString(status));
157  }
158  catch (Exception e) {
159  log.error(e.getMessage(), e);
160  subResponse=getErrorResponse(BAD_REQUEST, ErrorScimType.INVALID_SYNTAX, e.getMessage());
161 
162  operationResponse.setStatus(Integer.toString(BAD_REQUEST.getStatusCode()));
163  operationResponse.setResponse(subResponse.getEntity());
164  errors++;
165  }
166 
167  operationResponse.setBulkId(bulkId);
168  operationResponse.setMethod(method);
169 
170  responseOperations.add(operationResponse);
171 
172  log.debug("Operation {} processed with status {}. Method {}, Accumulated errors {}", i+1, operationResponse.getStatus(), method, errors);
173  }
174 
175  try {
176  BulkResponse bulkResponse=new BulkResponse();
177  bulkResponse.setOperations(responseOperations);
178 
179  String json = mapper.writeValueAsString(bulkResponse);
180  response=Response.ok(json).build();
181  }
182  catch (Exception e){
183  log.error(e.getMessage(), e);
184  response=getErrorResponse(INTERNAL_SERVER_ERROR, e.getMessage());
185  }
186  }
187  return response;
188 
189  }
ObjectMapper mapper
Definition: BulkWebService.java:81
String getValueFromHeaders(HttpHeaders headers, String name)
Definition: BaseScimWebService.java:97
String getFragment(String path, BaseScimWebService service, Map< String, String > idsMap)
Definition: BulkWebService.java:304
Response prepareRequest(BulkRequest request, String contentLength)
Definition: BulkWebService.java:191
Pair< Response, String > execute(Verb verb, BaseScimWebService ws, String data, String fragment)
Definition: BulkWebService.java:330
Logger log
Definition: BaseScimWebService.java:56
static Response getErrorResponse(Response.Status status, String detail)
Definition: BaseScimWebService.java:75
String replaceBulkIds(String str, Map< String, String > idsMap)
Definition: BulkWebService.java:310
HttpHeaders httpHeaders
Definition: BulkWebService.java:98
BaseScimWebService getWSForPath(String path)
Definition: BulkWebService.java:287

◆ replaceBulkIds()

String org.gluu.oxtrust.ws.rs.scim2.BulkWebService.replaceBulkIds ( String  str,
Map< String, String >  idsMap 
) throws Exception
inlineprivate
310  {
311 
312  Matcher m=bulkIdPattern.matcher(str);
313  StringBuffer sb = new StringBuffer();
314 
315  while (m.find()){
316  String id=m.group(1);
317  //See if the id supplied is known
318  String realId=idsMap.get(id);
319  if (realId==null)
320  throw new Exception("bulkId '" + id + "' not recognized");
321 
322  m.appendReplacement(sb, realId);
323  }
324  m.appendTail(sb);
325 
326  return sb.toString();
327 
328  }
final Pattern bulkIdPattern
Definition: BulkWebService.java:78

◆ setup()

void org.gluu.oxtrust.ws.rs.scim2.BulkWebService.setup ( )
inline
411  {
412  //Do not use getClass() here... a typical weld issue...
413  endpointUrl=appConfiguration.getBaseEndpoint() + BulkWebService.class.getAnnotation(Path.class).value();
414  availableMethods= Arrays.asList(Verb.values());
415 
419  commonWsEndpointPrefix=usersEndpoint.substring(0, usersEndpoint.lastIndexOf("/"));
420  }
String usersEndpoint
Definition: BulkWebService.java:83
FidoDeviceWebService fidoDeviceWS
Definition: BulkWebService.java:95
String commonWsEndpointPrefix
Definition: BulkWebService.java:86
String endpointUrl
Definition: BaseScimWebService.java:69
List< Verb > availableMethods
Definition: BulkWebService.java:80
String getEndpointUrl()
Definition: BaseScimWebService.java:71
String fidodevicesEndpoint
Definition: BulkWebService.java:85
String groupsEndpoint
Definition: BulkWebService.java:84
AppConfiguration appConfiguration
Definition: BaseScimWebService.java:59
GroupWebService groupWS
Definition: BulkWebService.java:92
UserWebService userWS
Definition: BulkWebService.java:89

◆ translateSortByAttribute()

String org.gluu.oxtrust.ws.rs.scim2.BaseScimWebService.translateSortByAttribute ( Class<? extends BaseScimResource cls,
String  sortBy 
)
inlinepackageinherited
137  {
138 
139  String type=ScimResourceUtil.getType(cls);
140  if (StringUtils.isEmpty(sortBy) || type==null)
141  sortBy=null;
142  else {
143  if (extService.extensionOfAttribute(cls, sortBy)==null) { //It's not a custom attribute...
144 
145  sortBy=ScimResourceUtil.stripDefaultSchema(cls, sortBy);
146  Field f=IntrospectUtil.findFieldFromPath(cls, sortBy);
147 
148  if (f==null){ //Not recognized!
149  log.warn("SortBy parameter value '{}' was not recognized as a SCIM attribute for resource {} - sortBy will be ignored.", sortBy, type);
150  sortBy=null;
151  //return getErrorResponse(Response.Status.BAD_REQUEST, ErrorScimType.INVALID_PATH, "sortBy parameter value not recognized");
152  }
153  else {
154  sortBy = FilterUtil.getLdapAttributeOfResourceAttribute(sortBy, cls).getFirst();
155  if (sortBy==null)
156  log.warn("There is no LDAP attribute mapping to sortBy attribute provided - sortBy will be ignored.");
157  }
158  }
159  else
160  sortBy = sortBy.substring(sortBy.lastIndexOf(":")+1);
161  }
162  return sortBy;
163 
164  }
Extension extensionOfAttribute(Class<? extends BaseScimResource > cls, String attribute)
Definition: ExtensionService.java:147
Logger log
Definition: BaseScimWebService.java:56
ExtensionService extService
Definition: BaseScimWebService.java:65

メンバ詳解

◆ appConfiguration

AppConfiguration org.gluu.oxtrust.ws.rs.scim2.BaseScimWebService.appConfiguration
packageinherited

◆ availableMethods

List<Verb> org.gluu.oxtrust.ws.rs.scim2.BulkWebService.availableMethods
private

◆ bulkIdPattern

final Pattern org.gluu.oxtrust.ws.rs.scim2.BulkWebService.bulkIdPattern = Pattern.compile("bulkId:(\\w+)")
private

◆ commonWsEndpointPrefix

String org.gluu.oxtrust.ws.rs.scim2.BulkWebService.commonWsEndpointPrefix
private

◆ endpointUrl

String org.gluu.oxtrust.ws.rs.scim2.BaseScimWebService.endpointUrl
packageinherited

◆ extService

ExtensionService org.gluu.oxtrust.ws.rs.scim2.BaseScimWebService.extService
packageinherited

◆ fidodevicesEndpoint

String org.gluu.oxtrust.ws.rs.scim2.BulkWebService.fidodevicesEndpoint
private

◆ fidoDeviceWS

FidoDeviceWebService org.gluu.oxtrust.ws.rs.scim2.BulkWebService.fidoDeviceWS
private

◆ groupsEndpoint

String org.gluu.oxtrust.ws.rs.scim2.BulkWebService.groupsEndpoint
private

◆ groupWS

GroupWebService org.gluu.oxtrust.ws.rs.scim2.BulkWebService.groupWS
private

◆ httpHeaders

HttpHeaders org.gluu.oxtrust.ws.rs.scim2.BulkWebService.httpHeaders
private

◆ log

Logger org.gluu.oxtrust.ws.rs.scim2.BaseScimWebService.log
packageinherited

◆ mapper

ObjectMapper org.gluu.oxtrust.ws.rs.scim2.BulkWebService.mapper =new ObjectMapper()
private

◆ resourceSerializer

ScimResourceSerializer org.gluu.oxtrust.ws.rs.scim2.BaseScimWebService.resourceSerializer
packageinherited

◆ SEARCH_SUFFIX

final String org.gluu.oxtrust.ws.rs.scim2.BaseScimWebService.SEARCH_SUFFIX = ".search"
staticinherited

◆ usersEndpoint

String org.gluu.oxtrust.ws.rs.scim2.BulkWebService.usersEndpoint
private

◆ userWS

UserWebService org.gluu.oxtrust.ws.rs.scim2.BulkWebService.userWS
private

このクラス詳解は次のファイルから抽出されました: