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.api.jobs.DeleteJob; import com.archivas.clienttools.arcutils.profile.AbstractProfileBase; import com.archivas.clienttools.arcutils.model.*; import com.archivas.clienttools.arcutils.utils.net.SSLCertChain; import org.apache.http.impl.client.AbstractHttpClient; import javax.xml.stream.XMLStreamReader; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.util.Date; import java.util.Iterator; import java.util.logging.Level; import java.util.logging.Logger; /** * This class is a null sink, intended for testing purposes. All operations appear to succeed, but * no work will actually be done. * * <p/> * Some methods will sleep for a specified number of milliseconds before returning, simulating a * real-world response time. The default sleep time is 1 second. This can be overridden by setting * the system property: * <code>.archivas.clienttools.arcutils.impl.adapter.HCAPNullAdapter.sleepTimeMs</code> * */ public class HCAPNullAdapter implements StorageAdapter { public static Logger LOG = Logger.getLogger(HCAPNullAdapter.class.getName()); public static long sleepTimeMs = 1; static { try { sleepTimeMs = Long.parseLong(System.getProperty(HCAPNullAdapter.class.getName() + ".sleepTimeMs")); } catch (Exception e) { // do nothing } } public String getDebugName() { return "HCAPNullAdapter"; } public AbstractProfileBase getProfile() { return null; } public void setProfile(final AbstractProfileBase profile) { } public void abortASAP() { } public void mkdir(final String url, final FileMetadata metadata) { } public void mkSymlink(String symlinkName, String symlinkTarget) throws StorageAdapterException { throw new UnsupportedOperationException("mksymlink"); } public void delete(final String path, boolean isDirectory, DeleteJob.Operation operation, String reason) { } public InputStream getInputStream(final String url, String unused) throws StorageAdapterException { return new ByteArrayInputStream(new byte[0]); } public void writeStream(final String targetPath, final InputStream is) throws StorageAdapterException { writeObjectFromStream(targetPath, is, null); } public void writeObjectFromStream(final String targetPath, final InputStream is, final FileMetadata ingestionMetadata) throws StorageAdapterException { try { Thread.sleep(sleepTimeMs); } catch (InterruptedException e) { LOG.log(Level.WARNING, e.toString(), e); } } @Override public void setMetadata(final String path, final FileMetadata metadata) throws StorageAdapterException { throw new UnsupportedOperationException(); } public void rename(final String parentDirectoryURL, final String oldName, final String newName) throws StorageAdapterException { } public boolean exists(final String path) { return true; } public ArcMoverDirectory getDirectory(String path, final boolean forceGetAllMetadata) throws StorageAdapterException { String s = path; if (s.endsWith("/")) { s = s.substring(0, s.length() - 1); } int i = s.lastIndexOf("/"); if (i >= 0) { path = s.substring(0, i + 1); } ArcMoverDirectory dir = ArcMoverDirectory.getDirInstance(getProfile(), path, this); return dir; } public ArcMoverFile createArcMoverFileObject(XMLStreamReader xmlr, ArcMoverDirectory caller) throws StorageAdapterException { return null; } public Iterator<ArcMoverFile> getFileListIterator(ArcMoverDirectory caller, boolean includeDeleted, boolean supportsVersioning) throws StorageAdapterException { return null; } public ArcMoverDirectory getVersions(String path) throws StorageAdapterException { return null; } public long getFileSize(final ArcMoverFile f) throws StorageAdapterException { return 0; } public FileMetadata getMetadata(final String path, final String queryString, final FileType fileType, final boolean isVersion) throws StorageAdapterException { FileMetadata md = new FileMetadata(); md.setFileType(FileType.FILE); md.setModTime(new Date()); md.setSize(new Long(0)); md.setHidden(false); return md; } public String getCustomMetadata(final String path, final Long version, final FileType fileType) throws StorageAdapterException { return ""; } public void setCustomMetadata(final String file, String metadata) throws StorageAdapterException { return; } public void deleteCustomMetadata(final String path) throws StorageAdapterException { return; } public InputStream getCustomMetadataStream(final String path, final Long version, final FileType fileType) throws StorageAdapterException { return getCustomMetadataStream(path, version, fileType, null); } public InputStream getCustomMetadataStream(final String path, final Long version, final FileType fileType, final String annotation) throws StorageAdapterException { return null; } public void setCustomMetadataStream(final String file, InputStream metadata) throws StorageAdapterException { setCustomMetadataStream(file, metadata, null); } public void setCustomMetadataStream(final String file, InputStream metadata, String annotation) throws StorageAdapterException { return; } public InputStream getACLStream(final String path) throws StorageAdapterException { return null; } public void setACLFromStream(final String path, InputStream aclStream) throws StorageAdapterException { } public void cancel() { } public void close() { } public SSLCertChain getSSLCerts() throws IOException { return null; } public AbstractHttpClient getHttpClient() { return null; } public void updateHttpClient(LoadSchedule load) { } public int getMaxNumSimultaneousHttpConnections(final int maxConnectionsPerRoute) { return Integer.MAX_VALUE; } public boolean testConnection() { return true; } public boolean copyDirMetadataWhenMigrating() { return false; } @Override public boolean isVersioningEnabled() { return false; } }