mirror of https://github.com/apache/archiva.git
correctlt close jcr session in case of exception
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1293682 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
31e5bf8148
commit
578d4c9858
|
@ -19,6 +19,9 @@ package org.apache.archiva.metadata.repository;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* The repository session provides a single interface to accessing Archiva repositories. It provides access to three
|
||||
* resources:
|
||||
|
@ -40,6 +43,8 @@ public class RepositorySession
|
|||
|
||||
private boolean dirty;
|
||||
|
||||
private Logger log = LoggerFactory.getLogger( getClass() );
|
||||
|
||||
// FIXME: include storage here too - perhaps a factory based on repository ID, or one per type to retrieve and
|
||||
// operate on a given repo within the storage API
|
||||
|
||||
|
@ -60,32 +65,17 @@ public class RepositorySession
|
|||
}
|
||||
|
||||
public void save()
|
||||
{
|
||||
try
|
||||
throws MetadataRepositoryException
|
||||
{
|
||||
repository.save();
|
||||
}
|
||||
catch ( MetadataRepositoryException e )
|
||||
{
|
||||
// FIXME
|
||||
throw new RuntimeException( e );
|
||||
}
|
||||
|
||||
dirty = false;
|
||||
}
|
||||
|
||||
public void revert()
|
||||
{
|
||||
try
|
||||
throws MetadataRepositoryException
|
||||
{
|
||||
repository.revert();
|
||||
}
|
||||
catch ( MetadataRepositoryException e )
|
||||
{
|
||||
// FIXME
|
||||
throw new RuntimeException( e );
|
||||
}
|
||||
|
||||
dirty = false;
|
||||
}
|
||||
|
||||
|
@ -96,14 +86,25 @@ public class RepositorySession
|
|||
* exception occurs.
|
||||
*/
|
||||
public void close()
|
||||
throws MetadataRepositoryException
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( dirty )
|
||||
{
|
||||
save();
|
||||
}
|
||||
|
||||
}
|
||||
catch ( MetadataRepositoryException e )
|
||||
{
|
||||
// olamy use revert here ?
|
||||
throw e;
|
||||
}
|
||||
finally
|
||||
{
|
||||
repository.close();
|
||||
}
|
||||
}
|
||||
|
||||
public void markDirty()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue