class P2TempBlobUtils extends ComponentSupport {

  @VisibleForTesting
  public P2Attributes mergeAttributesFromTempBlob(final TempBlob tempBlob, final P2Attributes sourceP2Attributes)
      throws IOException
  {
    checkNotNull(sourceP2Attributes.getExtension());
    P2Attributes p2Attributes = null;
    try {
      // first try Features XML
      p2Attributes = featureXmlParser.getAttributesFromBlob(tempBlob, sourceP2Attributes.getExtension());

      // second try Manifest
      if (p2Attributes.isEmpty()) {
        p2Attributes = manifestParser.getAttributesFromBlob(tempBlob, sourceP2Attributes.getExtension());
      }
    }
    catch (AttributeParsingException ex) {
      log.warn("Could not get attributes from feature.xml due to following exception: {}", ex.getMessage());
    }

    return Optional.ofNullable(p2Attributes)
        .filter(jarP2Attributes -> !jarP2Attributes.isEmpty())
        .map(jarP2Attributes -> P2Attributes.builder().merge(sourceP2Attributes, jarP2Attributes).build())
        .orElse(sourceP2Attributes);
  }

  @Inject public  P2TempBlobUtils(final AttributesParserFeatureXml featureXmlParser,
                         final AttributesParserManifest manifestParser);

}