Trying to get diffs URL in notifier email when a push is done in stash

Hello,

I am very new to Java development. I am writing a hook that sends out a email when a push is done in Stash. This email should have URL to diffs. I am using contentService.streamDirectory but I am not getting URL in the output. Please take a look at below code and help me on this.

public void explore(final Repository repository, String objectId, final StringBuilder sb){

String path= ""; //ToDO ContentTreeNode childNode != null ? node.getPath().toString() : "";

boolean recursive = true;

if (contentService.getType(repository, objectId, path) == ContentTreeNode.Type.DIRECTORY)

{

final List<ContentTreeNode> nodes = new ArrayList<ContentTreeNode>();

contentService.streamDirectory(repository, objectId, path, recursive, new AbstractContentTreeCallback(){

@Override

public boolean onTreeNode(ContentTreeNode node) throws IOException {

nodes.add(node);

String link = node.getPath().toString();

sb.append( link );

//Using below line I am trying to create a hyperlink.

sb.append( "<li><a href=\"" ).append( repository ).append(link).append( node.getPath() ).append( "\"diff" ).append( "\">")

.append(node.getPath()).append("</a></li>");

sb.append("\n");

return true;

}

}, new PageRequestImpl(0, PushEmailNotifier.MAX_PAGE_REQUEST));

}

}

I am using Atlassian SDK with stash 2.11 version. I really appreciate your help.

Thanks,

iihitp

1 answer

For getting the right URL, use the NavBuilder class instead of trying to construct it this way.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Jun 06, 2018 in Bitbucket

Do you use Bitbucket Cloud and Jira Cloud? If so, let us know!

Hi Community, I'm Julia and I'm on the Jira Software Cloud marketing team!  We're looking for companies or teams using Bitbucket Cloud and Jira Software Cloud. If your team fits the t...

174 views 6 3
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you