use of org.wso2.carbon.apimgt.rest.api.util.exception.BadRequestException in project charon by wso2.
the class ResourceTypeResourceManager method getResourceType.
/*
* return RESOURCE_TYPE schema
*
* @return
*/
private SCIMResponse getResourceType() {
JSONEncoder encoder = null;
try {
// obtain the json encoder
encoder = getEncoder();
// obtain the json decoder
JSONDecoder decoder = getDecoder();
// get the service provider config schema
SCIMResourceTypeSchema schema = SCIMResourceSchemaManager.getInstance().getResourceTypeResourceSchema();
// create a string in json format for user resource type with relevant values
String scimUserObjectString = encoder.buildUserResourceTypeJsonBody();
// create a string in json format for group resource type with relevant values
String scimGroupObjectString = encoder.buildGroupResourceTypeJsonBody();
// build the user abstract scim object
AbstractSCIMObject userResourceTypeObject = (AbstractSCIMObject) decoder.decodeResource(scimUserObjectString, schema, new AbstractSCIMObject());
// add meta data
userResourceTypeObject = ServerSideValidator.validateResourceTypeSCIMObject(userResourceTypeObject);
// build the group abstract scim object
AbstractSCIMObject groupResourceTypeObject = (AbstractSCIMObject) decoder.decodeResource(scimGroupObjectString, schema, new AbstractSCIMObject());
// add meta data
groupResourceTypeObject = ServerSideValidator.validateResourceTypeSCIMObject(groupResourceTypeObject);
// build the root abstract scim object
AbstractSCIMObject resourceTypeObject = buildCombinedResourceType(userResourceTypeObject, groupResourceTypeObject);
// encode the newly created SCIM Resource Type object.
String encodedObject;
Map<String, String> responseHeaders = new HashMap<String, String>();
if (resourceTypeObject != null) {
// create a deep copy of the resource type object since we are going to change it.
AbstractSCIMObject copiedObject = (AbstractSCIMObject) CopyUtil.deepCopy(resourceTypeObject);
encodedObject = encoder.encodeSCIMObject(copiedObject);
// add location header
responseHeaders.put(SCIMConstants.LOCATION_HEADER, getResourceEndpointURL(SCIMConstants.RESOURCE_TYPE_ENDPOINT));
responseHeaders.put(SCIMConstants.CONTENT_TYPE_HEADER, SCIMConstants.APPLICATION_JSON);
} else {
String error = "Newly created User resource is null.";
throw new InternalErrorException(error);
}
// put the uri of the resource type object in the response header parameter.
return new SCIMResponse(ResponseCodeConstants.CODE_OK, encodedObject, responseHeaders);
} catch (CharonException e) {
return encodeSCIMException(e);
} catch (BadRequestException e) {
return encodeSCIMException(e);
} catch (InternalErrorException e) {
return encodeSCIMException(e);
} catch (NotFoundException e) {
return encodeSCIMException(e);
} catch (JSONException e) {
return null;
}
}
use of org.wso2.carbon.apimgt.rest.api.util.exception.BadRequestException in project charon by wso2.
the class ResourceTypeResourceManager method listWithPOST.
@Override
public SCIMResponse listWithPOST(String resourceString, UserManager userManager) {
String error = "Request is undefined";
BadRequestException badRequestException = new BadRequestException(error, ResponseCodeConstants.INVALID_PATH);
return encodeSCIMException(badRequestException);
}
use of org.wso2.carbon.apimgt.rest.api.util.exception.BadRequestException in project charon by wso2.
the class ResourceTypeResourceManager method create.
@Override
public SCIMResponse create(String scimObjectString, UserManager userManager, String attributes, String excludeAttributes) {
String error = "Request is undefined";
BadRequestException badRequestException = new BadRequestException(error, ResponseCodeConstants.INVALID_PATH);
return encodeSCIMException(badRequestException);
}
use of org.wso2.carbon.apimgt.rest.api.util.exception.BadRequestException in project charon by wso2.
the class ServiceProviderConfigResourceManager method delete.
@Override
public SCIMResponse delete(String id, UserManager userManager) {
String error = "Request is undefined";
BadRequestException badRequestException = new BadRequestException(error, ResponseCodeConstants.INVALID_PATH);
return encodeSCIMException(badRequestException);
}
use of org.wso2.carbon.apimgt.rest.api.util.exception.BadRequestException in project charon by wso2.
the class ServiceProviderConfigResourceManager method create.
@Override
public SCIMResponse create(String scimObjectString, UserManager userManager, String attributes, String excludeAttributes) {
String error = "Request is undefined";
BadRequestException badRequestException = new BadRequestException(error, ResponseCodeConstants.INVALID_PATH);
return encodeSCIMException(badRequestException);
}
Aggregations