io.github.eliux.mega.cmd.MegaCmdLogin Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of megacmd4j Show documentation
Show all versions of megacmd4j Show documentation
Java client library that works on top of MEGAcmd to provide access to the services of Mega.nz
package io.github.eliux.mega.cmd;
import io.github.eliux.mega.MegaUtils;
import io.github.eliux.mega.error.MegaLoginException;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
public class MegaCmdLogin extends AbstractMegaCmdRunnerWithParams {
private final List cmdParams;
public MegaCmdLogin(String... cmdParams) {
super();
this.cmdParams = Arrays.asList(cmdParams);
}
@Override
public String getCmd() {
return "login";
}
@Override
protected void executeSysCmd(String... cmdStr) {
try {
final int result = MegaUtils.execCmd(cmdStr);
MegaUtils.handleResult(result);
} catch (IOException e) {
throw new MegaLoginException(
"Error while executing login command in Mega"
);
} catch (InterruptedException e) {
throw new MegaLoginException("The login was interrupted");
}
}
@Override
protected List cmdParams() {
return cmdParams;
}
}