001/* 002 * (C) Copyright 2015 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 * Florent Guillaume 018 */ 019package org.nuxeo.ecm.core.blob; 020 021import static org.nuxeo.ecm.core.blob.BlobProviderDescriptor.PREVENT_USER_UPDATE; 022 023import java.io.IOException; 024import java.util.Map; 025 026/** 027 * Abstract implementation for {@link BlobProvider} providing common logic. 028 * 029 * @since 7.10 030 */ 031public abstract class AbstractBlobProvider implements BlobProvider { 032 033 public String blobProviderId; 034 035 public Map<String, String> properties; 036 037 @Override 038 public void initialize(String blobProviderId, Map<String, String> properties) throws IOException { 039 this.blobProviderId = blobProviderId; 040 this.properties = properties; 041 } 042 043 protected boolean supportsUserUpdateDefaultTrue() { 044 return !Boolean.parseBoolean(properties.get(PREVENT_USER_UPDATE)); 045 } 046 047 protected boolean supportsUserUpdateDefaultFalse() { 048 return !Boolean.parseBoolean(properties.getOrDefault(PREVENT_USER_UPDATE, "true")); 049 } 050 051 @Override 052 public boolean supportsUserUpdate() { 053 return supportsUserUpdateDefaultTrue(); 054 } 055 056}