private static OwsExceptionReport duplicateOutput(OwsCode id) { return new InvalidParameterValueException().at(OUTPUT).withMessage("Duplicate output definition for output %s", id); }
protected void checkReservedCharacter(String value, String parameterName) throws OwsExceptionReport { if (value != null && value.contains(",")) { throw new InvalidParameterValueException(parameterName, value) .withMessage("The value '%s' contains the reserved parameter ','", value); } }
public InvalidParameterValueException(final String parameterName, final String value) { super(OwsExceptionCode.InvalidParameterValue); withMessage("The value '%s' of the parameter '%s' is invalid", value, parameterName).at(parameterName); setStatus(HTTPStatus.BAD_REQUEST); }
public static String checkParameterSingleValue(String value, String name) throws OwsExceptionReport { if (checkParameterMultipleValues(value, name).size() == 1) { return value; } else { throw new InvalidParameterValueException(name, value); } }
/** * Unfold internal observation from result values to single internal * observations * * @param observation * Internal observaiton to unfold * @return List with single interal observations * @throws OwsExceptionReport * If an error occurs during unfolding */ protected List<OmObservation> getSingleObservationsFromObservation(final OmObservation observation) throws OwsExceptionReport { try { return new ObservationUnfolder(observation, sweHelper).unfold(isConvertComplexProfileToSingleProfiles()); } catch (final Exception e) { throw new InvalidParameterValueException() .causedBy(e) .at(Sos2Constants.InsertResultParams.resultValues) .withMessage( "The resultValues format does not comply to the resultStructure of the resultTemplate!"); } }
public InvalidParameterValueException() { super(OwsExceptionCode.InvalidParameterValue); setStatus(HTTPStatus.BAD_REQUEST); }
private void checkResponseFormat(String responseFormat) throws CodedOwsException { if (responseFormat == null || responseFormat.isEmpty()) { throw new MissingParameterValueException("responseFormat"); } if (!(GetDataAvailabilityConstants.NS_GDA.equals(responseFormat) || GetDataAvailabilityConstants.NS_GDA_20.equals(responseFormat))) { throw new InvalidParameterValueException("responseFormat", responseFormat); } }
/** * Unfold internal observation from result values to single internal * observations * * @param observation * Internal observaiton to unfold * @return List with single interal observations * @throws OwsExceptionReport * If an error occurs during unfolding */ protected List<OmObservation> getSingleObservationsFromObservation(final OmObservation observation) throws OwsExceptionReport { try { return new ObservationUnfolder(observation, sweHelper).unfold(isConvertComplexProfileToSingleProfiles()); } catch (final Exception e) { throw new InvalidParameterValueException() .causedBy(e) .at(Sos2Constants.InsertResultParams.resultValues) .withMessage( "The resultValues format does not comply to the resultStructure of the resultTemplate!"); } }
public InvalidParameterValueException() { super(OwsExceptionCode.InvalidParameterValue); setStatus(HTTPStatus.BAD_REQUEST); }
public static void checkHref(final String href, final String parameterName) throws OwsExceptionReport { if (!href.startsWith("http") && !href.startsWith("urn")) { throw new InvalidParameterValueException().at(parameterName).withMessage( "The reference (href) has an invalid style!"); } }
private void checkResponseFormat(String responseFormat) throws CodedOwsException { if (responseFormat == null || responseFormat.isEmpty()) { throw new MissingParameterValueException("responseFormat"); } if (!(GetDataAvailabilityConstants.NS_GDA.equals(responseFormat) || GetDataAvailabilityConstants.NS_GDA_20.equals(responseFormat))) { throw new InvalidParameterValueException("responseFormat", responseFormat); } }
private OwsExceptionReport toOwsExceptionReport(Throwable ex) { if (ex instanceof OwsExceptionReport) { return (OwsExceptionReport) ex; } Throwable cause = ex.getCause(); if (cause instanceof OwsExceptionReport) { return (OwsExceptionReport) cause; } if (ex instanceof CompositeException) { return toOwsExceptionReport((CompositeException) ex); } if (cause instanceof CompositeException) { return toOwsExceptionReport((CompositeException) cause); } String location = null; if (ex instanceof LocationHintException) { location = ((LocationHintException) ex).getLocation().orElse(null); } else if (cause instanceof LocationHintException) { location = ((LocationHintException) cause).getLocation().orElse(null); } return new InvalidParameterValueException().withMessage(ex.getMessage()).causedBy(ex).at(location); } }
@Override public DismissResponse handle(DismissRequest request) throws OwsExceptionReport { JobId jobId = request.getJobId(); StatusInfo status; try { status = getEngine().dismiss(jobId); } catch (JobNotFoundException ex) { throw new InvalidParameterValueException(JOB_ID, jobId.getValue()).causedBy(ex); } String service = request.getService(); String version = request.getVersion(); return new DismissResponse(service, version, status); }
public InvalidParameterValueException(final String parameterName, final String value) { super(OwsExceptionCode.InvalidParameterValue); withMessage("The value '%s' of the parameter '%s' is invalid", value, parameterName).at(parameterName); setStatus(HTTPStatus.BAD_REQUEST); }
/** * Check if the requested resultType is valid * * @param resultType * Requested resultType * @throws CodedException * If the requested resultType is not valid */ private void checkRequestedResultType(String resultType) throws CodedException { if (!getValidResultTypes().contains(resultType)) { throw new InvalidParameterValueException().at("resultType").withMessage( "The requested resultType '%s' is not valid for the responseFormat '%s'", resultType, InspireOMSOConstants.NS_OMSO_30); } }
protected Date getDateForTimeIndeterminateValue(IndeterminateValue indeterminateValue, String parameter) throws InvalidParameterValueException { if (indeterminateValue.isNow()) { return new DateTime().toDate(); } throw new InvalidParameterValueException(parameter, indeterminateValue.getValue()); }
protected void checkTemporalFilter(TemporalFilter temporalFilter) throws CodedException { if (temporalFilter.getTime() instanceof TimePeriod) { TimePeriod tp = (TimePeriod) temporalFilter.getTime(); if (tp.isEmpty()) { throw new InvalidParameterValueException(SosConstants.Filter.TimePeriod, tp.toString()) .withMessage("Begin/end time is missing!"); } if (tp.getStart().isEqual(tp.getEnd())) { throw new InvalidParameterValueException(SosConstants.Filter.TimePeriod, tp.toString()).withMessage( "It is not allowed that begin and end time are equal! Begin '%s' == End '%s'", tp.getStart(), tp.getEnd()); } if (tp.getStart().isAfter(tp.getEnd())) { throw new InvalidParameterValueException(SosConstants.Filter.TimePeriod, tp.toString()).withMessage( "It is not allowed that begin time is after end time! Begin '%s' > End '%s'", tp.getStart(), tp.getEnd()); } } }
@Override public GetStatusResponse handle(GetStatusRequest request) throws OwsExceptionReport { String service = request.getService(); String version = request.getVersion(); JobId jobId = request.getJobId(); StatusInfo status; try { status = getEngine().getStatus(jobId); } catch (JobNotFoundException ex) { throw new InvalidParameterValueException(JOB_ID, jobId.getValue()).causedBy(ex); } catch (EngineException ex) { throw new NoApplicableCodeException().causedBy(ex); } return new GetStatusResponse(service, version, status); }
/** * Check if the requested resultType is valid * * @param resultType * Requested resultType * @throws CodedException * If the requested resultType is not valid */ private void checkRequestedResultType(String resultType) throws CodedException { if (!getValidResultTypes().contains(resultType)) { throw new InvalidParameterValueException().at("resultType").withMessage( "The requested resultType '%s' is not valid for the responseFormat '%s'", resultType, InspireOMSOConstants.NS_OMSO_30); } }
private List<String> deleteByTemplateId(Session session, List<String> resultTemplates) throws InvalidParameterValueException { List<String> deletedResultTemplates = Lists.newArrayList(); for (String resultTemplate : resultTemplates) { final ResultTemplateEntity templateObject = daoFactory.getResultTemplateDAO().getResultTemplateObject(resultTemplate, session); if (templateObject == null) { throw new InvalidParameterValueException(DeleteResultTemplateConstants.PARAMETERS.resultTemplate, resultTemplate); } session.delete(templateObject); deletedResultTemplates.add(resultTemplate); } return deletedResultTemplates; }