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

com.yourmediashelf.fedora.akubra.UUIDDatePathIdMapper Maven / Gradle / Ivy

There is a newer version: 0.5
Show newest version
/**
 * Copyright (C) 2012 MediaShelf 
 *
 * This file is part of uuid-datepath-idmapper.
 *
 * uuid-datepath-idmapper is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * uuid-datepath-idmapper is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with uuid-datepath-idmapper.  If not, see .
 */
package com.yourmediashelf.fedora.akubra;

import java.net.URI;
import java.util.UUID;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.akubraproject.map.IdMapper;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;

import com.fasterxml.uuid.UUIDType;
import com.fasterxml.uuid.impl.UUIDUtil;

/**
 * 

An Akubra IdMapper that maps version 1 UUIDs (i.e., time-based UUIDs) to * datetime-based paths. * *

This IdMapper should be configured to use a fallbackMapper, to handle ids * which are not version 1 UUIDs. * * @author Edwin Shin * */ public class UUIDDatePathIdMapper implements IdMapper { private static final String internalScheme = "file"; private IdMapper fallbackMapper; private Pattern pattern; private DateTimeFormatter fmt; /** * The number of 100-ns intervals between the UUID epoch 1582-10-15 00:00:00 * and the Unix epoch 1970-01-01 00:00:00. */ private final static long NUM_100NS_INTERVALS_SINCE_UUID_EPOCH = 0x01b21dd213814000L; /** *

Convenience constructor that uses the default dateFormat and fallbackMapper. * *

Note: the default fallbackMapper ({@link TrivialIdMapper}) is probably not * what you should be using. * */ public UUIDDatePathIdMapper() { this(null, null); } /** *

Convenience constructor that uses the default fallbackMapper. * *

Note: the default fallbackMapper ({@link TrivialIdMapper}) is probably not * what you should be using. * * @param dateFormat A {@link DateTimeFormat} pattern to generate the path. * * @see





© 2015 - 2024 Weber Informatics LLC | Privacy Policy