コード例 #1
0
 /** Method checks file selected by user is valid and call method which extracts data from it. */
 public static void handleFile(String fileName, Project project) {
   if (fileName != null && !fileName.isEmpty()) {
     File file = new File(fileName);
     PublishData publishDataToCache = handlePublishSettings(file, project);
     if (publishDataToCache == null) {
       return;
     }
     WizardCacheManager.setCurrentPublishData(publishDataToCache);
     // Make centralized storage registry.
     prepareListFromPublishData(project);
   }
 }
コード例 #2
0
 /** Method prepares storage account list. Adds data from publish settings file. */
 public static void prepareListFromPublishData(Project project) {
   List<StorageAccount> strgList = StorageAccountRegistry.getStrgList();
   Collection<PublishData> publishDatas = WizardCacheManager.getPublishDatas();
   for (PublishData pd : publishDatas) {
     for (Subscription sub : pd.getPublishProfile().getSubscriptions()) {
       /*
        * Get collection of storage services in each subscription.
        */
       StorageServices services = pd.getStoragesPerSubscription().get(sub.getId());
       // iterate over collection of services.
       for (StorageService strgService : services) {
         StorageAccount strEle =
             new StorageAccount(
                 strgService.getServiceName(),
                 strgService.getPrimaryKey(),
                 strgService.getStorageAccountProperties().getEndpoints().get(0).toString());
         /*
          * Check if storage account is already present
          * in centralized repository,
          * if present then do not add.
          * if not present then check
          * access key is valid or not.
          * If not then update with correct one in registry.
          */
         if (strgList.contains(strEle)) {
           int index = strgList.indexOf(strEle);
           StorageAccount account = strgList.get(index);
           String newKey = strEle.getStrgKey();
           if (!account.getStrgKey().equals(newKey)) {
             account.setStrgKey(newKey);
           }
         } else {
           strgList.add(strEle);
         }
       }
     }
   }
   AzureSettings.getSafeInstance(project).saveStorage();
 }