AvailablePlugin.java 5.46 KB
Newer Older
1 2 3 4 5
/**
 * $RCSfile$
 * $Revision: $
 * $Date: $
 *
6
 * Copyright (C) 2005-2008 Jive Software. All rights reserved.
7
 *
8 9 10 11 12 13 14 15 16 17 18
 * 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.
19 20
 */

21
package org.jivesoftware.openfire.update;
Gaston Dombiak's avatar
Gaston Dombiak committed
22 23

/**
24
 * Plugin available at igniterealtime.org. The plugin may or may not be locally installed.
Gaston Dombiak's avatar
Gaston Dombiak committed
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
 *
 * @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;
    /**
55
     * Type of license of the plugin.
Gaston Dombiak's avatar
Gaston Dombiak committed
56
     */
57
    private String licenseType;
Gaston Dombiak's avatar
Gaston Dombiak committed
58 59 60 61 62 63 64 65 66 67 68 69
    /**
     * 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;
70 71 72 73
    /**
     * Size in bytes of the plugin jar file.
     */
    private String fileSize;
Gaston Dombiak's avatar
Gaston Dombiak committed
74 75

    public AvailablePlugin(String name, String description, String latestVersion, String author,
76 77
            String icon, String changelog, String readme, String licenseType,
            String minServerVersion, String url, String fileSize) {
Gaston Dombiak's avatar
Gaston Dombiak committed
78 79 80 81
        this.author = author;
        this.icon = icon;
        this.changelog = changelog;
        this.readme = readme;
82
        this.licenseType = licenseType;
Gaston Dombiak's avatar
Gaston Dombiak committed
83 84 85 86 87
        this.description = description;
        this.latestVersion = latestVersion;
        this.minServerVersion = minServerVersion;
        this.name = name;
        this.url = url;
88
        this.fileSize = fileSize;
Gaston Dombiak's avatar
Gaston Dombiak committed
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 151 152 153 154 155 156 157 158 159
    }

    /**
     * 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() {
160 161 162 163 164 165 166 167 168 169
        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
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188
    }

    /**
     * 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;
    }
189 190 191 192 193 194 195 196 197 198 199 200 201

    /**
     * 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);
    }
202 203 204 205 206 207 208 209

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