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

java.fedora.server.journal.entry.CreatorJournalEntry Maven / Gradle / Ivy

Go to download

The Fedora Client is a Java Library that allows API access to a Fedora Repository. The client is typically one part of a full Fedora installation.

The newest version!
/*
 * -----------------------------------------------------------------------------
 *
 * 

License and Copyright: The contents of this file are subject to 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.fedora-commons.org/licenses.

* *

Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for * the specific language governing rights and limitations under the License.

* *

The entire file consists of original code.

*

Copyright © 2008 Fedora Commons, Inc.
*

Copyright © 2002-2007 The Rector and Visitors of the University of * Virginia and Cornell University
* All rights reserved.

* * ----------------------------------------------------------------------------- */ package fedora.server.journal.entry; import fedora.server.Context; import fedora.server.errors.ServerException; import fedora.server.journal.JournalException; import fedora.server.journal.JournalOperatingMode; import fedora.server.journal.JournalWriter; import fedora.server.management.ManagementDelegate; /** *

* Title: CreatorJournalEntry.java *

*

* Description: The JournalEntry to use when creating a journal file. * When invoking the management method, take a moment to write to the journal * before returning. *

* * @author [email protected] * @version $Id: CreatorJournalEntry.java 6758 2008-03-09 19:05:49 +0000 (Sun, * 09 Mar 2008) j2blake $ */ public class CreatorJournalEntry extends JournalEntry { /** * Don't store the Context that was given; store a writable version of it. */ public CreatorJournalEntry(String methodName, Context context) { super(methodName, new JournalEntryContext(context)); } /** * Process the management method: *
    *
  • Check the operating mode - if we are in * {@link JournalOperatingMode#READ_ONLY Read-Only} mode, this check will * throw an exception.
  • *
  • Prepare the writer in case we need to initialize a new file with a * repository hash.
  • *
  • Invoke the method on the ManagementDelegate.
  • *
  • Write the full journal entry, including any context changes from the * Management method.
  • *
* These operations occur within a synchronized block. We must be sure that * any pending operations are complete before we get the repository hash, so * we are confident that the hash accurately reflects the state of the * repository. Since all API-M operations go through this synchronized * block, we can be confident that the previous one had completed before the * current one started. *

* There might be a way to enforce the synchronization at a lower level, * thus increasing throughput, but we haven't explored it yet. */ public Object invokeMethod(ManagementDelegate delegate, JournalWriter writer) throws ServerException, JournalException { synchronized (JournalWriter.SYNCHRONIZER) { JournalOperatingMode.enforceCurrentMode(); writer.prepareToWriteJournalEntry(); Object result = super.getMethod().invoke(delegate); writer.writeJournalEntry(this); return result; } } /** * A convenience method that invokes the management method and then closes * the JournalEntry, thereby cleaning up any temp files. */ public Object invokeAndClose(ManagementDelegate delegate, JournalWriter writer) throws ServerException, JournalException { Object result = invokeMethod(delegate, writer); close(); return result; } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy