/*
 * Copyright 2000-2017 JetBrains s.r.o.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package jetbrains.buildServer.nuget.server.trigger;

import jetbrains.buildServer.RootUrlHolder;
import jetbrains.buildServer.nuget.server.TriggerUrlPostProcessor;
import jetbrains.buildServer.parameters.ReferencesResolverUtil;
import jetbrains.buildServer.serverSide.SBuildType;
import org.jetbrains.annotations.NotNull;

import static jetbrains.buildServer.agent.AgentRuntimeProperties.TEAMCITY_SERVER_URL;

/**
 * Created 26.06.13 19:02
 *
 * @author Eugene Petrenko (eugene.petrenko@jetbrains.com)
 */
public class TriggerUrlRootPostProcessor implements TriggerUrlPostProcessor {
  private final RootUrlHolder myHolder;

  public TriggerUrlRootPostProcessor(@NotNull RootUrlHolder holder) {
    myHolder = holder;
  }

  @NotNull
  public String updateTriggerUrl(@NotNull SBuildType buildType, @NotNull String source) {
    if (!ReferencesResolverUtil.mayContainReference(source)) return source;
    return source.replace(ReferencesResolverUtil.makeReference(TEAMCITY_SERVER_URL), myHolder.getRootUrl());
  }
}

@@ -875,16 +875,143 @@
 ldType;%0A
+import jetbrains.buildServer.util.positioning.PositionAware;%0Aimport jetbrains.buildServer.util.positioning.PositionConstraint;%0A
 import o
@@ -1044,16 +1044,16 @@
 otNull;%0A
-
 %0Aimport 
@@ -1303,16 +1303,31 @@
 rocessor
+, PositionAware
  %7B%0A  pri
@@ -1637,16 +1637,16 @@
 source;%0A
-
     retu
@@ -1749,11 +1749,238 @@
 ());%0A  %7D
+%0A%0A  @NotNull%0A  @Override%0A  public String getOrderId() %7B%0A    return TriggerUrlRootPostProcessor.class.getName();%0A  %7D%0A%0A  @NotNull%0A  @Override%0A  public PositionConstraint getConstraint() %7B%0A    return PositionConstraint.last();%0A  %7D
 %0A%7D%0A

Fix problem with TeamCity nuget feed reference resolution in trigger