/src/main/java/org/swift/jira/cli/JiraPluginHelper.java
Java | 96 lines | 28 code | 11 blank | 57 comment | 7 complexity | ecfe217fda3bb1cbc33ce89644d895db MD5 | raw file
Possible License(s): Apache-2.0, BSD-3-Clause
- /*
- * Copyright (c) 2009 Bob Swift.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * The names of contributors may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
- /*
- * Created on: Sep 16, 2009
- * Author: Bob Swift
- */
- package org.swift.jira.cli;
- import java.io.PrintStream;
- import org.swift.common.cli.AbstractPluginHelper;
- import org.swift.common.cli.AbstractRestClient;
- public class JiraPluginHelper extends AbstractPluginHelper {
- protected PrintStream out = System.out;
- public JiraPluginHelper(AbstractRestClient client) {
- super(client);
- }
- /**
- * Handle change between versions on location of plugins action at version 3
- *
- * @return request string for plugin actions
- */
- @Override
- public String getPluginRequestString() {
- return "/secure/admin/jira/ViewPlugins!default.jspa";
- }
- /**
- * Regex values for finding application specific data for plugin information
- *
- * <pre>
- * Example - plugin
- * <a href="viewplugins.action?pluginKey=com.atlassian.confluence.plugins.attachmentExtractors" >Attachment Extractors</a><br>
- * Example - plugin version
- * <strong>Plugin Version</strong>: 1.5<br>
- * Example - plugin version
- * <b>Vendor</b>: <a href="http://www.adaptavist.com/">Adaptavist.com Ltd</a><br>
- * Example - latest version
- * Latest Version: </dt> <dd>3.1.0</dd> <th> <a href="/plugin/details/152?versionId=1044">3.1.0</a> </th>
- * Example - download url for version
- * <dt><a href="/plugin/details/152?versionId=1043">3.0.2</a></dt>
- *
- * </pre>
- *
- * @param key
- * @return regex string appropriate for the key specified
- */
- @Override
- public String getPluginRegex(final String key) {
- String result = "";
- if (key.equals("plugin")) {
- result = "ViewPlugins.jspa\\?pluginKey=([^\"]*)\"[^>]*>([^<]*)<"; // <a href="ViewPlugins.jspa?pluginKey=jira.user.format" >User Format</a><br>
- } else if (key.equals("plugin-version")) {
- result = "Plugin Version[^:]*:[^>]*>\\s*([^<]*)<"; // <b>Plugin Version:</b> 1.0<br>
- } else if (key.equals("plugin-vendor")) {
- result = "Vendor[^>]*>[^>]*>\\s*([^<]*)<"; // <b>Vendor:</b> <a href="http://www.atlassian.com">Atlassian Pty Ltd<br></a>
- } else if (key.equals("plugin-enabled")) { // Doesn't really apply to JIRA
- result = ">\\s*This plugin is (disabled).\\s*[^<]*<";
- }
- // out.println("Regex: " + result);
- return result;
- }
- }