001/* 002 * (C) Copyright 2017 Nuxeo (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 * Mariana Cedica 018 */ 019package org.nuxeo.ecm.core.storage.status; 020 021import java.util.Map; 022 023import org.nuxeo.ecm.core.blob.BlobManager; 024import org.nuxeo.ecm.core.blob.BlobProvider; 025import org.nuxeo.ecm.core.blob.binary.BinaryManager; 026import org.nuxeo.ecm.core.management.api.Probe; 027import org.nuxeo.ecm.core.management.api.ProbeStatus; 028import org.nuxeo.ecm.core.storage.sql.S3BinaryManager; 029import org.nuxeo.runtime.api.Framework; 030 031/** 032 * Probe to check the status of the S3BinaryManager. Returns success if Nuxeo can access the bucket, failure otherwise 033 * 034 * @since 9.3 035 */ 036public class S3BinaryManagerStatusProbe implements Probe { 037 038 @Override 039 public ProbeStatus run() { 040 041 Map<String, BlobProvider> providers = Framework.getService(BlobManager.class).getBlobProviders(); 042 for (BlobProvider blobProvider : providers.values()) { 043 BinaryManager bm = blobProvider.getBinaryManager(); 044 if (bm != null && bm instanceof S3BinaryManager && ((S3BinaryManager) bm).canAccessBucket()) { 045 return ProbeStatus.newSuccess("S3BinaryManager can access the configured bucket"); 046 } 047 } 048 return ProbeStatus.newFailure("S3BinaryManager cannot access the configured bucket"); 049 050 } 051}