/** * Finds the type parameter for the given class. * * @param klass * a parameterized class * @return the class's type parameter */ static Class<?> getTypeParameter(Class<?> klass) { return getTypeParameter(klass, Object.class); }
/** * Get the namespace declarations of the application. * * @return the namespaces of the application */ public Namespaces namespaces() { return new NullNamespaces(); }
/** * {@inheritDoc} */ @Override public Namespaces applicationNamespaces() { return this.configuration.namespaces(); }
private void assertHasParameter(Query query, String parameterName, String... rawValues) { assertThat(query.hasParameter(parameterName),equalTo(true)); Parameter parameter = query.getParameter(parameterName); assertThat(parameter,notNullValue()); assertThat(parameter.isMultivalued(),equalTo(rawValues.length>1)); assertThat(parameter.cardinality(),equalTo(rawValues.length)); assertThat(parameter.rawValue(),equalTo(rawValues[0])); assertThat(parameter.rawValues(),hasItems(rawValues)); }
@Override public DataSet query(ResourceSnapshot resource, Query query, ReadSession session) throws ApplicationRuntimeException { throw new ApplicationRuntimeException("Failure"); }
public String getApplicationName() { return this.application!=null?this.application.getName():"<unknown>"; }
protected static <T> Class<T> processTypeVariable(Class<? super T> bound, TypeVariable<?> typeVariable) { for(Type paramBound:typeVariable.getBounds()) { if(paramBound instanceof Class<?>) { Class<T >cls=determineClass(bound,paramBound); if(cls!=null) { return cls; } } } return null; }
public InvalidQueryDiagnosedException(OperationContext context, InvalidQueryException cause) { super( context, cause, Diagnosis. create(). statusCode(Status.BAD_REQUEST). diagnostic("Invalid query: %s",cause.getMessage()). mandatory(true)); }
@Override public final DataSet get() throws FeatureException { try { DataSet dataSet = this.delegate.get(resource()); checkResponseNotNull(dataSet,ResourceHandler.class,"No data set returned"); return dataSet; } catch (ApplicationException | ApplicationApiRuntimeException e) { throw featureException(e,ResourceHandler.class); } finally { finalizeSession(); } }
@Override public final void update(DataSet content) throws FeatureException { try { as(Modifiable.class).update(resource(), content, writeSession()); } catch (ApplicationException | ApplicationApiRuntimeException e) { throw featureException(e,Modifiable.class); } finally { finalizeSession(); } }
@Override public final void delete() throws FeatureException { try { as(Deletable.class).delete(resource(),writeSession()); } catch (ApplicationException | ApplicationApiRuntimeException e) { throw featureException(e,Deletable.class); } finally { finalizeSession(); } }
@Override public final DataSet query(Query query) throws FeatureException { try { DataSet dataSet = as(Queryable.class).query(resource(), query, writeSession()); checkResponseNotNull(dataSet,Queryable.class,"No data set returned"); return dataSet; } catch (ApplicationException | ApplicationApiRuntimeException e) { throw featureException(e,Queryable.class); } finally { finalizeSession(); } }
@Override public Resource create(DataSet content) throws FeatureException { try { ResourceSnapshot create = as(ContainerHandler.class).create(resource(),content,writeSession()); checkResponseNotNull(create, ContainerHandler.class, "No resource created"); return detach(create); } catch (ApplicationException | ApplicationApiRuntimeException e) { throw featureException(e,ContainerHandler.class); } finally { finalizeSession(); } }
@Override public DataSet get(ResourceSnapshot resource) throws ApplicationRuntimeException { throw new ApplicationRuntimeException("Failure"); }
/** * Returns the {@link Class} of the configuration class type parameter. * * @return the configuration class * @see Generics#getTypeParameter(Class, Class) */ public final Class<T> getConfigurationClass() { return Generics.getTypeParameter(getClass(), Configuration.class); }
/** * {@inheritDoc} */ @Override public String applicationName() { return application().getName(); }
@Override public void update(ResourceSnapshot resource, DataSet content, WriteSession session) throws ApplicationRuntimeException { throw new ApplicationRuntimeException("Failure"); }
@Override public ResourceSnapshot create(ContainerSnapshot container, DataSet representation, WriteSession session) throws ApplicationRuntimeException { throw new ApplicationRuntimeException("Failure"); }
@Override public void delete(ResourceSnapshot resource, WriteSession session) throws ApplicationRuntimeException { throw new ApplicationRuntimeException("Failure"); }
@Override public final DataSet get(final ResourceSnapshot resource) { final K userId=getId(resource); try { return toDataSet( getEntity(this.backendController,userId), userId); } catch(final Exception e){ throw new ApplicationRuntimeException(e); } }