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.channel.api;
017
018import java.io.File;
019import java.io.IOException;
020import java.io.InputStream;
021import java.io.OutputStream;
022import java.util.List;
023
024import org.kuali.common.util.channel.model.CommandContext;
025import org.kuali.common.util.channel.model.CommandResult;
026import org.kuali.common.util.channel.model.CopyResult;
027import org.kuali.common.util.channel.model.RemoteFile;
028
029public interface SecureChannel {
030
031        CommandResult exec(CommandContext context);
032
033        List<CommandResult> exec(CommandContext... contexts);
034
035        /**
036         * Pass this command to a remote server as a sequence of bytes encoded using UTF-8
037         */
038        CommandResult exec(String command);
039
040        /**
041         * Pass each command to a remote server as a sequence of bytes encoded using UTF-8
042         */
043        List<CommandResult> exec(String... commands);
044
045        /**
046         * Pass this command to a remote server as a sequence of bytes encoded using UTF-8
047         */
048        void execNoWait(String command);
049
050        void execNoWait(byte[] command);
051
052        CopyResult scp(File source, RemoteFile destination);
053
054        CopyResult scp(String location, RemoteFile destination);
055
056        CopyResult scp(InputStream source, RemoteFile destination);
057
058        /**
059         * Copy the contents of <code>string</code> to <code>destination</code>
060         */
061        CopyResult scpString(String string, RemoteFile destination);
062
063        CopyResult scpToDir(String location, RemoteFile directory);
064
065        CopyResult scpToDir(File source, RemoteFile directory);
066
067        CopyResult scp(RemoteFile source, File destination);
068
069        CopyResult scpToDir(RemoteFile source, File directory);
070
071        RemoteFile getMetaData(String absolutePath);
072
073        boolean exists(String absolutePath);
074
075        boolean isDirectory(String absolutePath);
076
077        void deleteFile(String absolutePath);
078
079        void createDirectory(RemoteFile dir);
080
081        RemoteFile getWorkingDirectory();
082
083        CopyResult scp(String absolutePath, OutputStream out) throws IOException;
084
085        CopyResult scp(RemoteFile source, OutputStream out) throws IOException;
086
087        String toString(RemoteFile source);
088
089        void close();
090
091}