@@ -640,7 +640,6 @@ public String getHelpFile(String fieldName) {
640640 }
641641
642642 public FormValidation doCheckNetworkTags (@ QueryParameter String value ) {
643- checkPermissions ();
644643 if (value == null || value .isEmpty ()) {
645644 return FormValidation .ok ();
646645 }
@@ -657,7 +656,6 @@ public FormValidation doCheckNetworkTags(@QueryParameter String value) {
657656 }
658657
659658 public FormValidation doCheckNamePrefix (@ QueryParameter String value ) {
660- checkPermissions ();
661659 if (value == null || value .isEmpty ()) {
662660 return FormValidation .error ("A prefix is required" );
663661 }
@@ -675,7 +673,6 @@ public FormValidation doCheckNamePrefix(@QueryParameter String value) {
675673 }
676674
677675 public FormValidation doCheckDescription (@ QueryParameter String value ) {
678- checkPermissions ();
679676 if (value == null || value .isEmpty ()) {
680677 return FormValidation .error ("A description is required" );
681678 }
@@ -686,7 +683,7 @@ public ListBoxModel doFillRegionItems(
686683 @ AncestorInPath Jenkins context ,
687684 @ QueryParameter ("projectId" ) @ RelativePath (".." ) final String projectId ,
688685 @ QueryParameter ("credentialsId" ) @ RelativePath (".." ) final String credentialsId ) {
689- checkPermissions ();
686+ checkPermissions (Jenkins . get (), Jenkins . ADMINISTER );
690687 ListBoxModel items = new ListBoxModel ();
691688 items .add ("" );
692689 try {
@@ -708,7 +705,7 @@ public ListBoxModel doFillTemplateItems(
708705 @ AncestorInPath Jenkins context ,
709706 @ QueryParameter ("projectId" ) @ RelativePath (".." ) final String projectId ,
710707 @ QueryParameter ("credentialsId" ) @ RelativePath (".." ) final String credentialsId ) {
711- checkPermissions ();
708+ checkPermissions (Jenkins . get (), Jenkins . ADMINISTER );
712709 ListBoxModel items = new ListBoxModel ();
713710 items .add ("" );
714711 try {
@@ -727,8 +724,7 @@ public ListBoxModel doFillTemplateItems(
727724 }
728725
729726 public FormValidation doCheckRegion (@ QueryParameter String value ) {
730- checkPermissions ();
731- if (value .equals ("" )) {
727+ if (StringUtils .isEmpty (value )) {
732728 return FormValidation .error ("Please select a region..." );
733729 }
734730 return FormValidation .ok ();
@@ -739,7 +735,7 @@ public ListBoxModel doFillZoneItems(
739735 @ QueryParameter ("projectId" ) @ RelativePath (".." ) final String projectId ,
740736 @ QueryParameter ("region" ) final String region ,
741737 @ QueryParameter ("credentialsId" ) @ RelativePath (".." ) final String credentialsId ) {
742- checkPermissions ();
738+ checkPermissions (Jenkins . get (), Jenkins . ADMINISTER );
743739 ListBoxModel items = new ListBoxModel ();
744740 items .add ("" );
745741 try {
@@ -761,8 +757,7 @@ public ListBoxModel doFillZoneItems(
761757 }
762758
763759 public FormValidation doCheckZone (@ QueryParameter String value ) {
764- checkPermissions ();
765- if (value .equals ("" )) {
760+ if (StringUtils .isEmpty (value )) {
766761 return FormValidation .error ("Please select a zone..." );
767762 }
768763 return FormValidation .ok ();
@@ -773,7 +768,7 @@ public ListBoxModel doFillMachineTypeItems(
773768 @ QueryParameter ("projectId" ) @ RelativePath (".." ) final String projectId ,
774769 @ QueryParameter ("zone" ) final String zone ,
775770 @ QueryParameter ("credentialsId" ) @ RelativePath (".." ) final String credentialsId ) {
776- checkPermissions ();
771+ checkPermissions (Jenkins . get (), Jenkins . ADMINISTER );
777772 ListBoxModel items = new ListBoxModel ();
778773 items .add ("" );
779774 try {
@@ -795,8 +790,7 @@ public ListBoxModel doFillMachineTypeItems(
795790 }
796791
797792 public FormValidation doCheckMachineType (@ QueryParameter String value ) {
798- checkPermissions ();
799- if (value .equals ("" )) {
793+ if (StringUtils .isEmpty (value )) {
800794 return FormValidation .error ("Please select a machine type..." );
801795 }
802796 return FormValidation .ok ();
@@ -807,7 +801,7 @@ public ListBoxModel doFillMinCpuPlatformItems(
807801 @ QueryParameter ("projectId" ) @ RelativePath (".." ) final String projectId ,
808802 @ QueryParameter ("zone" ) final String zone ,
809803 @ QueryParameter ("credentialsId" ) @ RelativePath (".." ) final String credentialsId ) {
810- checkPermissions ();
804+ checkPermissions (Jenkins . get (), Jenkins . ADMINISTER );
811805 ListBoxModel items = new ListBoxModel ();
812806 items .add ("" );
813807 try {
@@ -833,7 +827,7 @@ public ListBoxModel doFillBootDiskTypeItems(
833827 @ QueryParameter ("projectId" ) @ RelativePath (".." ) final String projectId ,
834828 @ QueryParameter ("zone" ) String zone ,
835829 @ QueryParameter ("credentialsId" ) @ RelativePath (".." ) final String credentialsId ) {
836- checkPermissions ();
830+ checkPermissions (Jenkins . get (), Jenkins . ADMINISTER );
837831 ListBoxModel items = new ListBoxModel ();
838832 try {
839833 ComputeClient compute = computeClient (context , credentialsId );
@@ -856,7 +850,7 @@ public ListBoxModel doFillBootDiskTypeItems(
856850 public ListBoxModel doFillBootDiskSourceImageProjectItems (
857851 @ AncestorInPath Jenkins context ,
858852 @ QueryParameter ("projectId" ) @ RelativePath (".." ) final String projectId ) {
859- checkPermissions ();
853+ checkPermissions (Jenkins . get (), Jenkins . ADMINISTER );
860854 ListBoxModel items = new ListBoxModel ();
861855 items .add ("" );
862856 items .add (projectId );
@@ -867,8 +861,7 @@ public ListBoxModel doFillBootDiskSourceImageProjectItems(
867861 }
868862
869863 public FormValidation doCheckBootDiskSourceImageProject (@ QueryParameter String value ) {
870- checkPermissions ();
871- if (value .equals ("" )) {
864+ if (StringUtils .isEmpty (value )) {
872865 return FormValidation .warning ("Please select source image project..." );
873866 }
874867 return FormValidation .ok ();
@@ -878,7 +871,7 @@ public ListBoxModel doFillBootDiskSourceImageNameItems(
878871 @ AncestorInPath Jenkins context ,
879872 @ QueryParameter ("bootDiskSourceImageProject" ) final String projectId ,
880873 @ QueryParameter ("credentialsId" ) @ RelativePath (".." ) final String credentialsId ) {
881- checkPermissions ();
874+ checkPermissions (Jenkins . get (), Jenkins . ADMINISTER );
882875 ListBoxModel items = new ListBoxModel ();
883876 items .add ("" );
884877 try {
@@ -899,8 +892,7 @@ public ListBoxModel doFillBootDiskSourceImageNameItems(
899892 }
900893
901894 public FormValidation doCheckBootDiskSourceImageName (@ QueryParameter String value ) {
902- checkPermissions ();
903- if (value .equals ("" )) {
895+ if (StringUtils .isEmpty (value )) {
904896 return FormValidation .warning ("Please select source image..." );
905897 }
906898 return FormValidation .ok ();
@@ -912,7 +904,7 @@ public FormValidation doCheckBootDiskSizeGbStr(
912904 @ QueryParameter ("bootDiskSourceImageProject" ) final String projectId ,
913905 @ QueryParameter ("bootDiskSourceImageName" ) final String imageName ,
914906 @ QueryParameter ("credentialsId" ) @ RelativePath (".." ) final String credentialsId ) {
915- checkPermissions ();
907+ checkPermissions (Jenkins . get (), Jenkins . ADMINISTER );
916908 if (Strings .isNullOrEmpty (credentialsId )
917909 || Strings .isNullOrEmpty (projectId )
918910 || Strings .isNullOrEmpty (imageName )) return FormValidation .ok ();
@@ -936,7 +928,6 @@ public FormValidation doCheckBootDiskSizeGbStr(
936928
937929 public FormValidation doCheckLabelString (
938930 @ QueryParameter String value , @ QueryParameter Node .Mode mode ) {
939- checkPermissions ();
940931 if (mode == Node .Mode .EXCLUSIVE && (value == null || value .trim ().isEmpty ())) {
941932 return FormValidation .warning (
942933 "You may want to assign labels to this node;"
@@ -949,7 +940,6 @@ public FormValidation doCheckCreateSnapshot(
949940 @ AncestorInPath Jenkins context ,
950941 @ QueryParameter boolean value ,
951942 @ QueryParameter ("oneShot" ) boolean oneShot ) {
952- checkPermissions ();
953943 if (!oneShot && value ) {
954944 return FormValidation .error (Messages .InstanceConfiguration_SnapshotConfigError ());
955945 }
@@ -960,7 +950,6 @@ public FormValidation doCheckNumExecutorsStr(
960950 @ AncestorInPath Jenkins context ,
961951 @ QueryParameter String value ,
962952 @ QueryParameter ("oneShot" ) boolean oneShot ) {
963- checkPermissions ();
964953 int numExecutors = intOrDefault (value , DEFAULT_NUM_EXECUTORS );
965954 if (numExecutors < 1 ) {
966955 return FormValidation .error (
0 commit comments