protected override PluginCommandResponseMessage ExecuteOperation(PackageCommandArg commandArg)
        {
            var config = _libraryRepositoryConfigStorage.GetConfigs().FirstOrDefault(c => c.Name == commandArg.RepositoryName);

            if (config == null)
            {
                return(new PluginCommandResponseMessage
                {
                    PluginCommandStatus = PluginCommandStatus.Error,
                    ResponseData = "Unknown repository {0}".Fmt(commandArg.RepositoryName)
                });
            }

            ILibraryRepository           repository = _libraryRepositoryFactory.GetRepository(config);
            Mashup                       mashup     = repository.GetPackageMashup(commandArg.PackageName);
            PluginProfileErrorCollection errors     = _mashupInfoRepository.Add(mashup, true);

            return(errors.Empty()
                                       ? new PluginCommandResponseMessage {
                PluginCommandStatus = PluginCommandStatus.Succeed
            }
                                       : new PluginCommandResponseMessage
            {
                PluginCommandStatus = PluginCommandStatus.Error,
                ResponseData = errors.Aggregate("", (acc, e) => acc + e.Message + "\r\n")
            });
        }
Example #2
0
        public Mashup GetMashup(AccountName account, string mashupName)
        {
            _log.Info(string.Format("Getting mashup with name '{0}'", mashupName));
            Mashup mashup = _mashupLoader.Load(GetMashupFolderPath(account, mashupName), mashupName);

            _log.Info(string.Format("Mashup with name '{0}' retrieved", mashupName));
            return(mashup);
        }
Example #3
0
        private void WritePlaceholdersFile(Mashup mashup, string mashupFolderPath)
        {
            if (!string.IsNullOrEmpty(mashup.Placeholders))
            {
                _log.Info(string.Format("Add placeholder config to mashup with name '{0}'", mashup.Name));

                var cfgPath = Path.Combine(mashupFolderPath, "placeholders.cfg");
                File.WriteAllText(cfgPath, string.Format("{0}{1}", MashupConfig.PlaceholderConfigPrefix, mashup.Placeholders));
            }
        }
Example #4
0
        private void WriteAccountsFile(Mashup mashup, string mashupFolderPath)
        {
            if (_accountName.Value != AccountName.Empty)
            {
                _log.Info(string.Format("Add account config to mashup with name '{0}'", mashup.Name));

                var cfgPath = Path.Combine(mashupFolderPath, Mashup.AccountCfgFileName);
                File.WriteAllText(cfgPath, string.Format("{0}{1}", MashupConfig.AccountsConfigPrefix, _accountName.Value));
            }
        }
Example #5
0
        public void SaveMashup(Mashup mashup)
        {
            _log.Info(string.Format("Saving mashup with name '{0}'", mashup.Name));
            var mashupFolderPath = GetMashupFolderPath(mashup.Name);

            EnsureMashupFolderExistsAndEmpty(mashupFolderPath);
            foreach (var file in mashup.Files)
            {
                EnsureMashupFileSubFolderExists(mashupFolderPath, file.FileName);
                File.WriteAllText(Path.Combine(mashupFolderPath, file.FileName), file.Content);
            }
            WritePlaceholdersFile(mashup, mashupFolderPath);
            WriteAccountsFile(mashup, mashupFolderPath);
            _log.Info(string.Format("Mashup with name '{0}' saved", mashup.Name));
        }
		public PluginProfileErrorCollection Add(Mashup dto, bool generateUniqueName)
		{
			if (generateUniqueName)
			{
				dto.Name = GetUniqueMashupName(dto.Name);
			}

			var errors = dto.ValidateAdd(ManagerProfile);
			if (errors.Any())
			{
				return errors;
			}

			AddMashupNameToPlugin(dto.Name);
			_scriptStorage.SaveMashup(dto);
			_bus.Send(dto.CreatePluginMashupMessage());
			_log.InfoFormat("Add mashup command sent to TP (Mashup '{0}' for account '{1}')", dto.Name, _context.AccountName.Value);
			return errors;
		}
		public Mashup Load(string mashupFolderPath, string mashupName)
		{
			if (!Directory.Exists(mashupFolderPath))
			{
				return null;
			}

			var configFiles = Directory.GetFiles(mashupFolderPath, "*.cfg");
			var mashupConfig = new MashupConfig(configFiles.SelectMany(File.ReadAllLines));
			var files = Directory.GetFiles(mashupFolderPath, "*", SearchOption.AllDirectories).Where(f => !configFiles.Contains(f));
			var mashupFiles = files.Select(f => new MashupFile
			{
				FileName = f.GetRelativePathTo(mashupFolderPath),
				Content = File.ReadAllText(f)
			}).ToList();

			var mashup = new Mashup(mashupFiles)
			{
				Name = mashupName,
				Placeholders = String.Join(",", mashupConfig.Placeholders)
			};

			return mashup;
		}
		public PluginProfileErrorCollection Delete(string name)
		{
			var errors = MashupScriptStorageOperations.Delete(_scriptStorage, name);
			if (errors.Any())
			{
				return errors;
			}
			DeleteMashupNameToPlugin(name);
			var dto = new Mashup {Name = name};
			_bus.Send(dto.CreatePluginMashupMessage());
			_log.InfoFormat("Clean mashup commnad sent to TP (Mashup '{0}' for account '{1}')", dto.Name, _context.AccountName.Value);
			return new PluginProfileErrorCollection();
		}