Java tutorial
// Copyright 2007 Hitachi Data Systems // All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); you may // not use this file except in compliance with the License. You may obtain // a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the // License for the specific language governing permissions and limitations // under the License. package com.archivas.clienttools.arcutils.impl.adapter; import com.archivas.clienttools.arcutils.profile.*; import org.apache.http.impl.client.AbstractHttpClient; import java.util.logging.Level; import java.util.logging.Logger; public class DefaultStorageAdapterFactory implements StorageAdapterFactory { private static Logger LOG = Logger.getLogger(DefaultStorageAdapterFactory.class.getName()); /** * Instance method to return the <code>StorageAdapter</code> appropriate for accessing the * object referenced by <code>url</code>. * * @param profile * - * @param httpClient * - HCAPMoverProfile referencing the object for which a <code>StorageAdapter</code> * will be returned. * * @return A <code>StorageAdapter</code> appropriate for accessing the the object referenced by * <code>url</code>. */ public StorageAdapter getStorageAdapterInstance(AbstractProfileBase profile, AbstractHttpClient httpClient) { StorageAdapter adapter = null; if (profile == null) { return null; } try { switch (profile.getType()) { case HCAP2: adapter = new Hcap2Adapter((Hcap2Profile) profile, profile.getSSLExceptionCallback(), httpClient); break; case HCP_DEFAULT: adapter = new Hcp3DefaultNamespaceAdapter((Hcp3DefaultNamespaceProfile) profile, profile.getSSLExceptionCallback(), httpClient); break; case HCP: adapter = new Hcp3AuthNamespaceAdapter((Hcp3AuthNamespaceProfile) profile, profile.getSSLExceptionCallback(), httpClient); break; case HCP50: adapter = new Hcp5AuthNamespaceAdapter((Hcp5AuthNamespaceProfile) profile, profile.getSSLExceptionCallback(), httpClient); break; case HCP60: adapter = new Hcp6AuthNamespaceAdapter((Hcp6AuthNamespaceProfile) profile, profile.getSSLExceptionCallback(), httpClient); break; case FILESYSTEM: adapter = new FileSystemAdapter(); break; default: adapter = null; break; } } catch (StorageAdapterException e) { LOG.log(Level.WARNING, "StorageAdapterException creating adapter", e); } if (adapter == null) { String msg = "No StorageAdapter is available for profile: " + profile.getName(); throw new RuntimeException(msg); } return adapter; } }