All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.jscancella.conformance.profile.deserialize.FetchFileAllowedNodeDeserializer Maven / Gradle / Ivy

Go to download

This is a software library intended to support the creation, manipulation, and validation of "bags" from the bagit specification. It currently supports version 0.93 through 1.0.

There is a newer version: 5.2
Show newest version
package com.github.jscancella.conformance.profile.deserialize;

import java.util.ResourceBundle;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.NullNode;
import com.github.jscancella.conformance.profile.BagitProfileBuilder;

/**
 * responsible for deserializing "Allow-Fetch.txt" node from bagit profile
 */
public enum FetchFileAllowedNodeDeserializer {
  ;// using enum to ensure singleton
  private static final ResourceBundle messages = ResourceBundle.getBundle("MessageBundle");
  private static final Logger logger = LoggerFactory.getLogger(FetchFileAllowedNodeDeserializer.class);
  
  /**
   * @param node the json node to parse
   * @param builder the bagit profile builder
   */
  public static void parseFetchFileAllowed(final JsonNode node, final BagitProfileBuilder builder) {
    final JsonNode fetchIsAllowed = node.get("Allow-Fetch.txt");
    if(fetchIsAllowed != null && !(fetchIsAllowed instanceof NullNode)) {
      builder.setFetchFileAllowed(fetchIsAllowed.asBoolean());
    }
    logger.debug(messages.getString("fetch_allowed"), builder.isFetchAllowed());
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy