2 * Copyright (C) 2007-2012 Argeo GmbH
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org
.argeo
.cms
.internal
.backup
;
18 import java
.text
.DateFormat
;
19 import java
.text
.SimpleDateFormat
;
20 import java
.util
.Date
;
22 import org
.apache
.commons
.vfs2
.FileSystemManager
;
24 /** Simple implementation of a backup context */
25 public class SimpleBackupContext
implements BackupContext
{
26 private DateFormat dateFormat
= new SimpleDateFormat("yyyyMMdd_HHmm");
27 private final Date timestamp
;
28 private final String name
;
30 private final FileSystemManager fileSystemManager
;
32 public SimpleBackupContext(FileSystemManager fileSystemManager
,
33 String backupsBase
, String name
) {
35 this.timestamp
= new Date();
36 this.fileSystemManager
= fileSystemManager
;
39 public Date
getTimestamp() {
43 public String
getTimestampAsString() {
44 return dateFormat
.format(timestamp
);
47 public String
getSystemName() {
51 public String
getRelativeFolder() {
52 return name
+ '/' + getTimestampAsString();
55 public DateFormat
getDateFormat() {
59 public FileSystemManager
getFileSystemManager() {
60 return fileSystemManager
;