001/* 002 * Copyright 2015 DuraSpace, Inc. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.fcrepo.migration.handlers; 017 018import org.fcrepo.migration.DatastreamVersion; 019import org.fcrepo.migration.ObjectInfo; 020import org.fcrepo.migration.ObjectProperties; 021import org.fcrepo.migration.ObjectProperty; 022import org.fcrepo.migration.StreamingFedoraObjectHandler; 023 024/** 025 * A simple StreamingFedoraObjectHandler implementation that simply outputs information 026 * to the console. This is likely only useful for debugging or testing other 027 * code. 028 * @author mdurbin 029 */ 030public class ConsoleLoggingStreamingFedoraObjectHandler implements StreamingFedoraObjectHandler { 031 032 private long start; 033 034 @Override 035 public void beginObject(final ObjectInfo object) { 036 start = System.currentTimeMillis(); 037 System.out.println(object.getPid()); 038 } 039 040 @Override 041 public void processObjectProperties(final ObjectProperties properties) { 042 System.out.println(" Properties"); 043 for (final ObjectProperty p : properties.listProperties()) { 044 System.out.println(" " + p.getName() + " = " + p.getValue()); 045 } 046 } 047 048 @Override 049 public void processDatastreamVersion(final DatastreamVersion dsVersion) { 050 System.out.println(" " + dsVersion.getDatastreamInfo().getDatastreamId() + " version " 051 + dsVersion.getVersionId()); 052 } 053 054 @Override 055 public void processDisseminator() { 056 System.out.println(" DISSEMINATOR found and skipped!"); 057 } 058 059 @Override 060 public void completeObject(final ObjectInfo object) { 061 System.out.println(object.getPid() + " parsed in " + (System.currentTimeMillis() - start) + "ms."); 062 } 063 064 @Override 065 public void abortObject(final ObjectInfo object) { 066 System.out.println(object.getPid() + " failed to parse in " + (System.currentTimeMillis() - start) + "ms."); 067 } 068}