com.atlassian.studio.jira.servlet.filter
Class ContextPathToApplicationInstanceTranslator

java.lang.Object
  extended by com.atlassian.studio.jira.servlet.filter.ContextPathToApplicationInstanceTranslator
All Implemented Interfaces:
com.atlassian.applinks.core.ApplicationInstanceEventListener, org.springframework.beans.factory.DisposableBean

public class ContextPathToApplicationInstanceTranslator
extends Object
implements com.atlassian.applinks.core.ApplicationInstanceEventListener, org.springframework.beans.factory.DisposableBean

Given a URL or a relative path and JIRA's context path, this translator works out the remote primary applinked instances of CONFLUENCE, FECRU or BAMBOO, and returns the ApplicationInstance and the context path it uses. This works in both production environment as well as the development environment (localhost) as well Example: When being redirected to a destination after login, we need to establish if the destination belongs to a remote primary applinked application. In production, if the destination is "/wiki/dashboard.action", JIRA context path is "/", this will work out that the destination is actually a remote primary Confluence instance. In development environment, the destination is "/jira/wiki/dashboard.action", JIRA context path is "/jira", this will still work out that the destination is remote primary Confluence instance.


Constructor Summary
ContextPathToApplicationInstanceTranslator(com.atlassian.applinks.core.AppLinksManager appLinksManager)
           
 
Method Summary
 void destroy()
           
 com.google.common.base.Function<com.atlassian.applinks.core.ApplicationInstance,com.atlassian.applinks.core.Application> extractApplication()
           
 com.google.common.base.Function<? super com.atlassian.fugue.Pair<String,com.atlassian.applinks.core.ApplicationInstance>,com.atlassian.applinks.core.ApplicationInstance> extractApplicationInstance()
           
 com.atlassian.fugue.Option<com.atlassian.applinks.core.Application> findApplicationByUri(String location, String currentContextPath)
          Returns application type of the remote primary application instance that the given location belongs to.
 com.atlassian.fugue.Option<com.atlassian.applinks.core.ApplicationInstance> findApplicationInstanceByUri(String location, String currentContextPath)
          Returns the remote primary application instance that the given location belongs to.
 com.atlassian.fugue.Option<com.atlassian.fugue.Pair<String,com.atlassian.applinks.core.ApplicationInstance>> findByUri(String location, String currentContextPath)
          Returns the context path and the remote primary application instance that the given location belongs to.
 void instanceAdded(com.atlassian.applinks.core.ApplicationInstanceEvent event)
           
 void instanceMadePrimary(com.atlassian.applinks.core.ApplicationInstanceEvent event)
           
 void instanceRemoved(com.atlassian.applinks.core.ApplicationInstanceEvent event)
           
 void instanceUpdated(com.atlassian.applinks.core.ApplicationInstanceEvent event)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ContextPathToApplicationInstanceTranslator

public ContextPathToApplicationInstanceTranslator(com.atlassian.applinks.core.AppLinksManager appLinksManager)
Method Detail

findApplicationByUri

public com.atlassian.fugue.Option<com.atlassian.applinks.core.Application> findApplicationByUri(String location,
                                                                                                String currentContextPath)
Returns application type of the remote primary application instance that the given location belongs to.

Parameters:
location - the full URL, or a relative URI with or without the current context path
currentContextPath - the current context path if location is a relative URI with the current context path, or empty String if the location is a relative URI without the current context path. It doesn't matter if the location is a full URL.
Returns:
an option contains the application type of the remote primary application instance of Confluence, FishEye/Crucible or Bamboo if found, or Option.none() if not matched.

extractApplication

public com.google.common.base.Function<com.atlassian.applinks.core.ApplicationInstance,com.atlassian.applinks.core.Application> extractApplication()

findApplicationInstanceByUri

public com.atlassian.fugue.Option<com.atlassian.applinks.core.ApplicationInstance> findApplicationInstanceByUri(String location,
                                                                                                                String currentContextPath)
Returns the remote primary application instance that the given location belongs to.

Parameters:
location - the full URL, or a relative URI with or without the current context path
currentContextPath - the current context path if location is a relative URI with the current context path, or empty String if the location is a relative URI without the current context path. It doesn't matter if the location is a full URL.
Returns:
an option contains the remote primary application instance of Confluence, FishEye/Crucible or Bamboo if found, or Option.none() if not matched.

extractApplicationInstance

public com.google.common.base.Function<? super com.atlassian.fugue.Pair<String,com.atlassian.applinks.core.ApplicationInstance>,com.atlassian.applinks.core.ApplicationInstance> extractApplicationInstance()

findByUri

public com.atlassian.fugue.Option<com.atlassian.fugue.Pair<String,com.atlassian.applinks.core.ApplicationInstance>> findByUri(String location,
                                                                                                                              String currentContextPath)
Returns the context path and the remote primary application instance that the given location belongs to.

Parameters:
location - the full URL, or a relative URI with or without the current context path
currentContextPath - the current context path if location is a relative URI with the current context path, or empty String if the location is a relative URI without the current context path. It doesn't matter if the location is a full URL.
Returns:
an option contains the context path and the remote primary application instance of Confluence, FishEye/Crucible or Bamboo if found, or Option.none() if not matched.

instanceAdded

public void instanceAdded(com.atlassian.applinks.core.ApplicationInstanceEvent event)
Specified by:
instanceAdded in interface com.atlassian.applinks.core.ApplicationInstanceEventListener

instanceMadePrimary

public void instanceMadePrimary(com.atlassian.applinks.core.ApplicationInstanceEvent event)
Specified by:
instanceMadePrimary in interface com.atlassian.applinks.core.ApplicationInstanceEventListener

instanceRemoved

public void instanceRemoved(com.atlassian.applinks.core.ApplicationInstanceEvent event)
Specified by:
instanceRemoved in interface com.atlassian.applinks.core.ApplicationInstanceEventListener

instanceUpdated

public void instanceUpdated(com.atlassian.applinks.core.ApplicationInstanceEvent event)
Specified by:
instanceUpdated in interface com.atlassian.applinks.core.ApplicationInstanceEventListener

destroy

public void destroy()
             throws Exception
Specified by:
destroy in interface org.springframework.beans.factory.DisposableBean
Throws:
Exception


Copyright © 2002-2012 Atlassian. All Rights Reserved.