in odps-console-resource/src/main/java/com/aliyun/openservices/odps/console/resource/AddResourceCommand.java [126:199]
public void run() throws OdpsException, ODPSConsoleException {
String aliasSuffix;
if (StringUtils.isNullOrEmpty(alias)) {
aliasSuffix = refName.toUpperCase();
} else {
aliasSuffix = alias.toUpperCase();
}
// file/py/jar/archive
if (type.equals("PY") && !aliasSuffix.endsWith(".PY")) {
// 则命令出错
throw new ODPSConsoleException(ODPSConsoleConstants.FILENAME_ENDWITH_PY);
}
if (type.equals("JAR") && !aliasSuffix.endsWith(".JAR")) {
// 则命令出错
throw new ODPSConsoleException(ODPSConsoleConstants.FILENAME_ENDWITH_JAR);
}
// .jar/.zip/.tgz/.tar.gz/.tar/.whl
if (type.endsWith("ARCHIVE")
&& !(aliasSuffix.endsWith(".JAR")
|| aliasSuffix.endsWith(".ZIP") || aliasSuffix.endsWith(".TGZ")
|| aliasSuffix.endsWith(".TAR.GZ") || aliasSuffix.endsWith(".TAR")
|| aliasSuffix.endsWith(".WHL"))) {
// 则命令出错
throw new ODPSConsoleException(ODPSConsoleConstants.FILENAME_ENDWITH_MORE);
}
if (!StringUtils.isNullOrEmpty(partitionSpec) && StringUtils.isNullOrEmpty(alias)) {
// 如果出现partition (spec),则必须带alias
throwUsageError(System.err, "pls set alias.");
}
Odps odps = getCurrentOdps();
if (StringUtils.isNullOrEmpty(projectName)) {
projectName = getCurrentProject();
schemaName = ODPSConsoleUtils.getDefaultSchema(getContext());
}
FileResource resource = null;
Type resType = Type.valueOf(type.toUpperCase());
switch (resType) {
case VOLUMEFILE:
case VOLUMEARCHIVE:
addVolume(odps);
break;
case ARCHIVE:
resource = new ArchiveResource();
break;
case PY:
resource = new PyResource();
break;
case JAR:
resource = new JarResource();
break;
case FILE:
resource = new FileResource();
break;
case TABLE:
addTable(odps);
break;
}
if (resource != null) {
addFile(odps, resource);
}
if (!isUpdate) {
getWriter().writeError("OK: Resource '" + alias + "' have been created.");
} else {
getWriter().writeError("OK: Resource '" + alias + "' have been updated.");
}
}