congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
SignatureFileException
Code IndexAdd Tabnine to your IDE (free)

How to use
SignatureFileException
in
uk.gov.nationalarchives.droid.core.interfaces.signature

Best Java code snippets using uk.gov.nationalarchives.droid.core.interfaces.signature.SignatureFileException (Showing top 18 results out of 315)

origin: digital-preservation/droid

/**
 * Opens a signature file for parsing.
 * 
 * @param filePath
 *            the file location (relative or absolute) of the signature file
 *            to parse.
 * @throws SignatureFileException
 *             if the path specified was not a valid signature file.
 */
private Path openFile(final URI filePath) throws SignatureFileException {
  final Path f = Paths.get(filePath);
  if (!Files.exists(f)) {
    throw new SignatureFileException(String.format(
        "Signature file does not exist [%s]", filePath),
        ErrorCode.FILE_NOT_FOUND);
  }
  if (!Files.isRegularFile(f)) {
    throw new SignatureFileException(String.format(
        INVALID_SIGNATURE_FILE, filePath),
        ErrorCode.INVALID_SIGNATURE_FILE);
  }
  return f;
}
origin: digital-preservation/droid

/**
 * Executes this action.
 * @param parent the parent window
 */
public void execute(Window parent) {
  final Path f = Paths.get(fileName);
  try {
    final SignatureFileInfo info = signatureManager.install(type, f, useAsDefault);
    final String message = String.format("Signature file %s has been installed", info.getFile().getFileName().toString());
    JOptionPane.showMessageDialog(parent, message, "Signature file installed", JOptionPane.INFORMATION_MESSAGE);
  } catch (final SignatureFileException e) {
    JOptionPane.showMessageDialog(parent, e.getMessage(), 
        "Error installing signature file", JOptionPane.ERROR_MESSAGE);
  }            
}
origin: uk.gov.nationalarchives/droid-results

/**
 * Opens a signature file for parsing.
 * 
 * @param filePath
 *            the file location (relative or absolute) of the signature file
 *            to parse.
 * @throws SignatureFileException
 *             if the path specified was not a valid signature file.
 */
private File openFile(URI filePath) throws SignatureFileException {
  File f = new File(filePath);
  if (!f.exists()) {
    throw new SignatureFileException(String.format(
        "Signature file does not exist [%s]", filePath),
        ErrorCode.FILE_NOT_FOUND);
  }
  if (!f.isFile()) {
    throw new SignatureFileException(String.format(
        INVALID_SIGNATURE_FILE, filePath),
        ErrorCode.INVALID_SIGNATURE_FILE);
  }
  return f;
}
origin: uk.gov.nationalarchives/droid-ui

/**
 * Executes this action.
 * @param parent the parent window
 */
public void execute(Window parent) {
  File f = new File(fileName);
  try {
    SignatureFileInfo info = signatureManager.install(type, f, useAsDefault);
    String message = String.format("Signature file %s has been installed", info.getFile().getName());
    JOptionPane.showMessageDialog(parent, message, "Signature file installed", JOptionPane.INFORMATION_MESSAGE);
  } catch (SignatureFileException e) {
    JOptionPane.showMessageDialog(parent, e.getMessage(), 
        "Error installing signature file", JOptionPane.ERROR_MESSAGE);
  }            
}
origin: digital-preservation/droid

/**
 * {@inheritDoc}
 */
@Override
public void formats(final FormatCallback callback) throws SignatureFileException {
  final FileFormatHandler handler = new FileFormatHandler(callback);
  final SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
  try {
    final SAXParser saxParser = saxParserFactory.newSAXParser();
    saxParser.parse(file.toFile(), handler);
  } catch (SAXException e) {
    throw new SignatureFileException(String.format(
        INVALID_SIGNATURE_FILE, file.toUri()), e,
        ErrorCode.INVALID_SIGNATURE_FILE);
  } catch (final ParserConfigurationException | IOException e) {
    log.error(e.getMessage(), e);
    throw new RuntimeException(e.getMessage(), e);
  }
}
origin: digital-preservation/droid

  signatures = signatureManager.getDefaultSignatures();
} catch (SignatureFileException e) {
  throw new ProfileManagerException(e.getMessage());
origin: uk.gov.nationalarchives/droid-results

private static SignatureFileInfo forSimpleVersionedFile(File file, SignatureType type) 
  throws SignatureFileException {
  // parse the version from the filename
  String filename = FilenameUtils.getBaseName(file.getName());
  try {
    int version = Integer.valueOf(StringUtils.substringAfterLast(filename, "-"));
    final SignatureFileInfo signatureFileInfo = new SignatureFileInfo(version, false, type);
    signatureFileInfo.setFile(file);
    return signatureFileInfo;
  } catch (NumberFormatException e) {
    String message = String.format("Invalid signature filename [%s]", file.getName());
    throw new SignatureFileException(message, e, ErrorCode.INVALID_SIGNATURE_FILE);
  }
}
 
origin: uk.gov.nationalarchives/droid-results

  signatures = signatureManager.getDefaultSignatures();
} catch (SignatureFileException e) {
  throw new ProfileManagerException(e.getMessage());
origin: uk.gov.nationalarchives/droid-results

/**
 * {@inheritDoc}
 */
@Override
public void formats(FormatCallback callback) throws SignatureFileException {
  FileFormatHandler handler = new FileFormatHandler(callback);
  SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
  try {
    SAXParser saxParser = saxParserFactory.newSAXParser();
    saxParser.parse(file, handler);
  } catch (SAXException e) {
    throw new SignatureFileException(String.format(
        INVALID_SIGNATURE_FILE, file.toURI()), e,
        ErrorCode.INVALID_SIGNATURE_FILE);
  } catch (ParserConfigurationException e) {
    log.error(e);
    throw new RuntimeException(e.getMessage(), e);
  } catch (IOException e) {
    log.error(e);
    throw new RuntimeException(e.getMessage(), e);
  }
}
origin: digital-preservation/droid

  SignatureFileInfo parse(final Path sigFile) throws SignatureFileException {
  
    final SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
    final SignatureFileVersionHandler handler = new SignatureFileVersionHandler();
    try {
      final SAXParser saxParser = saxParserFactory.newSAXParser();
      saxParser.parse(sigFile.toFile(), handler);
      throw new SignatureFileException(String.format(
          INVALID_SIGNATURE_FILE, sigFile), ErrorCode.INVALID_SIGNATURE_FILE);
    } catch (final ValidSignatureFileException e) {
      return e.getInfo();
    } catch (final SAXException e) {
      throw new SignatureFileException(String.format(
          INVALID_SIGNATURE_FILE, sigFile), e,
          ErrorCode.INVALID_SIGNATURE_FILE);
    } catch (final ParserConfigurationException | IOException e) {
      throw new RuntimeException(e.getMessage(), e);
    }
  }
}
origin: uk.gov.nationalarchives/droid-results

  SignatureFileInfo parse(File sigFile) throws SignatureFileException {
  
    SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
    final SignatureFileVersionHandler handler = new SignatureFileVersionHandler();
    try {
      SAXParser saxParser = saxParserFactory.newSAXParser();
      saxParser.parse(sigFile, handler);
      throw new SignatureFileException(String.format(
          INVALID_SIGNATURE_FILE, sigFile), ErrorCode.INVALID_SIGNATURE_FILE);
    } catch (ValidSignatureFileException e) {
      return e.getInfo();
    } catch (SAXException e) {
      throw new SignatureFileException(String.format(
          INVALID_SIGNATURE_FILE, sigFile), e,
          ErrorCode.INVALID_SIGNATURE_FILE);
    } catch (ParserConfigurationException e) {
      throw new RuntimeException(e.getMessage(), e);
    } catch (IOException e) {
      throw new RuntimeException(e.getMessage(), e);
    }
  }
}
origin: digital-preservation/droid

private static SignatureFileInfo forSimpleVersionedFile(final Path file, final SignatureType type)
  throws SignatureFileException {
  // parse the version from the filename
  final String filename = FilenameUtils.getBaseName(FileUtil.fileName(file));
  try {
    final int version = Integer.valueOf(StringUtils.substringAfterLast(filename, "-"));
    final SignatureFileInfo signatureFileInfo = new SignatureFileInfo(version, false, type);
    signatureFileInfo.setFile(file);
    return signatureFileInfo;
  } catch (final NumberFormatException e) {
    final String message = String.format("Invalid signature filename [%s]", FileUtil.fileName(file));
    throw new SignatureFileException(message, e, ErrorCode.INVALID_SIGNATURE_FILE);
  }
}
 
origin: uk.gov.nationalarchives/droid-results

String errorMessage = String.format(errorMessagePattern, config.getProperties()
    .getString(defaultVersionProperties.get(type).getName()));
throw new SignatureFileException(errorMessage, ErrorCode.FILE_NOT_FOUND);
origin: digital-preservation/droid

String errorMessage = String.format(errorMessagePattern, config.getProperties()
    .getString(defaultVersionProperties.get(type).getName()));
throw new SignatureFileException(errorMessage, ErrorCode.FILE_NOT_FOUND);
origin: uk.gov.nationalarchives/droid-results

/**
 * {@inheritDoc}
 */
@Override
public SignatureFileInfo install(SignatureType type, File signatureFile, boolean setDefault) 
  throws SignatureFileException {
  
  SignatureInfoParser parser = new SignatureInfoParser();
  SignatureFileInfo sigFileInfo = forBinarySigFile(signatureFile, parser);
  try {
    FileUtils.copyFileToDirectory(signatureFile, config.getSignatureFileDir(), true);
    File newSignatureFile = new File(config.getSignatureFileDir(), signatureFile.getName());
    
    sigFileInfo.setFile(newSignatureFile);
    
    if (setDefault) {
      config.getProperties().setProperty(defaultVersionProperties.get(type).getName(), 
          FilenameUtils.getBaseName(newSignatureFile.getName()));
    }
    return sigFileInfo;
  } catch (IOException e) {
    log.error(e);
    throw new SignatureFileException(e.getMessage(), e, ErrorCode.FILE_NOT_FOUND);
  }
}
 
origin: digital-preservation/droid

/**
 * {@inheritDoc}
 */
@Override
public SignatureFileInfo install(final SignatureType type, final Path signatureFile, final boolean setDefault)
    throws SignatureFileException {
  final SignatureInfoParser parser = new SignatureInfoParser();
  final SignatureFileInfo sigFileInfo = forBinarySigFile(signatureFile, parser);
  try {
    final Path newSignatureFile = Files.copy(signatureFile, config.getSignatureFileDir());
    sigFileInfo.setFile(newSignatureFile);
    
    if (setDefault) {
      config.getProperties().setProperty(defaultVersionProperties.get(type).getName(), 
          FilenameUtils.getBaseName(FileUtil.fileName(newSignatureFile)));
    }
    return sigFileInfo;
  } catch (final IOException e) {
    log.error(e.getMessage(), e);
    throw new SignatureFileException(e.getMessage(), e, ErrorCode.FILE_NOT_FOUND);
  }
}
 
origin: digital-preservation/droid

  throw new SignatureFileException(ERROR_READING_SIGNATURE_FILE, e, ErrorCode.FILE_NOT_FOUND);
} catch (SignatureParseException e) {
  throw new SignatureFileException(ERROR_READING_SIGNATURE_FILE, e, ErrorCode.INVALID_SIGNATURE_FILE);
origin: uk.gov.nationalarchives/droid-container

  throw new SignatureFileException(ERROR_READING_SIGNATURE_FILE, e, ErrorCode.FILE_NOT_FOUND);
} catch (SignatureParseException e) {
  throw new SignatureFileException(ERROR_READING_SIGNATURE_FILE, e, ErrorCode.INVALID_SIGNATURE_FILE);
uk.gov.nationalarchives.droid.core.interfaces.signatureSignatureFileException

Most used methods

  • <init>
    Constructs a new SignatureFileException with a message.
  • getMessage

Popular in Java

  • Parsing JSON documents to java classes using gson
  • getSystemService (Context)
  • scheduleAtFixedRate (Timer)
  • setScale (BigDecimal)
  • Point (java.awt)
    A point representing a location in (x,y) coordinate space, specified in integer precision.
  • Thread (java.lang)
    A thread is a thread of execution in a program. The Java Virtual Machine allows an application to ha
  • SocketTimeoutException (java.net)
    This exception is thrown when a timeout expired on a socket read or accept operation.
  • URLConnection (java.net)
    A connection to a URL for reading or writing. For HTTP connections, see HttpURLConnection for docume
  • JButton (javax.swing)
  • JTable (javax.swing)
  • Best plugins for Eclipse
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