001/*
002 * (C) Copyright 2012 Nuxeo SA (http://nuxeo.com/) and contributors.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the GNU Lesser General Public License
006 * (LGPL) version 2.1 which accompanies this distribution, and is available at
007 * http://www.gnu.org/licenses/lgpl.html
008 *
009 * This library is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012 * Lesser General Public License for more details.
013 *
014 * Contributors:
015 *     mguillaume
016 */
017
018package org.nuxeo.launcher.info;
019
020import javax.xml.bind.annotation.XmlAccessType;
021import javax.xml.bind.annotation.XmlAccessorType;
022import javax.xml.bind.annotation.XmlRootElement;
023import javax.xml.bind.annotation.XmlType;
024
025import org.nuxeo.connect.update.NuxeoValidationState;
026import org.nuxeo.connect.update.Package;
027import org.nuxeo.connect.update.PackageDependency;
028import org.nuxeo.connect.update.PackageState;
029import org.nuxeo.connect.update.PackageType;
030import org.nuxeo.connect.update.PackageVisibility;
031import org.nuxeo.connect.update.ProductionState;
032
033@XmlAccessorType(XmlAccessType.FIELD)
034@XmlRootElement(name = "package")
035@XmlType(propOrder = { "id", "state", "version", "name", "type", "visibility", "targetPlatforms", "vendor",
036        "supportsHotReload", "supported", "productionState", "validationState", "provides", "dependencies",
037        "conflicts", "title", "description", "homePage", "licenseType", "licenseUrl" })
038public class PackageInfo {
039
040    public String name;
041
042    public String version;
043
044    public String id;
045
046    public PackageState state;
047
048    public String title;
049
050    public String description;
051
052    public String homePage;
053
054    public String licenseType;
055
056    public String licenseUrl;
057
058    public ProductionState productionState;
059
060    public NuxeoValidationState validationState;
061
062    public String[] targetPlatforms;
063
064    public PackageType type;
065
066    public String vendor;
067
068    public PackageVisibility visibility;
069
070    public PackageDependency[] provides;
071
072    public PackageDependency[] dependencies;
073
074    public PackageDependency[] conflicts;
075
076    public boolean supportsHotReload;
077
078    public boolean supported;
079
080    public PackageInfo() {
081    }
082
083    /**
084     * @deprecated since 5.7
085     */
086    @Deprecated
087    public PackageInfo(String name, String version, String id, int state) {
088        this.name = name;
089        this.version = version;
090        this.id = id;
091        this.state = PackageState.getByValue(state);
092    }
093
094    /**
095     * @since 5.7
096     */
097    public PackageInfo(Package pkg) {
098        name = pkg.getName();
099        version = pkg.getVersion().toString();
100        id = pkg.getId();
101        state = pkg.getPackageState();
102        title = pkg.getTitle();
103        description = pkg.getDescription();
104        homePage = pkg.getHomePage();
105        licenseType = pkg.getLicenseType();
106        licenseUrl = pkg.getLicenseUrl();
107        productionState = pkg.getProductionState();
108        validationState = pkg.getValidationState();
109        targetPlatforms = pkg.getTargetPlatforms();
110        type = pkg.getType();
111        vendor = pkg.getVendor();
112        visibility = pkg.getVisibility();
113        if (visibility == null) {
114            visibility = PackageVisibility.UNKNOWN;
115        }
116        provides = pkg.getProvides();
117        dependencies = pkg.getDependencies();
118        conflicts = pkg.getConflicts();
119        supportsHotReload = pkg.supportsHotReload();
120        supported = pkg.isSupported();
121    }
122
123}