@Override public Action getAction(String actionName) { int i = actionName.lastIndexOf('.'); String namespace = actionName.substring(0, i); String simpleActionName = actionName.substring(i + 1); Schema schema = schemas.get(namespace); if (schema == null) { throw new IllegalArgumentException("There are no such schema with namespace: " + namespace); } Action action = schema.getAction(simpleActionName); if (action == null) { throw new IllegalArgumentException("Can't find action with name: " + simpleActionName); } return action; }
@Override public Action getAction(String actionName) { int i = actionName.lastIndexOf('.'); String namespace = actionName.substring(0, i); String simpleActionName = actionName.substring(i + 1); Schema schema = schemas.get(namespace); if (schema == null) { throw new IllegalArgumentException("There are no such schema with namespace: " + namespace); } Action action = schema.getAction(simpleActionName); if (action == null) { throw new IllegalArgumentException("Can't find action with name: " + simpleActionName); } return action; }
/** * Gets the action by the specified name, throw an exception if no action with the specified name * exists. * * @param entityDataModel The entity data model. * @param actionName The name of action. * @return the Action instance specified by given actionName. */ public static Action getAndCheckAction(EntityDataModel entityDataModel, String actionName) { int namespaceLastIndex = actionName.lastIndexOf('.'); String namespace = actionName.substring(0, namespaceLastIndex); String simpleActionName = actionName.substring(namespaceLastIndex + 1); Schema schema = entityDataModel.getSchema(namespace); if (schema == null) { throw new ODataSystemException("Could not find schema in entity data model with namespace: " + namespace); } Action action = schema.getAction(simpleActionName); if (action == null) { throw new ODataSystemException("Action not found in entity data model: " + actionName); } return action; }
/** * Gets the action by the specified name, throw an exception if no action with the specified name * exists. * * @param entityDataModel The entity data model. * @param actionName The name of action. * @return the Action instance specified by given actionName. */ public static Action getAndCheckAction(EntityDataModel entityDataModel, String actionName) { int namespaceLastIndex = actionName.lastIndexOf('.'); String namespace = actionName.substring(0, namespaceLastIndex); String simpleActionName = actionName.substring(namespaceLastIndex + 1); Schema schema = entityDataModel.getSchema(namespace); if (schema == null) { throw new ODataSystemException("Could not find schema in entity data model with namespace: " + namespace); } Action action = schema.getAction(simpleActionName); if (action == null) { throw new ODataSystemException("Action not found in entity data model: " + actionName); } return action; }
private Object parseAction(String fullyQualifiedName) throws ODataException { int delimiterIndex = fullyQualifiedName.lastIndexOf("."); if (delimiterIndex < 0) { throw new ODataUnmarshallingException("The action should have a fully qualified name"); } String namespace = fullyQualifiedName.substring(0, delimiterIndex); String actionSimpleName = fullyQualifiedName.substring(delimiterIndex + 1); Schema schema = checkNotNull(entityDataModel.getSchema(namespace), "There is no schema with name: {}", namespace); Action action = checkNotNull(schema.getAction(actionSimpleName), "There is no action {} within schema {}", actionSimpleName, namespace); Object actionObject; try { actionObject = action.getJavaClass().newInstance(); } catch (ReflectiveOperationException e) { throw new ODataUnmarshallingException("Error during instantiation of action: " + action.getName()); } Set<Parameter> actionParameters = action.getParameters(); Map<String, Object> bodyParameters; try { bodyParameters = parseRequestBody(requestContext.getRequest().getBodyText(UTF_8.name())); } catch (IOException e) { throw new ODataUnmarshallingException("Error has occurred during parameter parsing", e); } assignParametersToAction(bodyParameters, actionParameters, actionObject); return actionObject; }
private Object parseAction(String fullyQualifiedName) throws ODataException { int delimiterIndex = fullyQualifiedName.lastIndexOf("."); if (delimiterIndex < 0) { throw new ODataUnmarshallingException("The action should have a fully qualified name"); } String namespace = fullyQualifiedName.substring(0, delimiterIndex); String actionSimpleName = fullyQualifiedName.substring(delimiterIndex + 1); Schema schema = checkNotNull(entityDataModel.getSchema(namespace), "There is no schema with name: {}", namespace); Action action = checkNotNull(schema.getAction(actionSimpleName), "There is no action {} within schema {}", actionSimpleName, namespace); Object actionObject; try { actionObject = action.getJavaClass().newInstance(); } catch (ReflectiveOperationException e) { throw new ODataUnmarshallingException("Error during instantiation of action: " + action.getName()); } Set<Parameter> actionParameters = action.getParameters(); Map<String, Object> bodyParameters; try { bodyParameters = parseRequestBody(requestContext.getRequest().getBodyText(UTF_8.name())); } catch (IOException e) { throw new ODataUnmarshallingException("Error has occurred during parameter parsing", e); } assignParametersToAction(bodyParameters, actionParameters, actionObject); return actionObject; }