Ignore:
Timestamp:
2017-03-09T22:49:28+01:00 (3 years ago)
Author:
bastiK
Message:

fixed #12731 - Add an option to completely prevent upload of a layer : e.g. "never" to upload=true/false

to set this option, add XML attribute upload='never' to .osm file

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/osm/DataSet.java

    r11632 r11709  
    100100
    101101    /**
     102     * Upload policy.
     103     *
     104     * Determines if upload to the OSM server is intended, discouraged, or
     105     * disabled / blocked.
     106     */
     107    public enum UploadPolicy {
     108        /**
     109         * Normal dataset, upload intended.
     110         */
     111        NORMAL("true"),
     112        /**
     113         * Upload discouraged, for example when using or distributing a private dataset.
     114         */
     115        DISCOURAGED("false"),
     116        /**
     117         * Upload blocked.
     118         * Upload options completely disabled. Intended for special cases
     119         * where a warning dialog is not enough, see #12731.
     120         *
     121         * For the user, it shouldn't be too easy to disable this flag.
     122         */
     123        BLOCKED("never");
     124
     125        String xml_flag;
     126
     127        private UploadPolicy(String xml_flag) {
     128            this.xml_flag = xml_flag;
     129        }
     130
     131        /**
     132         * Get the corresponding value of the <code>upload='...'</code> XML-attribute
     133         * in the .osm file.
     134         * @return value of the <code>upload</code> attribute
     135         */
     136        public String getXmlFlag() {
     137            return xml_flag;
     138        }
     139    };
     140
     141    /**
    102142     * Maximum number of events that can be fired between beginUpdate/endUpdate to be send as single events (ie without DatasetChangedEvent)
    103143     */
     
    124164    private int highlightUpdateCount;
    125165
    126     private boolean uploadDiscouraged;
     166    private UploadPolicy uploadPolicy;
    127167
    128168    private final ReadWriteLock lock = new ReentrantReadWriteLock();
     
    300340
    301341    /**
    302      * Determines if upload is being discouraged (i.e. this dataset contains private data which should not be uploaded)
     342     * Determines if upload is being discouraged.
     343     * (i.e. this dataset contains private data which should not be uploaded)
    303344     * @return {@code true} if upload is being discouraged, {@code false} otherwise
    304345     * @see #setUploadDiscouraged
    305      */
     346     * @deprecated use {@link #getUploadPolicy()}
     347     */
     348    @Deprecated
    306349    public boolean isUploadDiscouraged() {
    307         return uploadDiscouraged;
     350        return uploadPolicy == UploadPolicy.DISCOURAGED || uploadPolicy == UploadPolicy.BLOCKED;
    308351    }
    309352
     
    312355     * @param uploadDiscouraged {@code true} if this dataset contains private data which should not be uploaded
    313356     * @see #isUploadDiscouraged
    314      */
     357     * @deprecated use {@link #setUploadPolicy(UploadPolicy)}
     358     */
     359    @Deprecated
    315360    public void setUploadDiscouraged(boolean uploadDiscouraged) {
    316         this.uploadDiscouraged = uploadDiscouraged;
     361        if (uploadPolicy != UploadPolicy.BLOCKED) {
     362            this.uploadPolicy = uploadDiscouraged ? UploadPolicy.DISCOURAGED : UploadPolicy.NORMAL;
     363        }
     364    }
     365
     366    /**
     367     * Get the upload policy.
     368     * @return the upload policy
     369     * @see #setUploadPolicy(UploadPolicy)
     370     */
     371    public UploadPolicy getUploadPolicy() {
     372        return this.uploadPolicy;
     373    }
     374
     375    /**
     376     * Sets the upload policy.
     377     * @param uploadPolicy the upload policy
     378     * @see #getUploadPolicy()
     379     */
     380    public void setUploadPolicy(UploadPolicy uploadPolicy) {
     381        this.uploadPolicy = uploadPolicy;
    317382    }
    318383
Note: See TracChangeset for help on using the changeset viewer.