Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
More whitespace and static import cleanup
  • Loading branch information
ajs6f committed Oct 21, 2013
1 parent f8ef698 commit 16634cd
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions fcrepo-kernel/src/main/java/org/fcrepo/kernel/Transaction.java
Expand Up @@ -16,10 +16,14 @@

package org.fcrepo.kernel;

import static java.lang.System.currentTimeMillis;
import static java.util.UUID.randomUUID;
import static org.fcrepo.kernel.Transaction.State.COMMITED;
import static org.fcrepo.kernel.Transaction.State.DIRTY;
import static org.fcrepo.kernel.Transaction.State.ROLLED_BACK;

import java.util.Calendar;
import java.util.Date;
import java.util.UUID;

import javax.jcr.RepositoryException;
import javax.jcr.Session;

Expand Down Expand Up @@ -59,7 +63,7 @@ public Transaction(final Session session) {
super();
this.session = session;
this.created = new Date();
this.id = UUID.randomUUID().toString();
this.id = randomUUID().toString();
this.expires = Calendar.getInstance();
this.updateExpiryDate();
}
Expand Down Expand Up @@ -96,7 +100,7 @@ public String getId() {
*/
public State getState() throws RepositoryException {
if (this.session != null && this.session.hasPendingChanges()) {
return State.DIRTY;
return DIRTY;
}
return state;
}
Expand All @@ -116,7 +120,7 @@ public Date getExpires() {
*/
public void commit() throws RepositoryException {
this.session.save();
this.state = State.COMMITED;
this.state = COMMITED;
this.expire();
}

Expand All @@ -126,15 +130,15 @@ public void commit() throws RepositoryException {
*/
public void expire() throws RepositoryException {
this.session.logout();
this.expires.setTimeInMillis(System.currentTimeMillis());
this.expires.setTimeInMillis(currentTimeMillis());
}

/**
* Discard all unpersisted changes and expire
* @throws RepositoryException
*/
public void rollback() throws RepositoryException {
this.state = State.ROLLED_BACK;
this.state = ROLLED_BACK;
this.session.refresh(false);
this.expire();
}
Expand All @@ -150,6 +154,6 @@ public void updateExpiryDate() {
} else {
duration = DEFAULT_TIMEOUT;
}
this.expires.setTimeInMillis(System.currentTimeMillis() + duration);
this.expires.setTimeInMillis(currentTimeMillis() + duration);
}
}

0 comments on commit 16634cd

Please sign in to comment.