001/*
002 * (C) Copyright 2012 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 *
016 * Contributors:
017 *     mguillaume
018 */
019
020package org.nuxeo.launcher.info;
021
022import javax.xml.bind.annotation.XmlAccessType;
023import javax.xml.bind.annotation.XmlAccessorType;
024import javax.xml.bind.annotation.XmlRootElement;
025import javax.xml.bind.annotation.XmlType;
026
027import org.nuxeo.connect.update.NuxeoValidationState;
028import org.nuxeo.connect.update.Package;
029import org.nuxeo.connect.update.PackageDependency;
030import org.nuxeo.connect.update.PackageState;
031import org.nuxeo.connect.update.PackageType;
032import org.nuxeo.connect.update.PackageVisibility;
033import org.nuxeo.connect.update.ProductionState;
034
035@XmlAccessorType(XmlAccessType.FIELD)
036@XmlRootElement(name = "package")
037@XmlType(propOrder = { "id", "state", "version", "name", "type", "visibility", "targetPlatforms", "vendor",
038        "supportsHotReload", "supported", "productionState", "validationState", "provides", "dependencies",
039        "conflicts", "title", "description", "homePage", "licenseType", "licenseUrl" })
040public class PackageInfo {
041
042    public String name;
043
044    public String version;
045
046    public String id;
047
048    public PackageState state;
049
050    public String title;
051
052    public String description;
053
054    public String homePage;
055
056    public String licenseType;
057
058    public String licenseUrl;
059
060    public ProductionState productionState;
061
062    public NuxeoValidationState validationState;
063
064    public String[] targetPlatforms;
065
066    public PackageType type;
067
068    public String vendor;
069
070    public PackageVisibility visibility;
071
072    public PackageDependency[] provides;
073
074    public PackageDependency[] dependencies;
075
076    public PackageDependency[] conflicts;
077
078    public boolean supportsHotReload;
079
080    public boolean supported;
081
082    public PackageInfo() {
083    }
084
085    /**
086     * @deprecated since 5.7
087     */
088    @Deprecated
089    public PackageInfo(String name, String version, String id, int state) {
090        this.name = name;
091        this.version = version;
092        this.id = id;
093        this.state = PackageState.getByValue(state);
094    }
095
096    /**
097     * @since 5.7
098     */
099    public PackageInfo(Package pkg) {
100        name = pkg.getName();
101        version = pkg.getVersion().toString();
102        id = pkg.getId();
103        state = pkg.getPackageState();
104        title = pkg.getTitle();
105        description = pkg.getDescription();
106        homePage = pkg.getHomePage();
107        licenseType = pkg.getLicenseType();
108        licenseUrl = pkg.getLicenseUrl();
109        productionState = pkg.getProductionState();
110        validationState = pkg.getValidationState();
111        targetPlatforms = pkg.getTargetPlatforms();
112        type = pkg.getType();
113        vendor = pkg.getVendor();
114        visibility = pkg.getVisibility();
115        if (visibility == null) {
116            visibility = PackageVisibility.UNKNOWN;
117        }
118        provides = pkg.getProvides();
119        dependencies = pkg.getDependencies();
120        conflicts = pkg.getConflicts();
121        supportsHotReload = pkg.supportsHotReload();
122        supported = pkg.isSupported();
123    }
124
125}