Source code: com/flexstor/common/services/remote/FlexRemoteService.java
1 /*
2 * FlexRemoteService.java
3 *
4 * Copyright $Date: 2003/08/11 02:22:50 $ FLEXSTOR.net Inc.
5 *
6 * This work is licensed for use and distribution under license terms found at
7 * http://www.flexstor.org/license.html
8 *
9 */
10
11 package com.flexstor.common.services.remote;
12
13 import java.rmi.RemoteException;
14 import java.rmi.server.UnicastRemoteObject;
15
16 import com.flexstor.common.util.Diagnostic;
17
18 public class FlexRemoteService
19 extends UnicastRemoteObject
20 {
21 public FlexRemoteService() throws RemoteException
22 {
23
24 }
25
26 /**
27 * Creates a 'hybrid' file path by combining two paths.
28 * @param sSourcePath The full path of the original file.
29 * @param sTargetBase The base path of the destination.
30 * @param sSourceBase The base path of the source file (the part which is eliminated)
31 * Example:
32 * sSourcePath = /images/hires/ibm/tower.tif
33 * sTargetBase = /images/thumbnail
34 * sSourceBase = /images/hires/
35 * The returned path is created by removing the sSourceBase from the sSourcePath, taking what is
36 * left of the sSourcePath and adding it to the sTargetBase. So the returned string from
37 * the above example is: /images/thumbnail/ibm/tower.tif
38 *
39 */
40 protected String getCompositeDir(String sSourcePath, String sTargetBase, String sSourceBase)
41 {
42 Diagnostic.trace(Diagnostic.APPSERVER_IMPORT, "getCompositeDir: " + sSourcePath + ", " + sTargetBase + ", " + sSourceBase);
43 String sOutputPath = sTargetBase;
44 String fileSeparator = System.getProperty("file.separator");
45 // Find the base path in the user specified input file path
46 if (sSourceBase.length() < sSourcePath.length())
47 {
48 int nBaseDir = sSourcePath.indexOf(sSourceBase);
49 if (nBaseDir != -1)
50 sOutputPath += fileSeparator + sSourcePath.substring(nBaseDir + sSourceBase.length() + 1);
51 }
52 Diagnostic.trace(Diagnostic.APPSERVER_IMPORT, "The output path from getCompositeDir is: " + sOutputPath);
53 return sOutputPath;
54 } // buildCompositeDir
55
56 }