Tabnine Logo
com.lyncode.xoai.dataprovider.exceptions
Code IndexAdd Tabnine to your IDE (free)

How to use com.lyncode.xoai.dataprovider.exceptions

Best Java code snippets using com.lyncode.xoai.dataprovider.exceptions (Showing top 20 results out of 315)

origin: com.lyncode/xoai-data-provider

public void validate (Parameter parameter) throws IllegalVerbException, DuplicateDefinitionException {
  List<String> values = this.map.get(parameter);
  if (values != null && !values.isEmpty()) {
    if (parameter == Verb) {
      if (values.size() > 1)
        throw new IllegalVerbException("Illegal verb");
    } else {
      if (values.size() > 1)
        throw new DuplicateDefinitionException("Duplicate definition of parameter '" + parameter + "'");
    }
  }
}
origin: com.lyncode/xoai-data-provider

private void validateDates() throws BadArgumentException {
  Calendar from = Calendar.getInstance();
  Calendar until = Calendar.getInstance();
  from.setTime(this.from);
  until.setTime(this.until);
  if (from.after(until)) throw new BadArgumentException("The 'from' date must be less then the 'until' one");
}
origin: com.lyncode/xoai-data-provider

  private OAICompiledRequest compileParameters(OAIRequest requestParameters) throws IllegalVerbException, UnknownParameterException, BadArgumentException, DuplicateDefinitionException, BadResumptionToken {
    try {
      return requestParameters.compile();
    } catch (InvalidResumptionTokenException e) {
      throw new BadResumptionToken("The resumption token is invalid");
    }
  }
}
origin: com.lyncode/xoai-data-provider

throw new IdDoesNotExistException("This context does not include this item");
throw new CannotDisseminateRecordException("Format not applicable to this item");
  throw new OAIException(e);
} catch (TransformerException e) {
  throw new OAIException(e);
} catch (IOException e) {
  throw new OAIException(e);
} catch (XmlWriteException e) {
  throw new OAIException(e);
origin: IQSS/dataverse

@Override
public GetRecord handle(OAICompiledRequest parameters) throws OAIException, HandlerException {        
  MetadataFormat format = getContext().formatForPrefix(parameters.getMetadataPrefix());
  Item item = getRepository().getItemRepository().getItem(parameters.getIdentifier());
  if (getContext().hasCondition() &&
      !getContext().getCondition().getFilter(getRepository().getFilterResolver()).isItemShown(item))
    throw new IdDoesNotExistException("This context does not include this item");
  if (format.hasCondition() &&
      !format.getCondition().getFilter(getRepository().getFilterResolver()).isItemShown(item))
    throw new CannotDisseminateRecordException("Format not applicable to this item");
  
  Xrecord record = this.createRecord(parameters, item);
  GetRecord result = new XgetRecord(record);
  
  return result;
}

origin: DSpace/DSpace

  log.debug(e.getMessage(), e);
  return indexAction(response, model);
} catch (ContextServiceException e) {
                e);
} catch (OAIException e) {
  log.error(e.getMessage(), e);
  closeContext(context);
  response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
            "Unexpected error. For more information visit the log files.");
} catch (WritingXmlException e) {
  log.error(e.getMessage(), e);
  closeContext(context);
  response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
origin: com.lyncode/xoai-data-provider

@Override
public Item getItem(String identifier) throws IdDoesNotExistException, OAIException {
  for (InMemoryItem item : this.list) {
    if (item.getIdentifier().equals(identifier))
      return item;
  }
  throw new IdDoesNotExistException();
}
origin: com.lyncode/xoai-data-provider

@Override
public ListSets handle(OAICompiledRequest parameters) throws OAIException, HandlerException {
  ListSets result = new ListSets();
  if (!getRepository().getSetRepository().supportSets())
    throw new DoesNotSupportSetsException();
  int length = getRepository().getConfiguration().getMaxListSets();
  ListSetsResult listSetsResult = setRepositoryHelper.getSets(getContext(), getOffset(parameters), length);
  List<Set> sets = listSetsResult.getResults();
  if (sets.isEmpty() && parameters.getResumptionToken().isEmpty())
    throw new NoMatchesException();
  if (sets.size() > length)
    sets = sets.subList(0, length);
  for (Set set : sets) {
    result.getSets().add(set.toOAIPMH());
  }
  ResumptionToken.Value currentResumptionToken = new ResumptionToken.Value();
  if (parameters.hasResumptionToken()) {
    currentResumptionToken = parameters.getResumptionToken();
  } else if (listSetsResult.hasMore()) {
    currentResumptionToken = parameters.extractResumptionToken();
  }
  ResumptionTokenHelper resumptionTokenHelper = new ResumptionTokenHelper(currentResumptionToken,
      getRepository().getConfiguration().getMaxListSets());
  result.withResumptionToken(resumptionTokenHelper.resolve(listSetsResult.hasMore()));
  return result;
}
origin: com.lyncode/xoai-data-provider

private OAICompiledRequest(OAIRequest request, ResumptionTokenFormat resumptionTokenFormat)
    throws IllegalVerbException, BadArgumentException,
    UnknownParameterException, DuplicateDefinitionException, InvalidResumptionTokenException {
  Collection<String> parameterNames = request.getParameterNames();
  if (isTrueThat(parameterNames, not(hasItem(equalTo("verb")))))
    throw new IllegalVerbException("No verb provided");
  for (String parameterName : parameterNames)
    if (isTrueThat(parameterName, not(in("verb", "from", "until", "metadataPrefix", "identifier", "set", "resumptionToken"))))
      throw new UnknownParameterException("Unknown parameter '" + parameterName + "'");
  String until = request.getString(Until);
  String from = request.getString(From);
  if (isTrueThat(until, is(not(nullValue())))
      && isTrueThat(from, is(not(nullValue())))
      && from.length() != until.length())
    throw new BadArgumentException("Distinct granularities provided for until and from parameters");
  this.verbType = request.getVerb();
  this.from = request.getDate(From);
  this.until = request.getDate(Until);
  this.metadataPrefix = request.getString(MetadataPrefix);
  this.set = request.getString(Set);
  this.identifier = request.getString(Identifier);
  if (request.has(ResumptionToken))
    this.resumptionToken = resumptionTokenFormat.parse(request.getString(ResumptionToken));
  else
    this.resumptionToken = new ResumptionToken.Value();
  this.validate();
  this.loadResumptionToken(this.resumptionToken);
}
origin: com.lyncode/xoai-data-provider

      .withCode(Error.Code.NO_METADATA_FORMATS);
} else if (ex instanceof BadArgumentException) {
  return new Error(ex.getMessage())
      .withCode(Error.Code.BAD_ARGUMENT);
} else if (ex instanceof CannotDisseminateRecordException) {
      .withCode(Error.Code.CANNOT_DISSEMINATE_FORMAT);
} else if (ex instanceof DuplicateDefinitionException) {
  return new Error(ex.getMessage())
    .withCode(Error.Code.BAD_ARGUMENT);
} else if (ex instanceof UnknownParameterException) {
  return new Error(ex.getMessage())
    .withCode(Error.Code.BAD_ARGUMENT);
} else {
  return new Error(ex.getMessage())
    .withCode(Error.Code.BAD_ARGUMENT);
origin: com.lyncode/xoai-data-provider

public Context withSet(Set set) {
  if (!set.hasCondition())
    throw new InternalOAIException("Context sets must have a condition");
  this.sets.add(set);
  return this;
}
origin: com.lyncode/xoai-data-provider

public Type getVerb () throws DuplicateDefinitionException, IllegalVerbException {
  validate(Verb);
  String verb = get(Verb);
  if (verb == null)
    throw new IllegalVerbException("The verb given by the request is null, assuming identify");
  try {
    return fromValue(verb);
  } catch (IllegalArgumentException e) {
    throw new IllegalVerbException("The verb given by the request is unknown, assuming identify");
  }
}
origin: IQSS/dataverse

private OAICompiledRequest compileParameters(OAIRequest requestParameters) throws IllegalVerbException, UnknownParameterException, BadArgumentException, DuplicateDefinitionException, BadResumptionToken {
  try {
    return requestParameters.compile();
  } catch (InvalidResumptionTokenException e) {
    throw new BadResumptionToken("The resumption token is invalid");
  }
}    

origin: DSpace/DSpace

@Override
public Item getItem(String identifier) throws IdDoesNotExistException {
  if (identifier == null) {
    throw new IdDoesNotExistException();
  }
  String parts[] = identifier.split(Pattern.quote(":"));
  if (parts.length == 3) {
    try {
      SolrQuery params = new SolrQuery("item.handle:" + parts[2]);
      return new DSpaceSolrItem(DSpaceSolrSearch.querySingle(server, params));
    } catch (SolrSearchEmptyException ex) {
      throw new IdDoesNotExistException(ex);
    }
  }
  throw new IdDoesNotExistException();
}
origin: com.lyncode/xoai-data-provider

private Date getDate(String date, String param) throws BadArgumentException {
  if (date == null) return null;
  try {
    return dateProvider.parse(date);
  } catch (ParseException e) {
    throw new BadArgumentException("The " + param
        + " parameter given is not valid");
  }
}
origin: com.lyncode/xoai-data-provider

public IdentifyHandler(Context context, Repository repository) {
  super(context, repository);
  // Static validation
  RepositoryConfiguration configuration = getRepository().getConfiguration();
  if (configuration == null)
    throw new InternalOAIException("No repository configuration provided");
  if (configuration.getMaxListSets() <= 0)
    throw new InternalOAIException("The repository configuration must return maxListSets greater then 0");
  if (configuration.getMaxListIdentifiers() <= 0)
    throw new InternalOAIException("The repository configuration must return maxListIdentifiers greater then 0");
  if (configuration.getMaxListRecords() <= 0)
    throw new InternalOAIException("The repository configuration must return maxListRecords greater then 0");
  if (configuration.getAdminEmails() == null || configuration.getAdminEmails().isEmpty())
    throw new InternalOAIException("The repository configuration must return at least one admin email");
  try {
    if (configuration.getBaseUrl() == null)
      throw new InternalOAIException("The repository configuration must return a valid base url (absolute)");
    new URL(configuration.getBaseUrl());
  } catch (MalformedURLException e) {
    throw new InternalOAIException("The repository configuration must return a valid base url (absolute)", e);
  }
  if (configuration.getDeleteMethod() == null)
    throw new InternalOAIException("The repository configuration must return a valid delete method");
  if (configuration.getEarliestDate() == null)
    throw new InternalOAIException("The repository configuration must return a valid earliest date. That's the date of the first inserted item");
  if (configuration.getRepositoryName() == null)
    throw new InternalOAIException("The repository configuration must return a valid repository name");
}
origin: DSpace/DSpace

@Override
public ResumptionToken parse(String resumptionToken) throws BadResumptionToken {
  if (resumptionToken == null) {
    return new ResumptionToken();
  }
  String[] res = resumptionToken.split("/", -1);
  if (res.length != 5) {
    throw new BadResumptionToken();
  } else {
    try {
      int offset = Integer.parseInt(res[4]);
      String prefix = (res[0].equals("")) ? null : res[0];
      String set = (res[3].equals("")) ? null : res[3];
      Date from = (res[1].equals("")) ? null : DateUtils.parse(res[1]);
      Date until = res[2].equals("") ? null : DateUtils.parse(res[2]);
      return new ResumptionToken(offset, prefix, set, from, until);
    } catch (Exception e) {
      log.error(e.getMessage(), e);
      throw new BadResumptionToken();
    }
  }
}
origin: com.lyncode/xoai-data-provider

public Date getDate(Parameter parameter) throws BadArgumentException {
  if (!has(parameter)) return null;
  try {
    return dateProvider.parse(get(parameter));
  } catch (ParseException e) {
    throw new BadArgumentException("The " + parameter + " parameter given is not valid");
  }
}
origin: com.lyncode/xoai-data-provider

public ListMetadataFormatsHandler(Context context, Repository repository) {
  super(context, repository);
  itemRepositoryHelper = new ItemRepositoryHelper(repository.getItemRepository());
  // Static validation
  if (getContext().getMetadataFormats() == null ||
      getContext().getMetadataFormats().isEmpty())
    throw new InternalOAIException("The context must expose at least one metadata format");
}
origin: com.lyncode/xoai-data-provider

if (this.hasFrom() || this.hasSet() || this.hasUntil()
    || this.hasMetadataPrefix())
  throw new BadArgumentException(
      "ResumptionToken cannot be sent together with from, until, metadataPrefix or set parameters");
      || this.hasSet() || this.hasMetadataPrefix()
      || this.hasFrom() || this.hasUntil())
    throw new BadArgumentException(
        "Identify verb does not accept any extra parameter");
  break;
      || this.hasMetadataPrefix() || this.hasFrom()
      || this.hasUntil())
    throw new BadArgumentException(
        "ListMetadataFormats verb only accepts one optional parameter - identifier");
  break;
      || this.hasMetadataPrefix() || this.hasFrom()
      || this.hasUntil())
    throw new BadArgumentException(
        "ListSets verb only accepts one optional parameter - resumptionTokenResolver");
  break;
  if (!this.hasIdentifier() || !this.hasMetadataPrefix()
      || this.hasSet() || this.hasFrom() || this.hasUntil())
    throw new BadArgumentException(
        "GetRecord verb requires the use of the parameters - identifier and metadataPrefix");
  if (this.hasResumptionToken())
    throw new BadArgumentException(
com.lyncode.xoai.dataprovider.exceptions

Most used classes

  • BadResumptionToken
  • IdDoesNotExistException
  • OAIException
  • CannotDisseminateRecordException
  • DoesNotSupportSetsException
  • NoMatchesException,
  • BadArgumentException,
  • DuplicateDefinitionException,
  • IllegalVerbException,
  • InternalOAIException,
  • InvalidContextException,
  • NoMetadataFormatsException,
  • UnknownParameterException,
  • WritingXmlException
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now