001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: *
017: */
018:
019: /* $Id: FileReservedCheckInException.java 473861 2006-11-12 03:51:14Z gregor $ */
020:
021: package org.apache.lenya.cms.rc;
022:
023: import java.util.Date;
024:
025: /**
026: * Reserved check-in exception
027: */
028: public class FileReservedCheckInException extends Exception {
029: /**
030: *
031: */
032: private static final long serialVersionUID = 1L;
033: private String source = null;
034: private Date date = null;
035: private String username = null;
036: private String typeString = null;
037: private short type;
038:
039: /**
040: * Creates a new FileReservedCheckInException object.
041: *
042: * @param _source The source document
043: * @param rcml The RCML
044: *
045: * @throws Exception if an error occurs
046: */
047: public FileReservedCheckInException(String _source, RCML rcml)
048: throws Exception {
049: this .source = _source;
050:
051: try {
052: RCMLEntry rcmlEntry = rcml.getLatestEntry();
053:
054: this .username = rcmlEntry.getIdentity();
055: this .date = new Date(rcmlEntry.getTime());
056: this .type = rcmlEntry.getType();
057:
058: if (this .type == RCML.co) {
059: this .typeString = "Checkout";
060: } else {
061: this .typeString = "Checkin";
062: }
063: } catch (Exception exception) {
064: throw new Exception(
065: "Unable to create FileReservedCheckInException object!");
066: }
067: }
068:
069: /**
070: * Returns the exception message
071: * @return The exception message
072: */
073: public String getMessage() {
074: return "Unable to check in the file " + this .source
075: + " because of a " + this .typeString + " by user "
076: + this .username + " at " + this .date;
077: }
078:
079: /**
080: * Get the date
081: * @return the date
082: */
083: public Date getDate() {
084: return new Date(this .date.getTime());
085: }
086:
087: /**
088: * Get the typeString
089: * @return the type string
090: */
091: public String getTypeString() {
092: return this .typeString;
093: }
094:
095: /**
096: * Get the user name.
097: * @return the user name
098: */
099: public String getUsername() {
100: return this .username;
101: }
102:
103: /**
104: * Get the source
105: * @return The source
106: */
107: public String getSource() {
108: return this.source;
109: }
110: }
|