001/**
002 * Copyright 2010-2014 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.kuali.common.util.secure.channel;
017
018import org.kuali.common.util.Assert;
019
020import com.google.common.base.Optional;
021
022/**
023 * @deprecated
024 */
025@Deprecated
026public final class RemoteFile {
027
028        private final String absolutePath;
029        private final Optional<Integer> groupId;
030        private final Optional<Integer> userId;
031        private final Optional<Integer> permissions;
032        private final Optional<Long> size;
033        private final boolean directory;
034        private final Optional<Status> status;
035
036        public static class Builder {
037
038                // Required
039                private final String absolutePath;
040
041                // Optional
042                private Optional<Integer> groupId = Optional.absent();
043                private Optional<Integer> userId = Optional.absent();
044                private Optional<Integer> permissions = Optional.absent();
045                private Optional<Long> size = Optional.absent();
046                private boolean directory = false;
047                private Optional<Status> status = Optional.absent();
048
049                public Builder(String absolutePath) {
050                        this.absolutePath = absolutePath;
051                }
052
053                public Builder clone(RemoteFile other) {
054                        this.groupId = other.groupId;
055                        this.userId = other.userId;
056                        this.permissions = other.permissions;
057                        this.size = other.size;
058                        this.directory = other.directory;
059                        this.status = other.status;
060                        return this;
061                }
062
063                public Builder groupId(int groupId) {
064                        this.groupId = Optional.of(groupId);
065                        return this;
066                }
067
068                public Builder userId(int userId) {
069                        this.userId = Optional.of(userId);
070                        return this;
071                }
072
073                public Builder permissions(int permissions) {
074                        this.permissions = Optional.of(permissions);
075                        return this;
076                }
077
078                public Builder size(long size) {
079                        this.size = Optional.of(size);
080                        return this;
081                }
082
083                public Builder directory(boolean directory) {
084                        this.directory = directory;
085                        return this;
086                }
087
088                public Builder status(Status status) {
089                        this.status = Optional.of(status);
090                        return this;
091                }
092
093                public RemoteFile build() {
094                        Assert.noBlanks(absolutePath);
095                        Assert.noNulls(groupId, userId, permissions, size, directory, status);
096                        if (size.isPresent()) {
097                                Assert.isTrue(size.get() >= 0, "size is negative");
098                        }
099                        return new RemoteFile(this);
100                }
101
102        }
103
104        private RemoteFile(Builder builder) {
105                this.absolutePath = builder.absolutePath;
106                this.groupId = builder.groupId;
107                this.userId = builder.userId;
108                this.permissions = builder.permissions;
109                this.size = builder.size;
110                this.directory = builder.directory;
111                this.status = builder.status;
112        }
113
114        public String getAbsolutePath() {
115                return absolutePath;
116        }
117
118        public Optional<Integer> getGroupId() {
119                return groupId;
120        }
121
122        public Optional<Integer> getUserId() {
123                return userId;
124        }
125
126        public Optional<Integer> getPermissions() {
127                return permissions;
128        }
129
130        public Optional<Long> getSize() {
131                return size;
132        }
133
134        public boolean isDirectory() {
135                return directory;
136        }
137
138        public Optional<Status> getStatus() {
139                return status;
140        }
141
142}