FilesMetadataInfo.java

/*
 * Copyright 2017 Global Crop Diversity Trust
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.genesys.server.service.impl;

// import org.apache.commons.codec.binary.Hex;
import org.genesys.filerepository.model.RepositoryFile;
import org.springframework.stereotype.Component;

/**
 * @author Andrey Lugovskoy.
 */
@Component
public class FilesMetadataInfo extends ExporterToCSV<RepositoryFile> {

	// @formatter:off
	private final String[] CSV_HEADERS = new String[] { 
			"uuid", 
			"version",
			"contentType", 
			"path", 
			"extension", 
			"originalFilename", 
			"title", 
			"subject", 
			"description", 
			"creator", 
			"created",
			"rightsHolder", 
			"accessRights", 
			"license", 
			"bibliographicCitation",
			"md5",
			// "sha1",
			// "sha384",
	};
	// @formatter:on

	@Override
	protected String[] writeHeaders() {
		return CSV_HEADERS;
	}

	@Override
	protected String[] prepareLine(RepositoryFile element) {
		// @formatter:off
		return new String[] { 
				element.getUuid().toString(),
				element.getVersion().toString(),
				element.getContentType(), 
				element.getFolder().getPath(), 
				element.getExtension(), 
				element.getOriginalFilename(), 
				element.getTitle(), 
				element.getSubject(),
				element.getDescription(), 
				element.getCreator(), 
				element.getCreated(), 
				element.getRightsHolder(),
				element.getAccessRights(),
				element.getLicense(), 
				element.getBibliographicCitation(),
				element.getMd5Sum(),
				// element.getSha1Sum(),
				// element.getSha384() == null ? "" : Hex.encodeHexString(element.getSha384())
		};
		// @formatter:on
	}
}