AvailablePlugin.java 5.04 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11
/**
 * $RCSfile$
 * $Revision: $
 * $Date: $
 *
 * Copyright (C) 2006 Jive Software. All rights reserved.
 *
 * This software is published under the terms of the GNU Public License (GPL),
 * a copy of which is included in this distribution.
 */

Gaston Dombiak's avatar
Gaston Dombiak committed
12 13 14
package org.jivesoftware.wildfire.update;

/**
15
 * Plugin available at jivesoftware.org. The plugin may or may not be locally installed.
Gaston Dombiak's avatar
Gaston Dombiak committed
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
 *
 * @author Gaston Dombiak
 */
public class AvailablePlugin {

    /**
     * Name of the plugin.
     */
    private String name;
    /**
     * Latest version of the plugin that was found.
     */
    private String latestVersion;
    /**
     * URL from where the latest version of the plugin can be downloaded.
     */
    private String url;
    /**
     * Icon's URL of the latest version of the plugin.
     */
    private String icon;
    /**
     * README URL of the latest version of the plugin.
     */
    private String readme;
    /**
     * Changelog URL of the latest version of the plugin.
     */
    private String changelog;
    /**
46
     * Type of license of the plugin.
Gaston Dombiak's avatar
Gaston Dombiak committed
47
     */
48
    private String licenseType;
Gaston Dombiak's avatar
Gaston Dombiak committed
49 50 51 52 53 54 55 56 57 58 59 60
    /**
     * Description of the plugin as specified in plugin.xml.
     */
    private String description;
    /**
     * Author of the plugin as specified in plugin.xml.
     */
    private String author;
    /**
     * Minimum server version required by this plugin as specified in plugin.xml.
     */
    private String minServerVersion;
61 62 63 64
    /**
     * Size in bytes of the plugin jar file.
     */
    private String fileSize;
Gaston Dombiak's avatar
Gaston Dombiak committed
65 66

    public AvailablePlugin(String name, String description, String latestVersion, String author,
67 68
            String icon, String changelog, String readme, String licenseType,
            String minServerVersion, String url, String fileSize) {
Gaston Dombiak's avatar
Gaston Dombiak committed
69 70 71 72
        this.author = author;
        this.icon = icon;
        this.changelog = changelog;
        this.readme = readme;
73
        this.licenseType = licenseType;
Gaston Dombiak's avatar
Gaston Dombiak committed
74 75 76 77 78
        this.description = description;
        this.latestVersion = latestVersion;
        this.minServerVersion = minServerVersion;
        this.name = name;
        this.url = url;
79
        this.fileSize = fileSize;
Gaston Dombiak's avatar
Gaston Dombiak committed
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150
    }

    /**
     * Returns the name of the plugin that is not installed.
     *
     * @return the name of the plugin that is not installed.
     */
    public String getName() {
        return name;
    }

    /**
     * Returns the latest version of the plugin that is not installed.
     *
     * @return the latest version of the plugin that is not installed.
     */
    public String getLatestVersion() {
        return latestVersion;
    }

    /**
     * Return the icon's URL of the latest version of the plugin.
     *
     * @return the icon's URL of the latest version of the plugin.
     */
    public String getIcon() {
        return icon;
    }

    /**
     * Returns the URL to the README file of the latest version of the plugin.
     *
     * @return the URL to the README file of the latest version of the plugin.
     */
    public String getReadme() {
        return readme;
    }

    /**
     * Returns the URL to the change log of the plugin.
     *
     * @return the URL to the change log of the plugin.
     */
    public String getChangelog() {
        return changelog;
    }

    /**
     * Returns the URL from where the plugin.
     *
     * @return the URL from where the plugin.
     */
    public String getURL() {
        return url;
    }

    /**
     * Returns the author of the plugin as specified in plugin.xml.
     *
     * @return author of the plugin as specified in plugin.xml.
     */
    public String getAuthor() {
        return author;
    }

    /**
     * Returns true if the plugin is commercial.
     *
     * @return true if the plugin is commercial.
     */
    public boolean isCommercial() {
151 152 153 154 155 156 157 158 159 160
        return "commercial".equals(licenseType);
    }

    /**
     * Returns the type of license the plugin is being released under.
     *
     * @return the type of license of the plugin.
     */
    public String getLicenseType() {
        return licenseType;
Gaston Dombiak's avatar
Gaston Dombiak committed
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179
    }

    /**
     * Returns the description of the plugin as specified in plugin.xml.
     *
     * @return description of the plugin as specified in plugin.xml.
     */
    public String getDescription() {
        return description;
    }

    /**
     * Returns the minimum server version required by this plugin as specified in plugin.xml.
     *
     * @return minimum server version required by this plugin as specified in plugin.xml.
     */
    public String getMinServerVersion() {
        return minServerVersion;
    }
180 181 182 183 184 185 186 187 188 189 190 191 192

    /**
     * Returns the size in bytes of the plugin jar file.
     *
     * @return the size in bytes of the plugin jar file.
     */
    public long getFileSize() {
        if (fileSize == null) {
            // Dummy value for old xml files that didn't contain this piece of information
            return -1L;
        }
        return Long.parseLong(fileSize);
    }
193 194 195 196 197 198 199 200

    /**
     * Returns the hash code for this object.
     * @return the hash code.
     */
    public int getHashCode(){
        return hashCode();
    }
Gaston Dombiak's avatar
Gaston Dombiak committed
201
}