compatible with file:/// and /
@@ -8,8 +8,6 @@ import org.zstack.core.db.SimpleQuery.Op;
import org.zstack.core.errorcode.ErrorFacade;
import org.zstack.header.apimediator.ApiMessageInterceptionException;
import org.zstack.header.apimediator.ApiMessageInterceptor;
-import org.zstack.header.apimediator.StopRoutingException;
-import org.zstack.header.errorcode.SysErrors;
import org.zstack.header.image.*;
import org.zstack.header.image.ImageConstant.ImageMediaType;
import org.zstack.header.message.APIMessage;
@@ -25,11 +23,11 @@ import org.zstack.header.volume.VolumeState;
import org.zstack.header.volume.VolumeStatus;
import org.zstack.header.volume.VolumeVO;
+import java.util.List;
+
import static org.zstack.core.Platform.argerr;
import static org.zstack.core.Platform.operr;
-import java.util.List;
-
/**
* Created with IntelliJ IDEA.
* User: frank
@@ -143,5 +141,12 @@ public class ImageApiInterceptor implements ApiMessageInterceptor {
}
msg.setBackupStorageUuids(bsUuids);
}
+
+ // compatible with file:/// and /
+ if (msg.getUrl().startsWith("/")) {
+ msg.setUrl(String.format("file://%s", msg.getUrl()));
+ } else if (!msg.getUrl().startsWith("file:///") && !msg.getUrl().startsWith("http://") && !msg.getUrl().startsWith("https://")) {
+ throw new ApiMessageInterceptionException(argerr("url must starts with 'file:///', 'http://', 'https://' or '/'"));
+ }
}
}
