Revert "CLOUDSTACK-6940:Templates cannot be downloaded from URLs without"

This reverts commit 569e94908b6fa471f2f72578e1ff21f3fa7c6a4e.
This commit is contained in:
Min Chen 2014-08-11 17:03:53 -07:00
parent af37743045
commit a8316de725

View File

@ -16,6 +16,8 @@
// under the License.
package com.cloud.template;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
@ -122,6 +124,20 @@ public class HypervisorTemplateAdapter extends TemplateAdapterBase {
public TemplateProfile prepare(RegisterTemplateCmd cmd) throws ResourceAllocationException {
TemplateProfile profile = super.prepare(cmd);
String url = profile.getUrl();
String path = null;
try {
URL str = new URL(url);
path = str.getPath();
} catch (MalformedURLException ex) {
throw new InvalidParameterValueException("Please specify a valid URL. URL:" + url + " is invalid");
}
try {
checkFormat(cmd.getFormat(), url);
} catch (InvalidParameterValueException ex) {
checkFormat(cmd.getFormat(), path);
}
UriUtils.validateUrl(url);
profile.setUrl(url);
// Check that the resource limit for secondary storage won't be exceeded