2929import javax .inject .Inject ;
3030
3131import org .apache .cloudstack .api .ApiConstants ;
32+ import org .apache .cloudstack .api .BaseCmd ;
3233import org .apache .cloudstack .api .command .user .iso .DeleteIsoCmd ;
3334import org .apache .cloudstack .api .command .user .iso .GetUploadParamsForIsoCmd ;
3435import org .apache .cloudstack .api .command .user .iso .RegisterIsoCmd ;
@@ -469,7 +470,7 @@ public TemplateProfile prepare(RegisterTemplateCmd cmd) throws ResourceAllocatio
469470 /**
470471 * Prepare upload parameters internal method for templates and ISOs local upload
471472 */
472- private TemplateProfile prepareUploadParamsInternal (UploadParams params ) throws ResourceAllocationException {
473+ private TemplateProfile prepareUploadParamsInternal (BaseCmd cmd , UploadParams params ) throws ResourceAllocationException {
473474 //check if the caller can operate with the template owner
474475 Account caller = CallContext .current ().getCallingAccount ();
475476 Account owner = _accountMgr .getAccount (params .getTemplateOwnerId ());
@@ -490,12 +491,16 @@ private TemplateProfile prepareUploadParamsInternal(UploadParams params) throws
490491 StringUtils .join (Arrays .stream (HypervisorType .values ()).filter (h -> h != HypervisorType .None ).map (HypervisorType ::name ).toArray (), ", " )));
491492 }
492493
494+ TemplateType templateType = templateMgr .validateTemplateType (cmd , _accountMgr .isAdmin (caller .getAccountId ()),
495+ false , params .getHypervisorType ());
496+
493497 return prepare (params .isIso (), params .getUserId (), params .getName (), params .getDisplayText (), params .getArch (), params .getBits (),
494498 params .isPasswordEnabled (), params .requiresHVM (), params .getUrl (), params .isPublic (), params .isFeatured (),
495499 params .isExtractable (), params .getFormat (), params .getGuestOSId (), zoneList ,
496500 params .getHypervisorType (), params .getChecksum (), params .isBootable (), params .getTemplateTag (), owner ,
497501 params .getDetails (), params .isSshKeyEnabled (), params .getImageStoreUuid (),
498- params .isDynamicallyScalable (), params .isRoutingType () ? TemplateType .ROUTING : TemplateType .USER , params .isDirectDownload (), params .isDeployAsIs (), false , null );
502+ params .isDynamicallyScalable (), templateType , params .isDirectDownload (), params .isDeployAsIs (),
503+ params .isForCks (), null );
499504 }
500505
501506 private Long getDefaultDeployAsIsGuestOsId () {
@@ -516,8 +521,9 @@ public TemplateProfile prepare(GetUploadParamsForTemplateCmd cmd) throws Resourc
516521 BooleanUtils .toBoolean (cmd .isFeatured ()), BooleanUtils .toBoolean (cmd .isExtractable ()), cmd .getFormat (), osTypeId ,
517522 cmd .getZoneId (), HypervisorType .getType (cmd .getHypervisor ()), cmd .getChecksum (),
518523 cmd .getTemplateTag (), cmd .getEntityOwnerId (), cmd .getDetails (), BooleanUtils .toBoolean (cmd .isSshKeyEnabled ()),
519- BooleanUtils .toBoolean (cmd .isDynamicallyScalable ()), BooleanUtils .toBoolean (cmd .isRoutingType ()), cmd .isDeployAsIs (), cmd .isForCks ());
520- return prepareUploadParamsInternal (params );
524+ BooleanUtils .toBoolean (cmd .isDynamicallyScalable ()), BooleanUtils .toBoolean (cmd .isRoutingType ()), cmd .isDeployAsIs (),
525+ cmd .isForCks (), cmd .getTemplateType ());
526+ return prepareUploadParamsInternal (cmd , params );
521527 }
522528
523529 @ Override
@@ -526,7 +532,7 @@ public TemplateProfile prepare(GetUploadParamsForIsoCmd cmd) throws ResourceAllo
526532 cmd .getDisplayText (), BooleanUtils .toBoolean (cmd .isPublic ()), BooleanUtils .toBoolean (cmd .isFeatured ()),
527533 BooleanUtils .toBoolean (cmd .isExtractable ()), cmd .getOsTypeId (),
528534 cmd .getZoneId (), BooleanUtils .toBoolean (cmd .isBootable ()), cmd .getEntityOwnerId ());
529- return prepareUploadParamsInternal (params );
535+ return prepareUploadParamsInternal (cmd , params );
530536 }
531537
532538 @ Override
0 commit comments