001/*
002 * (C) Copyright 2014 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 *     Anahide Tchertchian
018 */
019package org.nuxeo.targetplatforms.api.service;
020
021import java.util.List;
022
023import org.nuxeo.targetplatforms.api.TargetPackage;
024import org.nuxeo.targetplatforms.api.TargetPackageInfo;
025import org.nuxeo.targetplatforms.api.TargetPlatform;
026import org.nuxeo.targetplatforms.api.TargetPlatformFilter;
027import org.nuxeo.targetplatforms.api.TargetPlatformInfo;
028import org.nuxeo.targetplatforms.api.TargetPlatformInstance;
029
030/**
031 * Service for target platforms and packages management.
032 *
033 * @since 5.7.1
034 */
035public interface TargetPlatformService {
036
037    /**
038     * Returns the override directory name.
039     */
040    String getOverrideDirectory();
041
042    /**
043     * Returns the default target platform.
044     * <p>
045     * If several target platforms are found for given filter, the first one is returned (ordered alphabetically on id).
046     */
047    TargetPlatform getDefaultTargetPlatform(TargetPlatformFilter filter);
048
049    /**
050     * Returns the target platform with given id, or null if not found.
051     */
052    TargetPlatform getTargetPlatform(String id);
053
054    /**
055     * Returns the target platform info for given id, or null if not found.
056     */
057    TargetPlatformInfo getTargetPlatformInfo(String id);
058
059    /**
060     * Returns the target package with given id, or null if not found.
061     */
062    TargetPackage getTargetPackage(String id);
063
064    /**
065     * Returns the target package info for given id, or null if not found.
066     */
067    TargetPackageInfo getTargetPackageInfo(String id);
068
069    /**
070     * Returns a target platform instance with given id and given enabled packages, or null if not found.
071     * <p>
072     * Ignore target packages that would not be found.
073     */
074    TargetPlatformInstance getTargetPlatformInstance(String id, List<String> packages);
075
076    /**
077     * Returns all target platforms matching given criteria.
078     *
079     * @param filter the filter to apply, can be null if no filtering is needed.
080     * @see TargetPlatformFilter
081     */
082    List<TargetPlatform> getAvailableTargetPlatforms(TargetPlatformFilter filter);
083
084    /**
085     * Returns all target platforms info matching given criteria.
086     *
087     * @param filter the filter to apply, can be null if no filtering is needed.
088     * @see TargetPlatformFilter
089     */
090    List<TargetPlatformInfo> getAvailableTargetPlatformsInfo(TargetPlatformFilter filter);
091
092    /**
093     * Deprecates the target platform if given boolean is true (or un-deprecates it if boolean is false), overriding the
094     * default value from extension points and adding an entry in the override directory.
095     */
096    void deprecateTargetPlatform(boolean deprecate, String id);
097
098    /**
099     * Enables the target platform if given boolean is true (or disables it boolean is false), overriding the default
100     * value from extension points and adding an entry in the override directory.
101     */
102    void enableTargetPlatform(boolean enable, String id);
103
104    /**
105     * Restricts the target platform if given boolean is true (or un-restricts it if boolean is false), overriding the
106     * default value from extension points and adding an entry in the override directory.
107     */
108    void restrictTargetPlatform(boolean restrict, String id);
109
110    /**
111     * Set the target platform as trial if given boolean is true (or unset it as trial if boolean is false), overriding
112     * the default value from extension points and adding an entry in the override directory.
113     */
114    void setTrialTargetPlatform(boolean trial, String id);
115
116    /**
117     * Set the target platform as default if given boolean is true (or unset it as default if boolean is false),
118     * overriding the default value from extension points and adding an entry in the override directory.
119     */
120    void setDefaultTargetPlatform(boolean isDefault, String id);
121
122    /**
123     * Removes overrides for this target platform.
124     */
125    void restoreTargetPlatform(String id);
126
127    /**
128     * Removes overrides for all target platform.
129     */
130    void restoreAllTargetPlatforms();
131
132    /**
133     * @return the default target platform instance and enabled if not found.
134     * @since 5.9.3-NXP-15602
135     */
136    TargetPlatformInstance getDefaultTargetPlatformInstance(boolean restricted);
137
138}