Source Code Cross Referenced for CommandCentral.java in  » Source-Control » sourcejammer » org » sourcejammer » client » gui » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Source Control » sourcejammer » org.sourcejammer.client.gui 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /*
0002:         *  Copyright (C) 2001-2003 Robert MacGrogan
0003:         *
0004:         *  This library is free software; you can redistribute it and/or
0005:         *  modify it under the terms of the GNU Lesser General Public
0006:         *  License as published by the Free Software Foundation; either
0007:         *  version 2.1 of the License, or (at your option) any later version.
0008:         *
0009:         *  This library is distributed in the hope that it will be useful,
0010:         *  but WITHOUT ANY WARRANTY; without even the implied warranty of
0011:         *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
0012:         *  Lesser General Public License for more details.
0013:         *
0014:         *  You should have received a copy of the GNU Lesser General Public
0015:         *  License along with this library; if not, write to the Free Software
0016:         *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
0017:         *
0018:         *
0019:         * $Archive: SourceJammer$
0020:         * $FileName: CommandCentral.java$
0021:         * $FileID: 3981$
0022:         *
0023:         * Last change:
0024:         * $AuthorName: Rob MacGrogan$
0025:         * $Date: 9/15/03 12:04 PM$
0026:         * $Comment: On check in, check if there's a new file id. This means
0027:         *          file branched on check in. Use new file ID to download latest
0028:         *          version, if required.$
0029:         */
0030:
0031:        package org.sourcejammer.client.gui;
0032:
0033:        import org.sourcejammer.project.view.*;
0034:        import org.sourcejammer.project.view.ArchiveProperties;
0035:        import javax.swing.JOptionPane;
0036:        import javax.swing.*;
0037:        import javax.swing.table.TableColumnModel;
0038:        import javax.swing.table.TableColumn;
0039:        import org.sourcejammer.util.ConfigurationException;
0040:        import org.sourcejammer.util.FileUtil;
0041:        import org.sourcejammer.util.ProcessTimer;
0042:        import org.sourcejammer.util.RepeatingResponse;
0043:        import org.sourcejammer.util.SourceJammerConnectionException;
0044:        import org.apache.xpath.operations.Mult;
0045:        import org.sourcejammer.client.SOAPPortal;
0046:        import org.sourcejammer.project.NodeExistsException;
0047:        import org.sourcejammer.project.NodeList;
0048:        import java.net.MalformedURLException;
0049:        import java.util.ArrayList;
0050:        import java.io.*;
0051:        import org.sourcejammer.util.AppConfig;
0052:        import org.sourcejammer.client.gui.conf.FileNodeInfo;
0053:        import org.sourcejammer.client.gui.conf.GuiConf;
0054:        import org.sourcejammer.client.gui.conf.UserPrefs;
0055:        import org.sourcejammer.client.SourceJammerClient;
0056:        import javax.swing.table.TableModel;
0057:        import javax.swing.tree.TreePath;
0058:        import org.sourcejammer.util.StringUtil;
0059:        import org.sourcejammer.client.filesys.FileSysUtil;
0060:        import org.sourcejammer.project.Node;
0061:        import org.sourcejammer.project.controller.LabelVersionMappingBean;
0062:        import org.sourcejammer.project.NodeDoesNotExistException;
0063:        import org.sourcejammer.util.ZipUtil;
0064:        import org.sourcejammer.util.BadMethodArgumentException;
0065:        import org.sourcejammer.client.filesys.SourceVersionChecker;
0066:        import org.sourcejammer.client.gui.logger.MessageDisplayStream;
0067:        import org.sourcejammer.client.gui.process.ProcessCentral;
0068:        import org.sourcejammer.client.plugin.EventTimingType;
0069:        import org.sourcejammer.util.TempDirectoryManager;
0070:        import org.sourcejammer.client.FileTransport;
0071:        import org.sourcejammer.project.view.DownloadFileIdentifier;
0072:        import org.sourcejammer.client.gui.action.ActionCentral;
0073:        import org.sourcejammer.client.NoSessionException;
0074:        import org.sourcejammer.client.DisplayTextLibrary;
0075:
0076:        /**
0077:         * Title:        $FileName: CommandCentral.java$
0078:         * @version $VerNum: 34$
0079:         * @author $AuthorName: Rob MacGrogan$<br><br>
0080:         * 
0081:         * $Description: Central singleton that handles issuing all
0082:         *              commands and performing all file system actions for GUI.$<br>
0083:         * $KeyWordsOff: $<br><br>
0084:         * 
0085:         * Central singleton that handles issuing all commands and performing all
0086:         * file system actions for GUI.
0087:         */
0088:        public class CommandCentral implements  SJRequestParams,
0089:                SJResponseParams {
0090:
0091:            public static final String APP_TITLE = "SourceJammer!";
0092:
0093:            private static CommandCentral instance = new CommandCentral();
0094:            private static final String SJ_FILE_NAME_ENV_VAR = "sourcejammer_file_name";
0095:            private static final int ZIP_BUFFER_SIZE = 50;
0096:
0097:            private String msUserName;
0098:            private String msPassword;
0099:            private String msArchiveName = null;
0100:            private long mlSessionID = -1;
0101:            private SJPrimaryWindow mjRootAppFrame = null;
0102:            private SOAPPortal moPortal = null;
0103:            private String msURL = null;
0104:            private static TableColumnModel moPrimaryColumnModel = null;
0105:            private ProjectTreeNode moCurrentTreeNode = null;
0106:            private boolean mbAppWindowRendered = false;
0107:            private GuiConf moConf = null;
0108:            public static PrintStream out = null;
0109:            private SourceVersionChecker currentProjectVerChecker = null;
0110:            private String proxyPassword = null;
0111:            private boolean proxyPasswordSet = false;
0112:
0113:            private CommandCentral() {
0114:            }
0115:
0116:            public synchronized void setArchiveConnectInfo(String archive,
0117:                    String userName, String password) throws IOException {
0118:                moConf = new GuiConf(archive, userName);
0119:                msArchiveName = archive;
0120:                msUserName = userName;
0121:                msPassword = password;
0122:            }
0123:
0124:            public String getArchiveName() {
0125:                return msArchiveName;
0126:            }
0127:
0128:            public SOAPPortal getPortal() {
0129:                return moPortal;
0130:            }
0131:
0132:            /**
0133:             * This method can be called to set the static out to some PrintStream
0134:             * other than the message pane. Typically, this will be called when
0135:             * SJ is being automated.
0136:             */
0137:            public void setAlternateOut(PrintStream altOut) {
0138:                out = altOut;
0139:            }
0140:
0141:            public String getUserName() {
0142:                return msUserName;
0143:            }
0144:
0145:            public String getPassword() {
0146:                return msPassword;
0147:            }
0148:
0149:            public GuiConf getGuiConf() {
0150:                return moConf;
0151:            }
0152:
0153:            public void setPrimaryTableColumnModel(TableColumnModel model) {
0154:                moPrimaryColumnModel = model;
0155:            }
0156:
0157:            public void rebuildFileView() throws NodeExistsException,
0158:                    IOException {
0159:                rebuildFileView(false);
0160:            }
0161:
0162:            public void rebuildFileView(boolean fromRoot)
0163:                    throws NodeExistsException, IOException {
0164:                ProjectTreeNode node = null;
0165:                if (!fromRoot) {
0166:                    node = moCurrentTreeNode;
0167:                } else if (mjRootAppFrame != null) {
0168:                    Object oRoot = mjRootAppFrame.getProjectTree().getModel()
0169:                            .getRoot();
0170:                    if (oRoot instanceof  ProjectTreeNode) {
0171:                        node = (ProjectTreeNode) oRoot;
0172:                    }
0173:                }
0174:                if (node != null) {
0175:                    node.rebuildDisplayList(UserPrefs.getInstance().getBoolean(
0176:                            UserPrefs.LOCAL_REMOTE_SYNC_VIEW, true));
0177:                    if (moCurrentTreeNode != null) {
0178:                        GuiUtil.setNewTableModel(moCurrentTreeNode
0179:                                .getFileTableModel());
0180:                    }
0181:                }
0182:            }
0183:
0184:            public void setCurrentTreeNode(ProjectTreeNode node) {
0185:                moCurrentTreeNode = node;
0186:                if (node != null) {
0187:                    try {
0188:                        java.io.File defaultDir = moConf
0189:                                .getDefaultWorkingDirectory(node.getNodeName());
0190:                        if (defaultDir != null && defaultDir.exists()) {
0191:                            currentProjectVerChecker = new SourceVersionChecker(
0192:                                    defaultDir, msURL, msArchiveName);
0193:                        } else {
0194:                            currentProjectVerChecker = null;
0195:                        }
0196:                    } catch (IOException ex) {
0197:                        currentProjectVerChecker = null;
0198:                    }
0199:                }
0200:            }
0201:
0202:            public SourceVersionChecker getCurrentProjectChecker() {
0203:                return currentProjectVerChecker;
0204:            }
0205:
0206:            public ProjectTreeNode getCurrentTreeNode() {
0207:                return moCurrentTreeNode;
0208:            }
0209:
0210:            public void setAppWindowRendered(boolean b) {
0211:                mbAppWindowRendered = b;
0212:            }
0213:
0214:            public boolean isAppWindowRendered() {
0215:                return mbAppWindowRendered;
0216:            }
0217:
0218:            public TableColumnModel getPrimaryTableColumnModel() {
0219:                TableColumn col = moPrimaryColumnModel.getColumn(1);
0220:                return moPrimaryColumnModel;
0221:            }
0222:
0223:            public static CommandCentral getInstance(
0224:                    SJPrimaryWindow rootApplicationFrame) {
0225:                instance.setRootAppFrameIfNull(rootApplicationFrame);
0226:                instance.initializeOut();
0227:                return instance;
0228:            }
0229:
0230:            private void initializeOut() {
0231:                if (out == null && mjRootAppFrame != null) {
0232:                    JTextArea messageArea = mjRootAppFrame.getMessageArea();
0233:                    if (messageArea == null) {
0234:                        System.out.println("Message area is null.");
0235:                    }
0236:                    MessageDisplayStream outStream = new MessageDisplayStream(
0237:                            messageArea, mjRootAppFrame.getMessagePane());
0238:                    out = new PrintStream(outStream);
0239:                    //System.out.println("Initialized out.");
0240:                }
0241:            }
0242:
0243:            public void setServerURL(String url) throws MalformedURLException {
0244:                moPortal = new SOAPPortal();
0245:                moPortal.setURL(url);
0246:                msURL = url;
0247:            }
0248:
0249:            public static CommandCentral getInstance() {
0250:                return instance;
0251:            }
0252:
0253:            private synchronized void setRootAppFrameIfNull(
0254:                    SJPrimaryWindow rootApplicationFrame) {
0255:                if (mjRootAppFrame == null) {
0256:                    mjRootAppFrame = rootApplicationFrame;
0257:                } else {
0258:                    throw new ConfigurationException(
0259:                            "Application root frame has already been set.");
0260:                }
0261:            }
0262:
0263:            public String[] getSelectedFileNames() {
0264:                String[] saReturn = null;
0265:                JTable table = mjRootAppFrame.getPrimaryTable();
0266:                int iSelectedRows[] = table.getSelectedRows();
0267:                TableModel model = table.getModel();
0268:
0269:                saReturn = new String[iSelectedRows.length];
0270:                for (int i = 0; i < iSelectedRows.length; i++) {
0271:                    NodeInfo nd = (NodeInfo) model.getValueAt(iSelectedRows[i],
0272:                            0);
0273:                    saReturn[i] = nd.getNodeName();
0274:                    //saReturn[i] = (String)model.getValueAt(iSelectedRows[i], 1);
0275:                }
0276:                return saReturn;
0277:            }
0278:
0279:            public NodeInfo getSelectedFileNodeInfo() {
0280:                NodeInfo[] files = getSelectedFilesNodeInfo();
0281:                return files[0];
0282:            }
0283:
0284:            public NodeInfo getSelectedFileNodeInfo(String name) {
0285:                NodeInfo file = null;
0286:                JTable table = mjRootAppFrame.getPrimaryTable();
0287:                int iSelectedRows[] = table.getSelectedRows();
0288:                TableModel model = table.getModel();
0289:
0290:                for (int i = 0; i < iSelectedRows.length; i++) {
0291:                    NodeInfo nd = (NodeInfo) model.getValueAt(iSelectedRows[i],
0292:                            0);
0293:                    if (nd.getNodeName().equals(name)) {
0294:                        file = nd;
0295:                        break;
0296:                    }
0297:                }
0298:                return file;
0299:            }
0300:
0301:            public NodeInfo[] getSelectedFilesNodeInfo() {
0302:                NodeInfo[] fileList = null;
0303:                JTable table = mjRootAppFrame.getPrimaryTable();
0304:                int iSelectedRows[] = table.getSelectedRows();
0305:                TableModel model = table.getModel();
0306:
0307:                fileList = new NodeInfo[iSelectedRows.length];
0308:                for (int i = 0; i < iSelectedRows.length; i++) {
0309:                    fileList[i] = (NodeInfo) model.getValueAt(iSelectedRows[i],
0310:                            0);
0311:                }
0312:                return fileList;
0313:            }
0314:
0315:            public String[] getAllCurrentFileNames() {
0316:                String[] saReturn = null;
0317:                JTable table = mjRootAppFrame.getPrimaryTable();
0318:                int iRowCount = table.getRowCount();
0319:
0320:                TableModel model = table.getModel();
0321:
0322:                ArrayList lst = new ArrayList();
0323:                for (int i = 0; i < iRowCount; i++) {
0324:                    FileNodeInfo nd = (FileNodeInfo) model.getValueAt(i, 0);
0325:                    if (nd.getLocalRemoteSyncState() != FileNodeInfo.NOT_IN_ARCHIVE)
0326:                        lst.add(nd.getNodeName());
0327:                }
0328:                saReturn = new String[lst.size()];
0329:                lst.toArray(saReturn);
0330:                return saReturn;
0331:            }
0332:
0333:            public String currentURL() {
0334:                return msURL;
0335:            }
0336:
0337:            /**
0338:             * Returns list of archives available on server user is currently
0339:             * connected to.
0340:             */
0341:            public String[] getArchiveNameList()
0342:                    throws SourceJammerConnectionException, GUICommandException {
0343:                String[] names = null;
0344:                SJRequest request = getBaseRequest();
0345:                SJResponse response = sendRequest(request,
0346:                        SOAPPortal.MCPMethodNames.GET_ARCHIVE_NAMES);
0347:                if (response.getErrorEncountered()) {
0348:                    throw new GUICommandException(response.getMessage());
0349:                }
0350:                Object[] oArchNames = (Object[]) response
0351:                        .objectValue(OBJECT_ARRAY);
0352:                names = new String[oArchNames.length];
0353:                for (int i = 0; i < oArchNames.length; i++) {
0354:                    names[i] = (String) oArchNames[i];
0355:                }
0356:                return names;
0357:            }
0358:
0359:            public SJResponse sendRequest(SJRequest request, String method)
0360:                    throws SourceJammerConnectionException, GUICommandException {
0361:                SJResponse response = null;
0362:                try {
0363:                    response = moPortal.sendRequest(request, method);
0364:                } catch (NoSessionException ex) {
0365:                    noSession();
0366:                    //try action again after reconnecting
0367:                    try {
0368:                        response = moPortal.sendRequest(request, method);
0369:                    } catch (NoSessionException ex2) {
0370:                        throw new SourceJammerConnectionException(
0371:                                DisplayTextLibrary
0372:                                        .displayText(DisplayTextLibrary.ERR_LOGIN_EXPIRED),
0373:                                ex2);
0374:                    }
0375:                }
0376:                return response;
0377:            }
0378:
0379:            private void noSession() throws SourceJammerConnectionException,
0380:                    GUICommandException {
0381:                try {
0382:                    //Attempt to reconnect.
0383:                    connectToArchive();
0384:                } catch (NoSessionException ex) {
0385:                    throw new SourceJammerConnectionException(
0386:                            DisplayTextLibrary
0387:                                    .displayText(DisplayTextLibrary.ERR_LOGIN_EXPIRED));
0388:                }
0389:            }
0390:
0391:            /**
0392:             * Returns true if the archive deleted is the current archive and
0393:             * the user is now disconnected. Signal to close any open dialog.
0394:             */
0395:            public boolean deleteArchive(String archiveName)
0396:                    throws SourceJammerConnectionException, GUICommandException {
0397:                boolean deletingCurrentArchive = false;
0398:                SJRequest request = getBaseRequest();
0399:                request.putString(NEW_ARCHIVE_NAME, archiveName);
0400:                SJResponse response = sendRequest(request,
0401:                        SOAPPortal.MCPMethodNames.DELETE_ARCHIVE);
0402:                if (!response.getErrorEncountered()) {
0403:                    //Set logout status to not logged in if just deleted current archive.
0404:                    if (archiveName.equals(msArchiveName)) {
0405:                        deletingCurrentArchive = true;
0406:                        setDisconnectedDisplaySettings();
0407:                        msArchiveName = null;
0408:                        msURL = null;
0409:                        msUserName = null;
0410:                        msPassword = null;
0411:                    }
0412:                    printServerMessage(response.getMessage());
0413:                } else {
0414:                    throw new GUICommandException(response.getMessage());
0415:                }
0416:                return deletingCurrentArchive;
0417:            }
0418:
0419:            public Project connectToArchive()
0420:                    throws SourceJammerConnectionException,
0421:                    GUICommandException, NoSessionException {
0422:                Project oReturn = null;
0423:                try {
0424:                    SJRequest request = new SJRequest();
0425:                    request.setArchiveName(msArchiveName);
0426:                    request.setUserName(msUserName);
0427:                    request.setPassword(msPassword);
0428:
0429:                    //Don't use internal sendRequest() method here because sendRequest() itself
0430:                    //may call this method. And NoSessionException does not mean very much
0431:                    //for Connection calls.
0432:
0433:                    //Before we call soap, set the proxy password to whatever we've got.
0434:                    moPortal.setProxyPassword(proxyPassword);
0435:                    SJResponse response = moPortal.sendRequest(request,
0436:                            SOAPPortal.MCPMethodNames.CONNECT);
0437:                    if (!response.getErrorEncountered()) {
0438:                        mlSessionID = response.getSessionID();
0439:                        oReturn = response.projectValue();
0440:                        try {
0441:                            oReturn.buildChildrenFromStrings();
0442:                        } catch (NodeExistsException ex) {
0443:                            throw new ConfigurationException(ex.getMessage(),
0444:                                    ex);
0445:                        }
0446:                    } else {
0447:                        throw new GUICommandException(response.getMessage());
0448:                    }
0449:                    if (mjRootAppFrame != null) {
0450:                        mjRootAppFrame.setTitle(APP_TITLE + " -- "
0451:                                + msArchiveName);
0452:                    }
0453:                    out.print(DisplayTextLibrary
0454:                            .displayText(DisplayTextLibrary.LBL_CONNECTED_TO));
0455:                    out.print(msArchiveName);
0456:                    out.print(" @ ");
0457:                    out.println(msURL);
0458:                    printServerMessage(response.getMessage());
0459:                } catch (SourceJammerConnectionException ex) {
0460:                    ex.printStackTrace(out);
0461:                    throw new SourceJammerConnectionException(
0462:                            DisplayTextLibrary
0463:                                    .displayText(DisplayTextLibrary.ERR_CONNECTION),
0464:                            ex);
0465:                }
0466:                return oReturn;
0467:            }
0468:
0469:            public void resetAppTitle() {
0470:                mjRootAppFrame.setTitle(APP_TITLE);
0471:            }
0472:
0473:            /**
0474:             * Get file info
0475:             */
0476:            public org.sourcejammer.project.view.File getFileInfo(
0477:                    NodeInfo flInfo, SJRequest request)
0478:                    throws GUICommandException, SourceJammerConnectionException {
0479:                org.sourcejammer.project.view.File oReturn = null;
0480:                try {
0481:                    if (request == null) {
0482:                        request = getBaseRequest();
0483:                    }
0484:                    request.putLong(REQUESTED_NODE_UNIQUE_ID, flInfo
0485:                            .getUniqueID());
0486:
0487:                    SourceJammerClient
0488:                            .getInstance()
0489:                            .getFileListeners()
0490:                            .notifyFileDetailsViewed(request, null,
0491:                                    EventTimingType.BEFORE_REQUEST_SENT, flInfo);
0492:
0493:                    SJResponse response = sendRequest(request,
0494:                            SOAPPortal.MCPMethodNames.GET_FILE_INFO);
0495:
0496:                    SourceJammerClient.getInstance().getFileListeners()
0497:                            .notifyFileDetailsViewed(request, response,
0498:                                    EventTimingType.AFTER_RESPONSE_RECEIVED,
0499:                                    flInfo);
0500:
0501:                    if (response.getErrorEncountered()) {
0502:                        throw new GUICommandException(response.getMessage());
0503:                    }
0504:                    oReturn = response.fileValue();
0505:                    try {
0506:                        oReturn.buildChildrenFromStrings();
0507:                    } catch (NodeExistsException ex) {
0508:                        throw new ConfigurationException(ex.getMessage(), ex);
0509:                    }
0510:
0511:                    printServerMessage(response.getMessage());
0512:                } catch (SourceJammerConnectionException ex) {
0513:                    ex.printStackTrace(out);
0514:                    throw new SourceJammerConnectionException(
0515:                            DisplayTextLibrary
0516:                                    .displayText(DisplayTextLibrary.ERR_CONNECTION),
0517:                            ex);
0518:                }
0519:                return oReturn;
0520:            }
0521:
0522:            /**
0523:             * Get Branch report
0524:             */
0525:            public String getBranchReport(long fileID, SJRequest request)
0526:                    throws GUICommandException, SourceJammerConnectionException {
0527:                String rpt = null;
0528:                try {
0529:                    if (request == null) {
0530:                        request = getBaseRequest();
0531:                    }
0532:                    request.putLong(REQUESTED_NODE_UNIQUE_ID, fileID);
0533:
0534:                    SJResponse response = sendRequest(request,
0535:                            SOAPPortal.MCPMethodNames.GET_BRANCH_REPORT);
0536:
0537:                    if (response.getErrorEncountered()) {
0538:                        throw new GUICommandException(response.getMessage());
0539:                    }
0540:                    rpt = response.stringValue(BRANCHES);
0541:                } catch (SourceJammerConnectionException ex) {
0542:                    ex.printStackTrace(out);
0543:                    throw new SourceJammerConnectionException(
0544:                            DisplayTextLibrary
0545:                                    .displayText(DisplayTextLibrary.ERR_CONNECTION),
0546:                            ex);
0547:                }
0548:                return rpt;
0549:            }
0550:
0551:            /**
0552:             * Make a new project on the server.
0553:             */
0554:            public long makeProject(long parentProjectID, String newProjectName)
0555:                    throws SourceJammerConnectionException, GUICommandException {
0556:                long lNewProjectID = -1;
0557:                try {
0558:                    SJRequest request = getBaseRequest();
0559:                    newProjectName = newProjectName.trim();
0560:                    request.putLong(REQUESTED_NODE_UNIQUE_ID, parentProjectID);
0561:                    request.putString(REQUESTED_NODE_NAME, newProjectName);
0562:                    SJResponse response = sendRequest(request,
0563:                            SOAPPortal.MCPMethodNames.ADD_PROJECT);
0564:                    if (response.getErrorEncountered()) {
0565:                        throw new GUICommandException(response.getMessage());
0566:                    }
0567:                    lNewProjectID = response.longValue(NODE_UNIQUE_ID);
0568:                    printServerMessage(response.getMessage());
0569:                } catch (SourceJammerConnectionException ex) {
0570:                    throw new SourceJammerConnectionException(
0571:                            DisplayTextLibrary
0572:                                    .displayText(DisplayTextLibrary.ERR_CONNECTION),
0573:                            ex);
0574:                }
0575:                return lNewProjectID;
0576:            }
0577:
0578:            public void renameProject(long projectID, long parentID,
0579:                    String newName) {
0580:                try {
0581:                    SJRequest request = getBaseRequest();
0582:                    request.putLong(REQUESTED_NODE_UNIQUE_ID, projectID);
0583:                    request.putLong(PARENT_NODE_UNIQUE_ID, parentID);
0584:                    request.putString(REQUESTED_NODE_NAME, newName);
0585:                    SJResponse response = moPortal.sendRequest(request,
0586:                            SOAPPortal.MCPMethodNames.RENAME_PROJECT);
0587:                    if (response.getErrorEncountered()) {
0588:                        throw new Exception(response.getMessage());
0589:                    }
0590:                    printServerMessage(response.getMessage());
0591:                } catch (SourceJammerConnectionException ex) {
0592:                    MessageBoxUtil.displayErrorMessage(DisplayTextLibrary
0593:                            .displayText(DisplayTextLibrary.ERR_CONNECTION));
0594:                } catch (Exception ex) {
0595:                    MessageBoxUtil.displayErrorMessage(ex.getMessage());
0596:                }
0597:            }
0598:
0599:            public void renameFile(NodeInfo flInfo, long parentID,
0600:                    String newName, SJRequest request)
0601:                    throws SourceJammerConnectionException, GUICommandException {
0602:                try {
0603:                    if (request == null) {
0604:                        request = getBaseRequest();
0605:                    }
0606:                    request.putLong(REQUESTED_NODE_UNIQUE_ID, flInfo
0607:                            .getUniqueID());
0608:                    request.putLong(PARENT_NODE_UNIQUE_ID, parentID);
0609:                    request.putString(REQUESTED_NODE_NAME, newName);
0610:
0611:                    SourceJammerClient
0612:                            .getInstance()
0613:                            .getFileListeners()
0614:                            .notifyFileRenamed(request, null,
0615:                                    EventTimingType.BEFORE_REQUEST_SENT, flInfo);
0616:
0617:                    SJResponse response = moPortal.sendRequest(request,
0618:                            SOAPPortal.MCPMethodNames.RENAME_FILE);
0619:                    if (response.getErrorEncountered()) {
0620:                        throw new Exception(response.getMessage());
0621:                    }
0622:                    printServerMessage(response.getMessage());
0623:
0624:                    SourceJammerClient.getInstance().getFileListeners()
0625:                            .notifyFileRenamed(request, response,
0626:                                    EventTimingType.AFTER_RESPONSE_RECEIVED,
0627:                                    flInfo);
0628:
0629:                } catch (SourceJammerConnectionException ex) {
0630:                    ex.printStackTrace(out);
0631:                    throw new SourceJammerConnectionException(
0632:                            DisplayTextLibrary
0633:                                    .displayText(DisplayTextLibrary.ERR_CONNECTION));
0634:                } catch (Exception ex) {
0635:                    throw new GUICommandException(ex.getMessage(), ex);
0636:                }
0637:            }
0638:
0639:            /**
0640:             * Retrieve info about a project from the server.
0641:             *
0642:             * Migrated to 1.1 unique ID approach. --rfm
0643:             */
0644:            public Project retrieveProject(long projectID)
0645:                    throws SourceJammerConnectionException, GUICommandException {
0646:                Project oReturn = null;
0647:                try {
0648:                    SJRequest request = getBaseRequest();
0649:                    request.putLong(REQUESTED_NODE_UNIQUE_ID, projectID);
0650:
0651:                    SJResponse response = moPortal.sendRequest(request,
0652:                            SOAPPortal.MCPMethodNames.GET_PROJECT_INFO);
0653:                    if (response.getErrorEncountered()) {
0654:                        throw new Exception(response.getMessage());
0655:                    }
0656:                    oReturn = response.projectValue();
0657:                    try {
0658:                        oReturn.buildChildrenFromStrings();
0659:                    } catch (NodeExistsException ex) {
0660:                        throw new ConfigurationException(ex.getMessage(), ex);
0661:                    }
0662:                    mlSessionID = response.getSessionID();
0663:                } catch (SourceJammerConnectionException ex) {
0664:                    ex.printStackTrace(out);
0665:                    throw new SourceJammerConnectionException(
0666:                            DisplayTextLibrary
0667:                                    .displayText(DisplayTextLibrary.ERR_CONNECTION));
0668:                } catch (Exception ex) {
0669:                    throw new GUICommandException(ex.getMessage(), ex);
0670:                }
0671:                return oReturn;
0672:            }
0673:
0674:            /**
0675:             * Returns unique id of project based on full path to sourcejammer node.
0676:             */
0677:            public long getProjectUniqueID(String sjPath)
0678:                    throws SourceJammerConnectionException, GUICommandException {
0679:                return getFileUniqueID(sjPath);
0680:            }
0681:
0682:            /**
0683:             * Returns unique id of file based on full path to sourcejammer node.
0684:             */
0685:            public long getFileUniqueID(String sjPath)
0686:                    throws SourceJammerConnectionException, GUICommandException {
0687:                long lFileID = -1;
0688:                try {
0689:                    SJRequest request = getBaseRequest();
0690:                    //First get the file ID.
0691:                    request.putLong(REQUESTED_NODE_UNIQUE_ID, 0);
0692:                    request.putString(REQUESTED_NODE_NAME, sjPath);
0693:                    SJResponse response = sendRequest(request,
0694:                            SOAPPortal.MCPMethodNames.GET_UNIQUE_ID_FROM_PATH);
0695:                    if (!response.getErrorEncountered()) {
0696:                        lFileID = response.longValue(NODE_UNIQUE_ID);
0697:                    } else {
0698:                        throw new Exception(response.getMessage());
0699:                    }
0700:                } catch (SourceJammerConnectionException ex) {
0701:                    ex.printStackTrace(out);
0702:                    throw new SourceJammerConnectionException(
0703:                            DisplayTextLibrary
0704:                                    .displayText(DisplayTextLibrary.ERR_CONNECTION));
0705:                } catch (Exception ex) {
0706:                    throw new GUICommandException(ex.getMessage(), ex);
0707:                }
0708:                return lFileID;
0709:            }
0710:
0711:            public void addFile(long parentUniqueID, String newFileName,
0712:                    String localFileNameLocation, int fileType,
0713:                    int historyType, String description, String afterAddAction,
0714:                    SJRequest request) throws GUICommandException,
0715:                    SourceJammerConnectionException, IOException {
0716:                try {
0717:                    if (request == null) {
0718:                        request = getBaseRequest();
0719:                    }
0720:                    request.putLong(REQUESTED_NODE_UNIQUE_ID, parentUniqueID);
0721:                    request.putString(REQUESTED_NODE_NAME, newFileName);
0722:                    if (fileType != AppConfig.FileTypes.BINARY
0723:                            && fileType != AppConfig.FileTypes.TEXT) {
0724:                        throw new GUICommandException(
0725:                                DisplayTextLibrary
0726:                                        .displayText(DisplayTextLibrary.ERR_FILE_TYPE_INVALID));
0727:                    }
0728:                    FileProperties props = new FileProperties();
0729:                    props.setFileType(fileType);
0730:                    props.setHistoryStorageType(historyType);
0731:                    props.setDescription(description);
0732:                    request.putObject(FILE_PROPERTIES, props);
0733:
0734:                    //Send binary file using uploader proxy.
0735:                    java.io.File fl = new java.io.File(localFileNameLocation);
0736:                    long lFileUploadId = sendFileToServer(fl, request);
0737:                    request.putLong(FILE_UPLOAD_ID, lFileUploadId);
0738:
0739:                    //Notify file listeners.
0740:                    SourceJammerClient.getInstance().getFileListeners()
0741:                            .notifyFileAdded(request, props,
0742:                                    EventTimingType.BEFORE_REQUEST_SENT, null);
0743:
0744:                    SJResponse response = sendRequest(request,
0745:                            SOAPPortal.MCPMethodNames.ADD_FILE);
0746:
0747:                    //Notify file listeners.
0748:                    SourceJammerClient.getInstance().getFileListeners()
0749:                            .notifyFileAdded(request, props,
0750:                                    EventTimingType.AFTER_RESPONSE_RECEIVED,
0751:                                    null);
0752:
0753:                    if (response.getErrorEncountered()) {
0754:                        throw new GUICommandException(response.getMessage());
0755:                    }
0756:                    mlSessionID = response.getSessionID();
0757:                    long lNewVerID = response.longValue(NODE_UNIQUE_ID);
0758:                    java.io.File flFile = new java.io.File(
0759:                            localFileNameLocation);
0760:                    SourceVersionChecker checker = getChecker(flFile
0761:                            .getParentFile());
0762:                    checker.updateLocalInfo(newFileName, lNewVerID);
0763:
0764:                    if (afterAddAction
0765:                            .equals(SourceJammerClient.lfa_SET_READ_ONLY)) {
0766:                        flFile.setReadOnly();
0767:                    } else if (afterAddAction
0768:                            .equals(SourceJammerClient.lfa_DELETE)) {
0769:                        flFile.delete();
0770:                    } else {
0771:                        //no special action.
0772:                    }
0773:
0774:                    printServerMessage(response.getMessage());
0775:                } catch (SourceJammerConnectionException ex) {
0776:                    ex.printStackTrace(out);
0777:                    throw new SourceJammerConnectionException(
0778:                            DisplayTextLibrary
0779:                                    .displayText(DisplayTextLibrary.ERR_CONNECTION),
0780:                            ex);
0781:                }
0782:            }
0783:
0784:            public void changeFileDescription(NodeInfo flInfo,
0785:                    String newDescription, SJRequest request)
0786:                    throws GUICommandException,
0787:                    SourceJammerConnectionException, IOException {
0788:                try {
0789:                    if (request == null) {
0790:                        request = getBaseRequest();
0791:                    }
0792:                    request.putLong(REQUESTED_NODE_UNIQUE_ID, flInfo
0793:                            .getUniqueID());
0794:                    request.putString(COMMENT, newDescription);
0795:
0796:                    SourceJammerClient
0797:                            .getInstance()
0798:                            .getFileListeners()
0799:                            .notifyFileDescriptionChanged(request,
0800:                                    newDescription,
0801:                                    EventTimingType.BEFORE_REQUEST_SENT, flInfo);
0802:
0803:                    SJResponse response = sendRequest(request,
0804:                            SOAPPortal.MCPMethodNames.CHANGE_FILE_DESCRIPTION);
0805:
0806:                    SourceJammerClient.getInstance().getFileListeners()
0807:                            .notifyFileDescriptionChanged(request, response,
0808:                                    EventTimingType.AFTER_RESPONSE_RECEIVED,
0809:                                    flInfo);
0810:
0811:                    if (response.getErrorEncountered()) {
0812:                        throw new GUICommandException(response.getMessage());
0813:                    }
0814:                    mlSessionID = response.getSessionID();
0815:                    printServerMessage(response.getMessage());
0816:                } catch (SourceJammerConnectionException ex) {
0817:                    ex.printStackTrace(out);
0818:                    throw new SourceJammerConnectionException(
0819:                            DisplayTextLibrary
0820:                                    .displayText(DisplayTextLibrary.ERR_CONNECTION),
0821:                            ex);
0822:                }
0823:            }
0824:
0825:            private void printServerMessage(String s) {
0826:                //ScreenUpdater.getInstance().printMessage("# " + s);
0827:                out.println("# " + s);
0828:            }
0829:
0830:            public boolean disconnect() throws SourceJammerConnectionException,
0831:                    GUICommandException {
0832:                boolean bActionComplete = false;
0833:                try {
0834:                    SJRequest request = getBaseRequest();
0835:                    msArchiveName = null;
0836:                    SJResponse response = moPortal.sendRequest(request,
0837:                            SOAPPortal.MCPMethodNames.DISCONNECT);
0838:                    printServerMessage(response.getMessage());
0839:                    msUserName = null;
0840:                    msPassword = null;
0841:                    moCurrentTreeNode = null;
0842:                    bActionComplete = true;
0843:                    out.println(DisplayTextLibrary
0844:                            .displayText(DisplayTextLibrary.LBL_DISCONNECTED));
0845:                } catch (SourceJammerConnectionException ex) {
0846:                    ex.printStackTrace(out);
0847:                    throw new SourceJammerConnectionException(
0848:                            DisplayTextLibrary
0849:                                    .displayText(DisplayTextLibrary.ERR_CONNECTION));
0850:                } catch (Exception ex) {
0851:                    throw new GUICommandException(ex.getMessage(), ex);
0852:                }
0853:                return bActionComplete;
0854:            }
0855:
0856:            public void setDisconnectedDisplaySettings() {
0857:                mjRootAppFrame.getProjectTree().setModel(null);
0858:                mjRootAppFrame.getPrimaryTable().setModel(
0859:                        new javax.swing.table.DefaultTableModel());
0860:                mjRootAppFrame.setTitle(APP_TITLE);
0861:
0862:                ActionCentral oActions = ActionCentral.getInstance();
0863:                oActions.enableAction(ActionCentral.act_CONNECT_LIST_ARCHIVES);
0864:                oActions.disableAction(ActionCentral.act_CHANGE_PASSWORD);
0865:                oActions
0866:                        .disableAction(ActionCentral.act_GET_COMPLETE_USER_LIST);
0867:                oActions.disableAction(ActionCentral.act_VIEW_LABELED_VERSIONS);
0868:                oActions.disableAction(ActionCentral.act_GET_LABELED_VERSION);
0869:                oActions.disableAction(ActionCentral.act_DISCONNECT);
0870:                oActions
0871:                        .disableAction(ActionCentral.act_LIST_ARCHIVES_ON_SERVER);
0872:                oActions
0873:                        .disableAction(ActionCentral.act_LIST_ARCHIVES_ON_SERVER_DELETE);
0874:                oActions.disableAction(ActionCentral.act_SHOW_ARCHIVE_PROPS);
0875:
0876:                oActions.disableAction(ActionCentral.act_ADD_FILE);
0877:                oActions.disableAction(ActionCentral.act_REFRESH_PROJECT);
0878:                oActions.disableAction(ActionCentral.act_SET_DEFAULT_DIR);
0879:                oActions.disableAction(ActionCentral.act_MAKE_PROJECT);
0880:                oActions.disableAction(ActionCentral.act_REMOVE_PROJECT);
0881:                oActions.disableAction(ActionCentral.act_VIEW_REMOVED);
0882:                oActions.disableAction(ActionCentral.act_VIEW_RESTORE_REMOVED);
0883:                oActions.disableAction(ActionCentral.act_VIEW_DELETE_REMOVED);
0884:                oActions.disableAction(ActionCentral.act_GET_FILES_IN_PROJECT);
0885:                oActions.disableAction(ActionCentral.act_MAKE_LABELED_VERSION);
0886:                oActions.disableAction(ActionCentral.act_RENAME_PROJECT);
0887:                oActions.disableAction(ActionCentral.act_MOVE_COPY_PROJECT);
0888:                oActions.disableAction(ActionCentral.act_CHECK_OUT_RPT);
0889:
0890:                oActions
0891:                        .disableAction(ActionCentral.act_MAINTAIN_ARCHIVE_USERS);
0892:            }
0893:
0894:            public void getFile(NodeInfo fileInfo,
0895:                    java.io.File flTargetDirectory, boolean setReadOnly,
0896:                    RepeatingResponse repeating)
0897:                    throws SourceJammerConnectionException,
0898:                    GUICommandException, IOException {
0899:                int iEOL = getClientDefaultEOLType();
0900:                getFile(fileInfo, flTargetDirectory, iEOL, setReadOnly,
0901:                        repeating, null);
0902:            }
0903:
0904:            public long getFileLatestVersionID(long lFileID) {
0905:                long lReturn = -1;
0906:                try {
0907:                    SJRequest request = getBaseRequest();
0908:                    request.putLong(REQUESTED_NODE_UNIQUE_ID, lFileID);
0909:                    SJResponse resID = moPortal.sendRequest(request,
0910:                            SOAPPortal.MCPMethodNames.GET_LATEST_VERSION_ID);
0911:                    lReturn = resID.longValue(NODE_UNIQUE_ID);
0912:                } catch (Exception ex) {
0913:                    lReturn = -1;
0914:                }
0915:                return lReturn;
0916:            }
0917:
0918:            public void getFile(NodeInfo fileInfo,
0919:                    java.io.File flTargetDirectory, int eolType,
0920:                    boolean setReadOnly, RepeatingResponse repeating,
0921:                    SJRequest request) throws SourceJammerConnectionException,
0922:                    GUICommandException, IOException {
0923:                getFile(fileInfo, flTargetDirectory, eolType, true,
0924:                        setReadOnly, repeating, request);
0925:            }
0926:
0927:            private boolean doesLocalFileExist(java.io.File dir, String fileName) {
0928:                boolean exists = true;
0929:                java.io.File fl = new java.io.File(dir, fileName);
0930:
0931:                if (!fl.exists()) {
0932:                    exists = false;
0933:                }
0934:                return exists;
0935:            }
0936:
0937:            public void getChangeList(long labelID, int newerVer, int olderVer,
0938:                    java.io.File targetFile, int eolType)
0939:                    throws SourceJammerConnectionException,
0940:                    GUICommandException, IOException {
0941:                try {
0942:                    java.io.File targetDir = targetFile.getParentFile();
0943:                    if (!targetDir.exists()) {
0944:                        throw new GUICommandException(
0945:                                DisplayTextLibrary
0946:                                        .displayText(DisplayTextLibrary.ERR_DIR_NO_EXIST));
0947:                    }
0948:
0949:                    //Build request.
0950:                    SJRequest request = getBaseRequest();
0951:                    request.putLong(REQUESTED_NODE_UNIQUE_ID, labelID);
0952:                    request.putInt(VERSION_NUMBER, newerVer);
0953:                    request.putInt(SECONDARY_VERSION_NUMBER, olderVer);
0954:                    request.putInt(REQUESTED_EOL_TYPE, eolType);
0955:                    request.putInt(ZIP_BINARIES_LARGER_THAN, SourceJammerClient
0956:                            .getInstance().getZipIfLargerThan());
0957:
0958:                    SJResponse response = sendRequest(request,
0959:                            SOAPPortal.MCPMethodNames.GET_CHANGE_LIST);
0960:                    if (response.getErrorEncountered()) {
0961:                        throw new GUICommandException(response.getMessage());
0962:                    }
0963:
0964:                    DownloadFileIdentifier downloadId = response
0965:                            .downloadFileIdentifierValue();
0966:                    long lTempFileId = retrieveFileFromServer(downloadId,
0967:                            response);
0968:
0969:                    java.io.File tempFile = TempDirectoryManager
0970:                            .getTempFileById(lTempFileId);
0971:
0972:                    FileSysUtil.streamFileToFile(tempFile, targetFile, false);
0973:                } catch (SourceJammerConnectionException ex) {
0974:                    throw new SourceJammerConnectionException(
0975:                            DisplayTextLibrary
0976:                                    .displayText(DisplayTextLibrary.ERR_CONNECTION),
0977:                            ex);
0978:                }
0979:            }
0980:
0981:            public void getFile(NodeInfo fileInfo,
0982:                    java.io.File flTargetDirectory, int eolType,
0983:                    boolean printMessages, boolean setReadOnly,
0984:                    RepeatingResponse repeating, SJRequest request)
0985:                    throws SourceJammerConnectionException,
0986:                    GUICommandException, IOException {
0987:                try {
0988:                    String sFileName = fileInfo.getNodeName();
0989:
0990:                    //If path passed in includes a file, assume this overrides file name.
0991:                    if (!flTargetDirectory.isDirectory()) {
0992:                        sFileName = flTargetDirectory.getName();
0993:                        flTargetDirectory = flTargetDirectory.getParentFile();
0994:                    }
0995:
0996:                    SourceVersionChecker checker = getChecker(flTargetDirectory);
0997:
0998:                    long lFileID = fileInfo.getUniqueID();
0999:                    boolean downloadFile = true;
1000:                    if (doesLocalFileExist(flTargetDirectory, sFileName)) {
1001:                        //If it exists, we need to see if we have latest version.
1002:                        long lLatestVerID = getFileLatestVersionID(lFileID);
1003:                        if (lLatestVerID == -1) {
1004:                            throw new BadMethodArgumentException(
1005:                                    DisplayTextLibrary
1006:                                            .displayText(DisplayTextLibrary.ERR_CANT_GET_VER_ID));
1007:                        }
1008:                        downloadFile = (!checker.isFileCurrent(sFileName,
1009:                                lLatestVerID));
1010:                    }
1011:                    //Check on latest version on file system.
1012:                    if (downloadFile) {
1013:                        if (request == null) {
1014:                            request = getBaseRequest();
1015:                        }
1016:                        request.putLong(REQUESTED_NODE_UNIQUE_ID, lFileID);
1017:
1018:                        request.putInt(REQUESTED_EOL_TYPE, eolType);
1019:                        request.putInt(ZIP_BINARIES_LARGER_THAN,
1020:                                SourceJammerClient.getInstance()
1021:                                        .getZipIfLargerThan());
1022:
1023:                        SourceJammerClient.getInstance().getFileListeners()
1024:                                .notifyFileGet(request, null,
1025:                                        EventTimingType.BEFORE_REQUEST_SENT,
1026:                                        fileInfo);
1027:
1028:                        SJResponse response = sendRequest(
1029:                                request,
1030:                                SOAPPortal.MCPMethodNames.GET_FILE_LATEST_VERSION);
1031:
1032:                        SourceJammerClient
1033:                                .getInstance()
1034:                                .getFileListeners()
1035:                                .notifyFileGet(
1036:                                        request,
1037:                                        response,
1038:                                        EventTimingType.AFTER_RESPONSE_RECEIVED,
1039:                                        fileInfo);
1040:
1041:                        if (response.getErrorEncountered()) {
1042:                            throw new GUICommandException(response.getMessage());
1043:                        }
1044:
1045:                        DownloadFileIdentifier downloadId = response
1046:                                .downloadFileIdentifierValue();
1047:                        long lTempFileId = retrieveFileFromServer(downloadId,
1048:                                response);
1049:
1050:                        long latestVerID = response.longValue(NODE_UNIQUE_ID);
1051:                        boolean bSaved = checker.saveFile(sFileName,
1052:                                latestVerID, lTempFileId, setReadOnly,
1053:                                repeating);
1054:                        if (printMessages) {
1055:                            printServerMessage(response.getMessage());
1056:                            if (bSaved) {
1057:                                out
1058:                                        .print(DisplayTextLibrary
1059:                                                .displayText(DisplayTextLibrary.LBL_SAVED_FILE));
1060:                                out.println(flTargetDirectory
1061:                                        + java.io.File.separator + sFileName);
1062:                            } else {
1063:                                out
1064:                                        .println(DisplayTextLibrary
1065:                                                .displayText(DisplayTextLibrary.LBL_FILE_NOT_SAVED));
1066:                            }
1067:                        }
1068:                    } else {
1069:                        if (printMessages) {
1070:                            out
1071:                                    .println(DisplayTextLibrary
1072:                                            .displayText(DisplayTextLibrary.LBL_LOCAL_IS_CURRENT)
1073:                                            + "--" + sFileName);
1074:                        }
1075:                    }
1076:                } catch (SourceJammerConnectionException ex) {
1077:                    throw new SourceJammerConnectionException(
1078:                            DisplayTextLibrary
1079:                                    .displayText(DisplayTextLibrary.ERR_CONNECTION),
1080:                            ex);
1081:                }
1082:            }
1083:
1084:            public void checkOutFileToStream(long fileID, OutputStream stmOut,
1085:                    int eolType) throws SourceJammerConnectionException,
1086:                    GUICommandException, IOException {
1087:
1088:                try {
1089:
1090:                    SJRequest request = getBaseRequest();
1091:
1092:                    request.putLong(REQUESTED_NODE_UNIQUE_ID, fileID);
1093:                    request.putString(CHECK_OUT_PATH, "unknown");
1094:                    request.putInt(REQUESTED_EOL_TYPE, eolType);
1095:                    request.putBoolean(EXCLUDE_FILE, false);
1096:                    request.putInt(ZIP_BINARIES_LARGER_THAN, SourceJammerClient
1097:                            .getInstance().getZipIfLargerThan());
1098:
1099:                    SJResponse response = sendRequest(request,
1100:                            SOAPPortal.MCPMethodNames.CHECK_OUT_FILE);
1101:                    if (response.getErrorEncountered()) {
1102:                        throw new GUICommandException(response.getMessage());
1103:                    }
1104:                    DownloadFileIdentifier downloadId = response
1105:                            .downloadFileIdentifierValue();
1106:                    long lTempFileId = retrieveFileFromServer(downloadId,
1107:                            response);
1108:
1109:                    java.io.File flTemp = TempDirectoryManager
1110:                            .getTempFileById(lTempFileId);
1111:                    FileInputStream stmIn = new FileInputStream(flTemp);
1112:                    try {
1113:                        FileUtil.inputStreamToOutputStream(stmIn, stmOut);
1114:                    } finally {
1115:                        stmIn.close();
1116:                        flTemp.delete();
1117:                    }
1118:                } catch (SourceJammerConnectionException ex) {
1119:                    ex.printStackTrace(out);
1120:                    throw new SourceJammerConnectionException(
1121:                            DisplayTextLibrary
1122:                                    .displayText(DisplayTextLibrary.ERR_CONNECTION),
1123:                            ex);
1124:                }
1125:            }
1126:
1127:            public void getFileToStream(long lFileID, OutputStream stmOut,
1128:                    int eolType) throws SourceJammerConnectionException,
1129:                    GUICommandException, IOException {
1130:                try {
1131:
1132:                    long lLatestVerID = getFileLatestVersionID(lFileID);
1133:                    if (lLatestVerID == -1) {
1134:                        throw new BadMethodArgumentException(
1135:                                DisplayTextLibrary
1136:                                        .displayText(DisplayTextLibrary.ERR_CANT_GET_VER_ID));
1137:                    }
1138:
1139:                    SJRequest request = getBaseRequest();
1140:                    request.putLong(REQUESTED_NODE_UNIQUE_ID, lFileID);
1141:
1142:                    request.putInt(REQUESTED_EOL_TYPE, eolType);
1143:                    request.putInt(ZIP_BINARIES_LARGER_THAN, SourceJammerClient
1144:                            .getInstance().getZipIfLargerThan());
1145:
1146:                    SJResponse response = sendRequest(request,
1147:                            SOAPPortal.MCPMethodNames.GET_FILE_LATEST_VERSION);
1148:                    if (response.getErrorEncountered()) {
1149:                        throw new GUICommandException(response.getMessage());
1150:                    }
1151:
1152:                    DownloadFileIdentifier downloadId = response
1153:                            .downloadFileIdentifierValue();
1154:                    long lTempFileId = retrieveFileFromServer(downloadId,
1155:                            response);
1156:
1157:                    java.io.File flTemp = TempDirectoryManager
1158:                            .getTempFileById(lTempFileId);
1159:                    FileInputStream stmIn = new FileInputStream(flTemp);
1160:                    try {
1161:                        FileUtil.inputStreamToOutputStream(stmIn, stmOut);
1162:                    } finally {
1163:                        stmIn.close();
1164:                        flTemp.delete();
1165:                    }
1166:                } catch (SourceJammerConnectionException ex) {
1167:                    throw new SourceJammerConnectionException(
1168:                            DisplayTextLibrary
1169:                                    .displayText(DisplayTextLibrary.ERR_CONNECTION),
1170:                            ex);
1171:                }
1172:            }
1173:
1174:            /**
1175:             * Gets the default EOL type for the client from AppConfig.
1176:             */
1177:            public int getClientDefaultEOLType() {
1178:                int iEOL = -1;
1179:                String sEOL = new String(SourceJammerClient.getInstance()
1180:                        .getDefaultEndOfLine());
1181:                String sLF = new String(AppConfig.EndOfLines.LINE_FEED);
1182:                if (sEOL.equals(sLF)) {
1183:                    iEOL = AppConfig.EndOfLineType.LINE_FEED;
1184:                } else {
1185:                    iEOL = AppConfig.EndOfLineType.CARRIAGE_RETURN_LINE_FEED;
1186:                }
1187:                return iEOL;
1188:            }
1189:
1190:            public void checkOutFile(long fileID, String fileName,
1191:                    java.io.File flTargetDirectory)
1192:                    throws SourceJammerConnectionException,
1193:                    GUICommandException, IOException {
1194:                int iEOL = getClientDefaultEOLType();
1195:                checkOutFile(fileID, fileName, flTargetDirectory, iEOL, null);
1196:            }
1197:
1198:            public boolean hasLocalFileChanged(String fileName,
1199:                    java.io.File flTargetDir) throws IOException {
1200:
1201:                boolean hasChnaged = false;
1202:                java.io.File testFile = new java.io.File(flTargetDir, fileName);
1203:                if (testFile.exists()) {
1204:                    SourceVersionChecker checker = getChecker(flTargetDir);
1205:                    hasChnaged = !checker.isStoredFileInfoAccurate(fileName);
1206:                }
1207:                return hasChnaged;
1208:            }
1209:
1210:            public void checkOutFile(long fileID, String fileName,
1211:                    java.io.File flTargetDirectory, int eolType,
1212:                    SJRequest request) throws SourceJammerConnectionException,
1213:                    GUICommandException, IOException {
1214:
1215:                try {
1216:                    long lLatestVerID = getFileLatestVersionID(fileID);
1217:                    SourceVersionChecker checker = getChecker(flTargetDirectory);
1218:                    boolean bExclude = checker.isFileCurrent(fileName,
1219:                            lLatestVerID);
1220:
1221:                    if (request == null) {
1222:                        request = getBaseRequest();
1223:                    }
1224:
1225:                    request.putLong(REQUESTED_NODE_UNIQUE_ID, fileID);
1226:                    request.putString(CHECK_OUT_PATH, flTargetDirectory
1227:                            .getAbsolutePath());
1228:                    request.putInt(REQUESTED_EOL_TYPE, eolType);
1229:                    request.putBoolean(EXCLUDE_FILE, bExclude);
1230:                    if (bExclude) {
1231:                        out
1232:                                .println(DisplayTextLibrary
1233:                                        .displayText(DisplayTextLibrary.LBL_LOCAL_IS_CURRENT)
1234:                                        + ".");
1235:                    } else {
1236:                        request.putInt(ZIP_BINARIES_LARGER_THAN,
1237:                                SourceJammerClient.getInstance()
1238:                                        .getZipIfLargerThan());
1239:                    }
1240:
1241:                    FileNodeInfo flNodeInfo = (FileNodeInfo) getSelectedFileNodeInfo(fileName);
1242:                    SourceJammerClient.getInstance().getFileListeners()
1243:                            .notifyFileCheckedOut(request, null,
1244:                                    EventTimingType.BEFORE_REQUEST_SENT,
1245:                                    flNodeInfo);
1246:
1247:                    SJResponse response = sendRequest(request,
1248:                            SOAPPortal.MCPMethodNames.CHECK_OUT_FILE);
1249:
1250:                    SourceJammerClient.getInstance().getFileListeners()
1251:                            .notifyFileCheckedOut(request, null,
1252:                                    EventTimingType.AFTER_RESPONSE_RECEIVED,
1253:                                    flNodeInfo);
1254:
1255:                    if (response.getErrorEncountered()) {
1256:                        throw new GUICommandException(response.getMessage());
1257:                    }
1258:                    printServerMessage(response.getMessage());
1259:                    if (!bExclude) {
1260:                        DownloadFileIdentifier downloadId = response
1261:                                .downloadFileIdentifierValue();
1262:                        long lTempFileId = retrieveFileFromServer(downloadId,
1263:                                response);
1264:
1265:                        boolean bSaved = checker.saveFile(fileName,
1266:                                lLatestVerID, lTempFileId, false, null);
1267:                        if (bSaved) {
1268:                            out
1269:                                    .print(DisplayTextLibrary
1270:                                            .displayText(DisplayTextLibrary.LBL_SAVED_FILE));
1271:                            out.println(flTargetDirectory
1272:                                    + java.io.File.separator + fileName);
1273:                        } else {
1274:                            out
1275:                                    .println(DisplayTextLibrary
1276:                                            .displayText(DisplayTextLibrary.LBL_FILE_NOT_SAVED));
1277:                        }
1278:                    } else {
1279:                        makeFileWritable(new java.io.File(flTargetDirectory,
1280:                                fileName));
1281:                    }
1282:                } catch (SourceJammerConnectionException ex) {
1283:                    ex.printStackTrace(out);
1284:                    throw new SourceJammerConnectionException(
1285:                            DisplayTextLibrary
1286:                                    .displayText(DisplayTextLibrary.ERR_CONNECTION),
1287:                            ex);
1288:                }
1289:            }
1290:
1291:            /**
1292:             * Force local version of file into archive without checking file out.
1293:             */
1294:            public void forceCheckIn(NodeInfo fileNode,
1295:                    java.io.File flTargetDirectory, String comment,
1296:                    String afterCheckInAction, SJRequest request)
1297:                    throws SourceJammerConnectionException,
1298:                    GUICommandException, IOException {
1299:                try {
1300:                    if (request == null) {
1301:                        request = getBaseRequest();
1302:                    }
1303:
1304:                    long fileID = fileNode.getUniqueID();
1305:                    String fileName = fileNode.getNodeName();
1306:
1307:                    //Check out file, but don't download it.
1308:                    request.putLong(REQUESTED_NODE_UNIQUE_ID, fileID);
1309:                    request.putString(CHECK_OUT_PATH, flTargetDirectory
1310:                            .getAbsolutePath());
1311:                    request.putBoolean(EXCLUDE_FILE, true);
1312:
1313:                    FileNodeInfo flNodeInfo = (FileNodeInfo) getSelectedFileNodeInfo(fileName);
1314:                    //Notify force check in
1315:                    SourceJammerClient.getInstance().getFileListeners()
1316:                            .notifyFileForceCheckedIn(request, null,
1317:                                    EventTimingType.BEFORE_REQUEST_SENT,
1318:                                    flNodeInfo);
1319:
1320:                    //Notify check out.
1321:                    SourceJammerClient.getInstance().getFileListeners()
1322:                            .notifyFileCheckedOut(request, null,
1323:                                    EventTimingType.BEFORE_REQUEST_SENT,
1324:                                    flNodeInfo);
1325:
1326:                    SJResponse response = sendRequest(request,
1327:                            SOAPPortal.MCPMethodNames.CHECK_OUT_FILE);
1328:
1329:                    SourceJammerClient.getInstance().getFileListeners()
1330:                            .notifyFileCheckedOut(request, response,
1331:                                    EventTimingType.AFTER_RESPONSE_RECEIVED,
1332:                                    flNodeInfo);
1333:
1334:                    if (response.getErrorEncountered()) {
1335:                        throw new GUICommandException(response.getMessage());
1336:                    }
1337:
1338:                    //Check local file in.
1339:                    //Notify check in.
1340:                    SourceJammerClient.getInstance().getFileListeners()
1341:                            .notifyFileCheckedIn(request, null,
1342:                                    EventTimingType.BEFORE_REQUEST_SENT,
1343:                                    flNodeInfo);
1344:
1345:                    checkInFile(fileNode, flTargetDirectory, comment,
1346:                            afterCheckInAction, null);
1347:
1348:                    SourceJammerClient.getInstance().getFileListeners()
1349:                            .notifyFileCheckedIn(request, response,
1350:                                    EventTimingType.AFTER_RESPONSE_RECEIVED,
1351:                                    flNodeInfo);
1352:
1353:                    SourceJammerClient.getInstance().getFileListeners()
1354:                            .notifyFileForceCheckedIn(request, response,
1355:                                    EventTimingType.AFTER_RESPONSE_RECEIVED,
1356:                                    flNodeInfo);
1357:                } catch (SourceJammerConnectionException ex) {
1358:                    throw new SourceJammerConnectionException(
1359:                            DisplayTextLibrary
1360:                                    .displayText(DisplayTextLibrary.ERR_CONNECTION),
1361:                            ex);
1362:                }
1363:
1364:            }
1365:
1366:            /**
1367:             * Checks in the file. If file is shared, tells server to branch it on
1368:             * checkin.
1369:             */
1370:            public void branchAndCheckIn(NodeInfo fileNode,
1371:                    java.io.File flTargetDirectory, String comment,
1372:                    String afterCheckInAction, long parentProjectID,
1373:                    String identifier, SJRequest request)
1374:                    throws SourceJammerConnectionException,
1375:                    GUICommandException, IOException {
1376:                if (request == null) {
1377:                    request = getBaseRequest();
1378:                }
1379:                if (fileNode.isShared()) {
1380:                    request.putBoolean(IS_BRANCH_AFTER_CHECKIN, true);
1381:                    request.putString(IDENTIFIER, identifier);
1382:                    request.putLong(PARENT_NODE_UNIQUE_ID, parentProjectID);
1383:                } else {
1384:                    request.removeValue(IS_BRANCH_AFTER_CHECKIN);
1385:                    ;
1386:                }
1387:                checkInFile(fileNode, flTargetDirectory, comment,
1388:                        afterCheckInAction, request);
1389:            }
1390:
1391:            public void checkInFile(NodeInfo fileNode,
1392:                    java.io.File flTargetDirectory, String comment,
1393:                    String afterCheckInAction, SJRequest request)
1394:                    throws SourceJammerConnectionException,
1395:                    GUICommandException, IOException {
1396:
1397:                try {
1398:                    String fileName = fileNode.getNodeName();
1399:                    long fileID = fileNode.getUniqueID();
1400:                    String localFileNameLocation = flTargetDirectory
1401:                            .getAbsolutePath()
1402:                            + java.io.File.separator + fileName;
1403:
1404:                    if (request == null) {
1405:                        request = getBaseRequest();
1406:                    }
1407:
1408:                    request.putLong(REQUESTED_NODE_UNIQUE_ID, fileID);
1409:                    if (comment == null) {
1410:                        comment = "";
1411:                    }
1412:                    request.putString(COMMENT, comment);
1413:
1414:                    java.io.File fl = new java.io.File(localFileNameLocation);
1415:                    long lFileUploadId = sendFileToServer(fl, request);
1416:
1417:                    request.putLong(FILE_UPLOAD_ID, lFileUploadId);
1418:
1419:                    SourceJammerClient.getInstance().getFileListeners()
1420:                            .notifyFileCheckedIn(request, null,
1421:                                    EventTimingType.BEFORE_REQUEST_SENT,
1422:                                    fileNode);
1423:
1424:                    SJResponse response = sendRequest(request,
1425:                            SOAPPortal.MCPMethodNames.CHECK_IN_FILE);
1426:
1427:                    SourceJammerClient.getInstance().getFileListeners()
1428:                            .notifyFileCheckedIn(request, null,
1429:                                    EventTimingType.AFTER_RESPONSE_RECEIVED,
1430:                                    fileNode);
1431:
1432:                    if (response.getErrorEncountered()) {
1433:                        throw new GUICommandException(response.getMessage());
1434:                    }
1435:                    long lNewVerID = response.longValue(NODE_UNIQUE_ID);
1436:                    SourceVersionChecker checker = getChecker(flTargetDirectory);
1437:                    checker.updateLocalInfo(fileName, lNewVerID);
1438:                    java.io.File flFile = new java.io.File(
1439:                            localFileNameLocation);
1440:                    if (afterCheckInAction
1441:                            .equals(SourceJammerClient.lfa_SET_READ_ONLY)) {
1442:                        flFile.setReadOnly();
1443:                    } else if (afterCheckInAction
1444:                            .equals(SourceJammerClient.lfa_DELETE)) {
1445:                        flFile.delete();
1446:                    } else {
1447:                        //No action.
1448:                    }
1449:
1450:                    if (lNewVerID < 0) {
1451:                        //Means file was modified by server on checkin.
1452:                        String confAction = SourceJammerClient.getInstance()
1453:                                .getOnFileModifiedOnCheckin();
1454:                        if (confAction
1455:                                .equals(SourceJammerClient.lfa_GET_LATEST)) {
1456:                            //Fire off a get on the file.
1457:                            //Check if we have a new file id.
1458:                            long newID = response.longValue(NEW_FILE_ID);
1459:                            if (newID > -1) {
1460:                                fileNode = fileNode.cloneNodeInfo();
1461:                                fileNode.setUniqueID(newID);
1462:                            }
1463:                            getFile(
1464:                                    fileNode,
1465:                                    flTargetDirectory,
1466:                                    afterCheckInAction
1467:                                            .equals(SourceJammerClient.lfa_SET_READ_ONLY),
1468:                                    null);
1469:                        }
1470:                    }
1471:                    printServerMessage(response.getMessage());
1472:                } catch (SourceJammerConnectionException ex) {
1473:                    throw new SourceJammerConnectionException(
1474:                            DisplayTextLibrary
1475:                                    .displayText(DisplayTextLibrary.ERR_CONNECTION),
1476:                            ex);
1477:                }
1478:            }
1479:
1480:            public void undoCheckOut(long fileID, String sFileName,
1481:                    java.io.File flTargetDirectory, SJRequest request)
1482:                    throws SourceJammerConnectionException, GUICommandException {
1483:                try {
1484:                    if (request == null) {
1485:                        request = getBaseRequest();
1486:                    }
1487:                    request.putLong(REQUESTED_NODE_UNIQUE_ID, fileID);
1488:
1489:                    FileNodeInfo flNodeInfo = (FileNodeInfo) getSelectedFileNodeInfo(sFileName);
1490:                    SourceJammerClient.getInstance().getFileListeners()
1491:                            .notifyFileCheckeOutUndone(request, null,
1492:                                    EventTimingType.BEFORE_REQUEST_SENT,
1493:                                    flNodeInfo);
1494:
1495:                    SJResponse response = sendRequest(request,
1496:                            SOAPPortal.MCPMethodNames.UNDO_CHECKOUT);
1497:
1498:                    SourceJammerClient.getInstance().getFileListeners()
1499:                            .notifyFileCheckeOutUndone(request, response,
1500:                                    EventTimingType.AFTER_RESPONSE_RECEIVED,
1501:                                    flNodeInfo);
1502:
1503:                    if (response.getErrorEncountered()) {
1504:                        throw new GUICommandException(response.getMessage());
1505:                    }
1506:                    if (flTargetDirectory != null) {
1507:                        java.io.File flFile = new java.io.File(
1508:                                flTargetDirectory, sFileName);
1509:                        if (flFile.exists()) {
1510:                            flFile.setReadOnly();
1511:                        }
1512:                    }
1513:                    printServerMessage(response.getMessage());
1514:                } catch (SourceJammerConnectionException ex) {
1515:                    throw new SourceJammerConnectionException(
1516:                            DisplayTextLibrary
1517:                                    .displayText(DisplayTextLibrary.ERR_CONNECTION),
1518:                            ex);
1519:                }
1520:            }
1521:
1522:            public String viewVersionComment(long versionID)
1523:                    throws SourceJammerConnectionException, GUICommandException {
1524:                String comment = null;
1525:                try {
1526:                    SJRequest request = getBaseRequest();
1527:                    request.putLong(REQUESTED_NODE_UNIQUE_ID, versionID);
1528:                    SJResponse response = sendRequest(request,
1529:                            SOAPPortal.MCPMethodNames.VIEW_VERSION_COMMENT);
1530:                    if (response.getErrorEncountered()) {
1531:                        throw new GUICommandException(response.getMessage());
1532:                    }
1533:                    comment = response.getMessage();
1534:                    if (comment == null) {
1535:                        comment = "";
1536:                    }
1537:                } catch (SourceJammerConnectionException ex) {
1538:                    throw new SourceJammerConnectionException(
1539:                            DisplayTextLibrary
1540:                                    .displayText(DisplayTextLibrary.ERR_CONNECTION),
1541:                            ex);
1542:                }
1543:                return comment;
1544:            }
1545:
1546:            public void getFileVersion(NodeInfo flInfo,
1547:                    java.io.File flTargetDirectory, int iVersion,
1548:                    long versionID, boolean setReadOnly,
1549:                    RepeatingResponse repeating)
1550:                    throws SourceJammerConnectionException,
1551:                    GUICommandException, IOException {
1552:                getFileVersion(flInfo, flTargetDirectory, iVersion, versionID,
1553:                        setReadOnly, true, repeating);
1554:            }
1555:
1556:            public void getFileVersion(NodeInfo flInfo,
1557:                    java.io.File flTargetDirectory, int iVersion,
1558:                    long versionID, boolean setReadOnly,
1559:                    RepeatingResponse repeating, SJRequest request)
1560:                    throws SourceJammerConnectionException,
1561:                    GUICommandException, IOException {
1562:                getFileVersion(flInfo, flTargetDirectory, iVersion, versionID,
1563:                        getClientDefaultEOLType(), setReadOnly, true,
1564:                        repeating, request);
1565:            }
1566:
1567:            public void getFileVersion(NodeInfo flInfo,
1568:                    java.io.File flTargetDirectory, int iVersion,
1569:                    long versionID, boolean setReadOnly, boolean printMessages,
1570:                    RepeatingResponse repeating)
1571:                    throws SourceJammerConnectionException,
1572:                    GUICommandException, IOException {
1573:                int iEOL = getClientDefaultEOLType();
1574:                getFileVersion(flInfo, flTargetDirectory, iVersion, versionID,
1575:                        iEOL, setReadOnly, printMessages, repeating, null);
1576:            }
1577:
1578:            public void getFileVersion(NodeInfo flInfo,
1579:                    java.io.File flTargetDirectory, int iVersion,
1580:                    long versionID, int eolType, boolean setReadOnly,
1581:                    RepeatingResponse repeating, SJRequest request)
1582:                    throws SourceJammerConnectionException,
1583:                    GUICommandException, IOException {
1584:                getFileVersion(flInfo, flTargetDirectory, iVersion, versionID,
1585:                        eolType, setReadOnly, true, repeating, request);
1586:            }
1587:
1588:            public void getFileVersion(NodeInfo flInfo,
1589:                    java.io.File flTargetDirectory, int iVersion,
1590:                    long versionID, int eolType, boolean setReadOnly,
1591:                    boolean printMessages, RepeatingResponse repeating,
1592:                    SJRequest request) throws SourceJammerConnectionException,
1593:                    GUICommandException, IOException {
1594:                try {
1595:                    getFileVersionFromServer(flInfo, iVersion, eolType,
1596:                            versionID, flTargetDirectory, setReadOnly,
1597:                            printMessages, repeating, request);
1598:                } catch (SourceJammerConnectionException ex) {
1599:                    throw new SourceJammerConnectionException(
1600:                            DisplayTextLibrary
1601:                                    .displayText(DisplayTextLibrary.ERR_CONNECTION),
1602:                            ex);
1603:                }
1604:            }
1605:
1606:            /**
1607:             * Gets full source from server for a specified version, if required, and
1608:             * saves the file.
1609:             */
1610:            private void getFileVersionFromServer(NodeInfo flInfo,
1611:                    int iVersion, int eolType, long versionID,
1612:                    java.io.File targetDir, boolean setReadOnly,
1613:                    RepeatingResponse repeating, SJRequest request)
1614:                    throws GUICommandException,
1615:                    SourceJammerConnectionException, IOException {
1616:                getFileVersionFromServer(flInfo, iVersion, eolType, versionID,
1617:                        targetDir, setReadOnly, true, repeating, request);
1618:            }
1619:
1620:            private void getFileVersionFromServer(NodeInfo flInfo,
1621:                    int iVersion, int eolType, long versionID,
1622:                    java.io.File targetDir, boolean setReadOnly,
1623:                    boolean printMessages, RepeatingResponse repeating,
1624:                    SJRequest request) throws GUICommandException,
1625:                    SourceJammerConnectionException, IOException {
1626:                String fileName = flInfo.getNodeName();
1627:                //if target is a file, assume name overrides.
1628:                if (!targetDir.isDirectory()) {
1629:                    fileName = targetDir.getName();
1630:                    targetDir = targetDir.getParentFile();
1631:                }
1632:                SourceVersionChecker checker = getChecker(targetDir);
1633:                if (!checker.isFileCurrent(fileName, versionID)) {
1634:                    if (request == null) {
1635:                        request = getBaseRequest();
1636:                    }
1637:                    long fileID = flInfo.getUniqueID();
1638:                    request.putLong(REQUESTED_NODE_UNIQUE_ID, fileID);
1639:                    request.putInt(VERSION_NUMBER, iVersion);
1640:                    request.putInt(REQUESTED_EOL_TYPE, eolType);
1641:                    request.putInt(ZIP_BINARIES_LARGER_THAN, SourceJammerClient
1642:                            .getInstance().getZipIfLargerThan());
1643:
1644:                    SourceJammerClient
1645:                            .getInstance()
1646:                            .getFileListeners()
1647:                            .notifyFileVersionGet(request, null,
1648:                                    EventTimingType.BEFORE_REQUEST_SENT, flInfo);
1649:
1650:                    SJResponse response = sendRequest(request,
1651:                            SOAPPortal.MCPMethodNames.GET_FILE_VERSION);
1652:
1653:                    SourceJammerClient.getInstance().getFileListeners()
1654:                            .notifyFileVersionGet(request, null,
1655:                                    EventTimingType.AFTER_RESPONSE_RECEIVED,
1656:                                    flInfo);
1657:
1658:                    if (response.getErrorEncountered()) {
1659:                        throw new GUICommandException(response.getMessage());
1660:                    }
1661:                    DownloadFileIdentifier downloadId = response
1662:                            .downloadFileIdentifierValue();
1663:                    long lTempFileId = retrieveFileFromServer(downloadId,
1664:                            response);
1665:
1666:                    boolean bSaved = checker.saveFile(fileName, versionID,
1667:                            lTempFileId, setReadOnly, repeating);
1668:                    if (printMessages) {
1669:                        printServerMessage(response.getMessage());
1670:                        if (bSaved) {
1671:                            out
1672:                                    .print(DisplayTextLibrary
1673:                                            .displayText(DisplayTextLibrary.LBL_SAVED_FILE));
1674:                            out.println(targetDir + java.io.File.separator
1675:                                    + fileName);
1676:                        } else {
1677:                            out
1678:                                    .println(DisplayTextLibrary
1679:                                            .displayText(DisplayTextLibrary.LBL_FILE_NOT_SAVED));
1680:                        }
1681:                    }
1682:                } else {
1683:                    if (printMessages) {
1684:                        out
1685:                                .println(DisplayTextLibrary
1686:                                        .displayText(DisplayTextLibrary.LBL_LOCAL_IS_CURRENT)
1687:                                        + "--" + fileName);
1688:                    }
1689:                }
1690:            }
1691:
1692:            public boolean doesProjectContainShares(long projectID)
1693:                    throws SourceJammerConnectionException, GUICommandException {
1694:                try {
1695:                    SJRequest request = getBaseRequest();
1696:                    request.putLong(REQUESTED_NODE_UNIQUE_ID, projectID);
1697:                    SJResponse response = sendRequest(request,
1698:                            SOAPPortal.MCPMethodNames.PROJECT_CONTAINS_SHARES);
1699:                    if (response.getErrorEncountered()) {
1700:                        throw new GUICommandException(response.getMessage());
1701:                    }
1702:                    return response.booleanValue(BOOLEAN_QUERY_RESULT);
1703:                } catch (SourceJammerConnectionException ex) {
1704:                    throw new SourceJammerConnectionException(
1705:                            DisplayTextLibrary
1706:                                    .displayText(DisplayTextLibrary.ERR_CONNECTION),
1707:                            ex);
1708:                }
1709:            }
1710:
1711:            public boolean checkDeletedNodeShareStatus(long projectID,
1712:                    int itemIndex) throws SourceJammerConnectionException,
1713:                    GUICommandException {
1714:                boolean containsShares = false;
1715:                try {
1716:                    SJRequest request = getBaseRequest();
1717:                    request.putLong(REQUESTED_NODE_UNIQUE_ID, projectID);
1718:                    request.putInt(VERSION_NUMBER, itemIndex);
1719:                    SJResponse response = sendRequest(
1720:                            request,
1721:                            SOAPPortal.MCPMethodNames.CHECK_DELETED_NODE_SHARE_STATUS);
1722:                    if (response.getErrorEncountered()) {
1723:                        throw new GUICommandException(response.getMessage());
1724:                    }
1725:                    if (response.booleanValue(IS_CHECKED_OUT)) {
1726:                        //The node is a shared file that's checked out or a project that
1727:                        //contains a shared file that's checked out. Either way, it can't be
1728:                        //deleted, so we'll error out here.
1729:                        throw new GUICommandException(
1730:                                DisplayTextLibrary
1731:                                        .displayText(DisplayTextLibrary.ERR_CANT_DELETE_CHECKED_OUT));
1732:                    }
1733:                    containsShares = response.booleanValue(IS_SHARED);
1734:                } catch (SourceJammerConnectionException ex) {
1735:                    throw new SourceJammerConnectionException(
1736:                            DisplayTextLibrary
1737:                                    .displayText(DisplayTextLibrary.ERR_CONNECTION),
1738:                            ex);
1739:                }
1740:                return containsShares;
1741:            }
1742:
1743:            public void removeProjectAndAllShares(long projectID)
1744:                    throws SourceJammerConnectionException, GUICommandException {
1745:                try {
1746:                    SJRequest request = getBaseRequest();
1747:                    request.putLong(REQUESTED_NODE_UNIQUE_ID, projectID);
1748:                    SJResponse response = sendRequest(request,
1749:                            SOAPPortal.MCPMethodNames.REMOVE_PROJECT);
1750:                    if (response.getErrorEncountered()) {
1751:                        throw new GUICommandException(response.getMessage());
1752:                    }
1753:                    printServerMessage(response.getMessage());
1754:                } catch (SourceJammerConnectionException ex) {
1755:                    throw new SourceJammerConnectionException(
1756:                            DisplayTextLibrary
1757:                                    .displayText(DisplayTextLibrary.ERR_CONNECTION),
1758:                            ex);
1759:                }
1760:            }
1761:
1762:            public void removeProjectFromParent(long projectID, long parentID)
1763:                    throws SourceJammerConnectionException, GUICommandException {
1764:                try {
1765:                    SJRequest request = getBaseRequest();
1766:                    request.putLong(PARENT_NODE_UNIQUE_ID, parentID);
1767:                    request.putLong(REQUESTED_NODE_UNIQUE_ID, projectID);
1768:                    SJResponse response = sendRequest(request,
1769:                            SOAPPortal.MCPMethodNames.REMOVE_PROJECT);
1770:                    if (response.getErrorEncountered()) {
1771:                        throw new GUICommandException(response.getMessage());
1772:                    }
1773:                    printServerMessage(response.getMessage());
1774:                } catch (SourceJammerConnectionException ex) {
1775:                    throw new SourceJammerConnectionException(
1776:                            DisplayTextLibrary
1777:                                    .displayText(DisplayTextLibrary.ERR_CONNECTION),
1778:                            ex);
1779:                }
1780:            }
1781:
1782:            public void removeAllSharesOfFile(NodeInfo flInfo, SJRequest request)
1783:                    throws SourceJammerConnectionException, GUICommandException {
1784:                try {
1785:                    if (request == null) {
1786:                        request = getBaseRequest();
1787:                    }
1788:                    request.putLong(REQUESTED_NODE_UNIQUE_ID, flInfo
1789:                            .getUniqueID());
1790:
1791:                    SourceJammerClient
1792:                            .getInstance()
1793:                            .getFileListeners()
1794:                            .notifyFileRemoved(request,
1795:                                    "removeAllSharesOfFile",
1796:                                    EventTimingType.BEFORE_REQUEST_SENT, flInfo);
1797:
1798:                    SJResponse response = sendRequest(request,
1799:                            SOAPPortal.MCPMethodNames.REMOVE_FILE);
1800:
1801:                    SourceJammerClient.getInstance().getFileListeners()
1802:                            .notifyFileRemoved(request, response,
1803:                                    EventTimingType.AFTER_RESPONSE_RECEIVED,
1804:                                    flInfo);
1805:
1806:                    if (response.getErrorEncountered()) {
1807:                        throw new GUICommandException(response.getMessage());
1808:                    }
1809:                    printServerMessage(response.getMessage());
1810:                } catch (SourceJammerConnectionException ex) {
1811:                    throw new SourceJammerConnectionException(
1812:                            DisplayTextLibrary
1813:                                    .displayText(DisplayTextLibrary.ERR_CONNECTION),
1814:                            ex);
1815:                }
1816:            }
1817:
1818:            public void removeFileFromParent(NodeInfo flInfo, long parentID,
1819:                    SJRequest request) throws SourceJammerConnectionException,
1820:                    GUICommandException {
1821:                try {
1822:                    if (request == null) {
1823:                        request = getBaseRequest();
1824:                    }
1825:                    request.putLong(PARENT_NODE_UNIQUE_ID, parentID);
1826:                    request.putLong(REQUESTED_NODE_UNIQUE_ID, flInfo
1827:                            .getUniqueID());
1828:
1829:                    SourceJammerClient
1830:                            .getInstance()
1831:                            .getFileListeners()
1832:                            .notifyFileRemoved(request,
1833:                                    SOAPPortal.MCPMethodNames.REMOVE_FILE,
1834:                                    EventTimingType.BEFORE_REQUEST_SENT, flInfo);
1835:
1836:                    SJResponse response = sendRequest(request,
1837:                            SOAPPortal.MCPMethodNames.REMOVE_FILE);
1838:
1839:                    SourceJammerClient.getInstance().getFileListeners()
1840:                            .notifyFileRemoved(request, response,
1841:                                    EventTimingType.AFTER_RESPONSE_RECEIVED,
1842:                                    flInfo);
1843:
1844:                    if (response.getErrorEncountered()) {
1845:                        throw new GUICommandException(response.getMessage());
1846:                    }
1847:                    printServerMessage(response.getMessage());
1848:                } catch (SourceJammerConnectionException ex) {
1849:                    throw new SourceJammerConnectionException(
1850:                            DisplayTextLibrary
1851:                                    .displayText(DisplayTextLibrary.ERR_CONNECTION),
1852:                            ex);
1853:                }
1854:            }
1855:
1856:            public RemovedItem[] viewRemoved(long projectID)
1857:                    throws SourceJammerConnectionException, GUICommandException {
1858:                RemovedItem[] oaRemoved = null;
1859:                try {
1860:                    SJRequest request = getBaseRequest();
1861:                    request.putLong(REQUESTED_NODE_UNIQUE_ID, projectID);
1862:                    SJResponse response = sendRequest(request,
1863:                            SOAPPortal.MCPMethodNames.VIEW_REMOVED_NODES);
1864:                    if (response.getErrorEncountered()) {
1865:                        throw new GUICommandException(response.getMessage());
1866:                    }
1867:                    Object[] nodes = (Object[]) response
1868:                            .objectValue(OBJECT_ARRAY);
1869:                    oaRemoved = new RemovedItem[nodes.length];
1870:                    for (int iCounter = 0; iCounter < nodes.length; iCounter++) {
1871:                        NodeInfo ndRem = (NodeInfo) nodes[iCounter];
1872:                        oaRemoved[iCounter] = new RemovedItem();
1873:                        oaRemoved[iCounter].setNumber(iCounter);
1874:                        oaRemoved[iCounter].setName(ndRem.getNodeName());
1875:                        oaRemoved[iCounter].setNodeType(ndRem.getNodeType());
1876:                    }
1877:                } catch (SourceJammerConnectionException ex) {
1878:                    throw new SourceJammerConnectionException(
1879:                            DisplayTextLibrary
1880:                                    .displayText(DisplayTextLibrary.ERR_CONNECTION),
1881:                            ex);
1882:                }
1883:                return oaRemoved;
1884:            }
1885:
1886:            public void restoreRemoved(long parentID, int iItemNumber,
1887:                    String newName) {
1888:                try {
1889:                    SJRequest request = getBaseRequest();
1890:                    request.putLong(REQUESTED_NODE_UNIQUE_ID, parentID);
1891:                    request.putInt(VERSION_NUMBER, iItemNumber);
1892:                    if (newName != null) {
1893:                        request.putString(REQUESTED_NODE_NAME, newName);
1894:                    }
1895:                    SJResponse response = moPortal.sendRequest(request,
1896:                            SOAPPortal.MCPMethodNames.RESTORE_REMOVED_NODE);
1897:                    if (response.getErrorEncountered()) {
1898:                        throw new Exception(response.getMessage());
1899:                    }
1900:                    printServerMessage(response.getMessage());
1901:                } catch (SourceJammerConnectionException ex) {
1902:                    MessageBoxUtil.displayErrorMessage(DisplayTextLibrary
1903:                            .displayText(DisplayTextLibrary.ERR_CONNECTION));
1904:                } catch (Exception ex) {
1905:                    MessageBoxUtil.displayErrorMessage(ex.getMessage());
1906:                }
1907:            }
1908:
1909:            public void deleteRemoved(long lParentID, int iItemNumber)
1910:                    throws SourceJammerConnectionException, GUICommandException {
1911:                deleteRemoved(lParentID, iItemNumber, false);
1912:            }
1913:
1914:            public void deleteRemoved(long lParentID, int iItemNumber,
1915:                    boolean deleteAllShares)
1916:                    throws SourceJammerConnectionException, GUICommandException {
1917:                try {
1918:                    SJRequest request = getBaseRequest();
1919:                    request.putLong(REQUESTED_NODE_UNIQUE_ID, lParentID);
1920:                    request.putInt(VERSION_NUMBER, iItemNumber);
1921:                    request.putBoolean(RECURSIVE, deleteAllShares);
1922:                    SJResponse response = sendRequest(request,
1923:                            SOAPPortal.MCPMethodNames.PERMANENTLY_DELETE_NODE);
1924:                    if (response.getErrorEncountered()) {
1925:                        throw new GUICommandException(response.getMessage());
1926:                    }
1927:                    printServerMessage(response.getMessage());
1928:                } catch (SourceJammerConnectionException ex) {
1929:                    ex.printStackTrace(out);
1930:                    throw new SourceJammerConnectionException(
1931:                            DisplayTextLibrary
1932:                                    .displayText(DisplayTextLibrary.ERR_CONNECTION),
1933:                            ex);
1934:                }
1935:            }
1936:
1937:            public void makeUser(String sUserName, String sPassword,
1938:                    String sFullName) throws GUICommandException,
1939:                    SourceJammerConnectionException {
1940:                try {
1941:                    SJRequest request = getBaseRequest();
1942:                    request.putString(NEW_USER_NAME, sUserName);
1943:                    request.putString(NEW_USER_PASSWORD, sPassword);
1944:                    request.putString(NEW_USER_FULL_NAME, sFullName);
1945:                    SJResponse response = sendRequest(request,
1946:                            SOAPPortal.MCPMethodNames.ADD_USER);
1947:                    if (response.getErrorEncountered()) {
1948:                        throw new GUICommandException(response.getMessage());
1949:                    }
1950:                    printServerMessage(response.getMessage());
1951:                } catch (SourceJammerConnectionException ex) {
1952:                    ex.printStackTrace();
1953:                    throw new SourceJammerConnectionException(
1954:                            DisplayTextLibrary
1955:                                    .displayText(DisplayTextLibrary.ERR_CONNECTION),
1956:                            ex);
1957:                }
1958:            }
1959:
1960:            public void removeUser(String sUserName)
1961:                    throws GUICommandException, SourceJammerConnectionException {
1962:                try {
1963:                    SJRequest request = getBaseRequest();
1964:                    request.putString(NEW_USER_NAME, sUserName);
1965:                    SJResponse response = sendRequest(request,
1966:                            SOAPPortal.MCPMethodNames.REMOVE_USER);
1967:                    if (response.getErrorEncountered()) {
1968:                        throw new GUICommandException(response.getMessage());
1969:                    }
1970:                    printServerMessage(response.getMessage());
1971:                } catch (SourceJammerConnectionException ex) {
1972:                    ex.printStackTrace();
1973:                    throw new SourceJammerConnectionException(
1974:                            DisplayTextLibrary
1975:                                    .displayText(DisplayTextLibrary.ERR_CONNECTION),
1976:                            ex);
1977:                }
1978:            }
1979:
1980:            public void changePassword(String sPassword)
1981:                    throws SourceJammerConnectionException, GUICommandException {
1982:                try {
1983:                    SJRequest request = getBaseRequest();
1984:                    request.putString(NEW_USER_PASSWORD, sPassword);
1985:                    SJResponse response = sendRequest(request,
1986:                            SOAPPortal.MCPMethodNames.CHANGE_PASSWORD);
1987:                    if (response.getErrorEncountered()) {
1988:                        throw new GUICommandException(response.getMessage());
1989:                    }
1990:                    printServerMessage(response.getMessage());
1991:                } catch (SourceJammerConnectionException ex) {
1992:                    throw new SourceJammerConnectionException(
1993:                            DisplayTextLibrary
1994:                                    .displayText(DisplayTextLibrary.ERR_CONNECTION),
1995:                            ex);
1996:                }
1997:            }
1998:
1999:            public void changePassword(String sPassword, String userName)
2000:                    throws SourceJammerConnectionException, GUICommandException {
2001:                try {
2002:                    SJRequest request = getBaseRequest();
2003:                    request.putString(NEW_USER_PASSWORD, sPassword);
2004:                    request.putString(NEW_USER_NAME, userName);
2005:                    SJResponse response = sendRequest(request,
2006:                            SOAPPortal.MCPMethodNames.CHANGE_PASSWORD);
2007:                    if (response.getErrorEncountered()) {
2008:                        throw new GUICommandException(response.getMessage());
2009:                    }
2010:                    printServerMessage(response.getMessage());
2011:                } catch (SourceJammerConnectionException ex) {
2012:                    throw new SourceJammerConnectionException(
2013:                            DisplayTextLibrary
2014:                                    .displayText(DisplayTextLibrary.ERR_CONNECTION),
2015:                            ex);
2016:                }
2017:            }
2018:
2019:            public void makeArchive(String name, int implementation, String path)
2020:                    throws SourceJammerConnectionException, GUICommandException {
2021:                try {
2022:                    SJRequest request = getBaseRequest();
2023:                    Integer intImplementation = null;
2024:                    if (implementation > -1) {
2025:                        intImplementation = new Integer(implementation);
2026:                    }
2027:                    request.putString(NEW_ARCHIVE_NAME, name);
2028:                    if (intImplementation != null) {
2029:                        request.putInt(NEW_ARCHIVE_IMPLEMENTATION,
2030:                                intImplementation.intValue());
2031:                    }
2032:                    if (path != null) {
2033:                        request.putString(NEW_ARCHIVE_ROOT_PATH, path);
2034:                    }
2035:                    SJResponse response = sendRequest(request,
2036:                            SOAPPortal.MCPMethodNames.ADD_ARCHIVE);
2037:                    if (response.getErrorEncountered()) {
2038:                        throw new GUICommandException(response.getMessage());
2039:                    }
2040:                    printServerMessage(response.getMessage());
2041:                } catch (SourceJammerConnectionException ex) {
2042:                    throw new SourceJammerConnectionException(
2043:                            DisplayTextLibrary
2044:                                    .displayText(DisplayTextLibrary.ERR_CONNECTION),
2045:                            ex);
2046:                }
2047:            }
2048:
2049:            public void makeArchiveDisconnected(String userName,
2050:                    String password, String url, String name,
2051:                    int implementation, String path)
2052:                    throws SourceJammerConnectionException,
2053:                    GUICommandException, MalformedURLException,
2054:                    NoSessionException {
2055:                try {
2056:                    SJRequest request = getBaseRequest();
2057:                    request.setUserName(userName);
2058:                    request.setPassword(password);
2059:                    SOAPPortal oLocalPortal = new SOAPPortal();
2060:                    oLocalPortal.setURL(url);
2061:                    SJResponse loginResponse = oLocalPortal.sendRequest(
2062:                            request, SOAPPortal.MCPMethodNames.LOG_IN);
2063:                    SJResponse response = null;
2064:                    if (!loginResponse.getErrorEncountered()) {
2065:                        request.setSessionID(loginResponse.getSessionID());
2066:                        Integer intImplementation = null;
2067:                        if (implementation > -1) {
2068:                            intImplementation = new Integer(implementation);
2069:                        }
2070:                        request.putString(NEW_ARCHIVE_NAME, name);
2071:                        if (intImplementation != null) {
2072:                            request.putInt(NEW_ARCHIVE_IMPLEMENTATION,
2073:                                    intImplementation.intValue());
2074:                        }
2075:                        if (path != null) {
2076:                            request.putString(NEW_ARCHIVE_ROOT_PATH, path);
2077:                        }
2078:                        response = oLocalPortal.sendRequest(request,
2079:                                SOAPPortal.MCPMethodNames.ADD_ARCHIVE);
2080:                        oLocalPortal.sendRequest(request,
2081:                                SOAPPortal.MCPMethodNames.DISCONNECT);
2082:                    } else {
2083:                        response = loginResponse;
2084:                    }
2085:                    if (response.getErrorEncountered()) {
2086:                        throw new GUICommandException(response.getMessage());
2087:                    }
2088:                    printServerMessage(response.getMessage());
2089:                } catch (SourceJammerConnectionException ex) {
2090:                    throw new SourceJammerConnectionException(
2091:                            DisplayTextLibrary
2092:                                    .displayText(DisplayTextLibrary.ERR_CONNECTION),
2093:                            ex);
2094:                }
2095:            }
2096:
2097:            public NodeList getLabelList()
2098:                    throws SourceJammerConnectionException,
2099:                    GUICommandException,
2100:                    org.sourcejammer.project.NodeExistsException {
2101:                NodeList oReturn = null;
2102:                try {
2103:                    SJRequest request = getBaseRequest();
2104:                    SJResponse response = sendRequest(request,
2105:                            SOAPPortal.MCPMethodNames.LABEL_LIST);
2106:                    if (response.getErrorEncountered()) {
2107:                        throw new GUICommandException(response.getMessage());
2108:                    }
2109:                    Object[] obj = (Object[]) response
2110:                            .objectValue(OBJECT_ARRAY);
2111:                    oReturn = new NodeList();
2112:                    if (obj != null) {
2113:                        for (int i = 0; i < obj.length; i++) {
2114:                            oReturn.addNode((Node) obj[i]);
2115:                        }
2116:                    }
2117:                } catch (SourceJammerConnectionException ex) {
2118:                    throw new SourceJammerConnectionException(
2119:                            DisplayTextLibrary
2120:                                    .displayText(DisplayTextLibrary.ERR_CONNECTION),
2121:                            ex);
2122:                }
2123:                return oReturn;
2124:            }
2125:
2126:            public void makeLabel(long labelRootProjectID, String labelName,
2127:                    String description) throws SourceJammerConnectionException,
2128:                    GUICommandException {
2129:                try {
2130:                    SJRequest request = getBaseRequest();
2131:                    request.putLong(REQUESTED_NODE_UNIQUE_ID,
2132:                            labelRootProjectID);
2133:                    request.putString(REQUESTED_NODE_NAME, labelName);
2134:                    request.putString(COMMENT, description);
2135:                    SJResponse response = sendRequest(request,
2136:                            SOAPPortal.MCPMethodNames.MAKE_LABEL);
2137:                    if (response.getErrorEncountered()) {
2138:                        throw new GUICommandException(response.getMessage());
2139:                    }
2140:                    printServerMessage(response.getMessage());
2141:                } catch (SourceJammerConnectionException ex) {
2142:                    throw new SourceJammerConnectionException(
2143:                            DisplayTextLibrary
2144:                                    .displayText(DisplayTextLibrary.ERR_CONNECTION),
2145:                            ex);
2146:                }
2147:            }
2148:
2149:            public void moveFile(NodeInfo flInfo, long fromProjectID,
2150:                    long toProjectID, SJRequest request)
2151:                    throws SourceJammerConnectionException, GUICommandException {
2152:                try {
2153:                    if (request == null) {
2154:                        request = getBaseRequest();
2155:                    }
2156:                    request.putLong(REQUESTED_NODE_UNIQUE_ID, flInfo
2157:                            .getUniqueID());
2158:                    request.putLong(PARENT_NODE_UNIQUE_ID, fromProjectID);
2159:                    request.putLong(NEW_PARENT_NODE_UNIQUE_ID, toProjectID);
2160:
2161:                    SourceJammerClient
2162:                            .getInstance()
2163:                            .getFileListeners()
2164:                            .notifyFileMoveCopy(request, "move",
2165:                                    EventTimingType.BEFORE_REQUEST_SENT, flInfo);
2166:
2167:                    SJResponse response = sendRequest(request,
2168:                            SOAPPortal.MCPMethodNames.MOVE_FILE);
2169:
2170:                    SourceJammerClient.getInstance().getFileListeners()
2171:                            .notifyFileMoveCopy(request, response,
2172:                                    EventTimingType.AFTER_RESPONSE_RECEIVED,
2173:                                    flInfo);
2174:
2175:                    if (response.getErrorEncountered()) {
2176:                        throw new GUICommandException(response.getMessage());
2177:                    }
2178:                    printServerMessage(response.getMessage());
2179:                } catch (SourceJammerConnectionException ex) {
2180:                    throw new SourceJammerConnectionException(
2181:                            DisplayTextLibrary
2182:                                    .displayText(DisplayTextLibrary.ERR_CONNECTION),
2183:                            ex);
2184:                }
2185:            }
2186:
2187:            public void shareFile(NodeInfo flInfo, long toProjectID,
2188:                    SJRequest request) throws SourceJammerConnectionException,
2189:                    GUICommandException {
2190:                try {
2191:                    if (request == null) {
2192:                        request = getBaseRequest();
2193:                    }
2194:                    request.putLong(REQUESTED_NODE_UNIQUE_ID, flInfo
2195:                            .getUniqueID());
2196:                    request.putLong(NEW_PARENT_NODE_UNIQUE_ID, toProjectID);
2197:
2198:                    SourceJammerClient
2199:                            .getInstance()
2200:                            .getFileListeners()
2201:                            .notifyFileShared(request, null,
2202:                                    EventTimingType.BEFORE_REQUEST_SENT, flInfo);
2203:
2204:                    SJResponse response = sendRequest(request,
2205:                            SOAPPortal.MCPMethodNames.SHARE_FILE);
2206:
2207:                    SourceJammerClient.getInstance().getFileListeners()
2208:                            .notifyFileShared(request, response,
2209:                                    EventTimingType.AFTER_RESPONSE_RECEIVED,
2210:                                    flInfo);
2211:
2212:                    if (response.getErrorEncountered()) {
2213:                        throw new GUICommandException(response.getMessage());
2214:                    }
2215:                    printServerMessage(response.getMessage());
2216:                } catch (SourceJammerConnectionException ex) {
2217:                    throw new SourceJammerConnectionException(
2218:                            DisplayTextLibrary
2219:                                    .displayText(DisplayTextLibrary.ERR_CONNECTION),
2220:                            ex);
2221:                }
2222:            }
2223:
2224:            public void shareProject(long projectID, long toProjectID,
2225:                    String newProjectName)
2226:                    throws SourceJammerConnectionException, GUICommandException {
2227:                try {
2228:                    SJRequest request = getBaseRequest();
2229:                    request.putLong(REQUESTED_NODE_UNIQUE_ID, projectID);
2230:                    request.putLong(NEW_PARENT_NODE_UNIQUE_ID, toProjectID);
2231:                    request.putString(REQUESTED_NODE_NAME, newProjectName);
2232:
2233:                    SJResponse response = sendRequest(request,
2234:                            SOAPPortal.MCPMethodNames.SHARE_PROJECT);
2235:                    if (response.getErrorEncountered()) {
2236:                        throw new GUICommandException(response.getMessage());
2237:                    }
2238:                    printServerMessage(response.getMessage());
2239:                } catch (SourceJammerConnectionException ex) {
2240:                    throw new SourceJammerConnectionException(
2241:                            DisplayTextLibrary
2242:                                    .displayText(DisplayTextLibrary.ERR_CONNECTION),
2243:                            ex);
2244:                }
2245:            }
2246:
2247:            public void removeFileShare(NodeInfo flInfo, long fromProjectID,
2248:                    SJRequest request) throws SourceJammerConnectionException,
2249:                    GUICommandException {
2250:                try {
2251:                    if (request == null) {
2252:                        request = getBaseRequest();
2253:                    }
2254:                    request.putLong(REQUESTED_NODE_UNIQUE_ID, flInfo
2255:                            .getUniqueID());
2256:                    request.putLong(PARENT_NODE_UNIQUE_ID, fromProjectID);
2257:
2258:                    SourceJammerClient
2259:                            .getInstance()
2260:                            .getFileListeners()
2261:                            .notifyFileShareRemoved(request, null,
2262:                                    EventTimingType.BEFORE_REQUEST_SENT, flInfo);
2263:
2264:                    SJResponse response = sendRequest(request,
2265:                            SOAPPortal.MCPMethodNames.REMOVE_FILE_SHARE);
2266:
2267:                    SourceJammerClient.getInstance().getFileListeners()
2268:                            .notifyFileShareRemoved(request, response,
2269:                                    EventTimingType.AFTER_RESPONSE_RECEIVED,
2270:                                    flInfo);
2271:
2272:                    if (response.getErrorEncountered()) {
2273:                        throw new GUICommandException(response.getMessage());
2274:                    }
2275:                    printServerMessage(response.getMessage());
2276:                } catch (SourceJammerConnectionException ex) {
2277:                    throw new SourceJammerConnectionException(
2278:                            DisplayTextLibrary
2279:                                    .displayText(DisplayTextLibrary.ERR_CONNECTION),
2280:                            ex);
2281:                }
2282:            }
2283:
2284:            public void removeProjectShare(long projectID)
2285:                    throws SourceJammerConnectionException, GUICommandException {
2286:                try {
2287:                    SJRequest request = getBaseRequest();
2288:                    request.putLong(REQUESTED_NODE_UNIQUE_ID, projectID);
2289:
2290:                    SJResponse response = sendRequest(request,
2291:                            SOAPPortal.MCPMethodNames.REMOVE_PROJECT_SHARE);
2292:                    if (response.getErrorEncountered()) {
2293:                        throw new GUICommandException(response.getMessage());
2294:                    }
2295:                    printServerMessage(response.getMessage());
2296:                } catch (SourceJammerConnectionException ex) {
2297:                    throw new SourceJammerConnectionException(
2298:                            DisplayTextLibrary
2299:                                    .displayText(DisplayTextLibrary.ERR_CONNECTION),
2300:                            ex);
2301:                }
2302:            }
2303:
2304:            public void branchFile(NodeInfo flInfo, long parentProjectID,
2305:                    String comment, String identifier, SJRequest request)
2306:                    throws SourceJammerConnectionException, GUICommandException {
2307:                try {
2308:                    if (request == null) {
2309:                        request = getBaseRequest();
2310:                    }
2311:                    request.putLong(REQUESTED_NODE_UNIQUE_ID, flInfo
2312:                            .getUniqueID());
2313:                    request.putLong(PARENT_NODE_UNIQUE_ID, parentProjectID);
2314:                    request.putString(COMMENT, comment);
2315:                    request.putString(IDENTIFIER, identifier);
2316:
2317:                    SourceJammerClient
2318:                            .getInstance()
2319:                            .getFileListeners()
2320:                            .notifyFileBranched(request, null,
2321:                                    EventTimingType.BEFORE_REQUEST_SENT, flInfo);
2322:
2323:                    SJResponse response = sendRequest(request,
2324:                            SOAPPortal.MCPMethodNames.BRANCH_FILE);
2325:
2326:                    SourceJammerClient.getInstance().getFileListeners()
2327:                            .notifyFileBranched(request, null,
2328:                                    EventTimingType.AFTER_RESPONSE_RECEIVED,
2329:                                    flInfo);
2330:
2331:                    if (response.getErrorEncountered()) {
2332:                        throw new GUICommandException(response.getMessage());
2333:                    }
2334:                    printServerMessage(response.getMessage());
2335:                } catch (SourceJammerConnectionException ex) {
2336:                    throw new SourceJammerConnectionException(
2337:                            DisplayTextLibrary
2338:                                    .displayText(DisplayTextLibrary.ERR_CONNECTION),
2339:                            ex);
2340:                }
2341:            }
2342:
2343:            public void branchProject(long projectID, String comment,
2344:                    String identifier) throws SourceJammerConnectionException,
2345:                    GUICommandException {
2346:                try {
2347:                    SJRequest request = getBaseRequest();
2348:                    request.putLong(REQUESTED_NODE_UNIQUE_ID, projectID);
2349:                    request.putString(COMMENT, comment);
2350:                    request.putString(IDENTIFIER, identifier);
2351:
2352:                    SJResponse response = sendRequest(request,
2353:                            SOAPPortal.MCPMethodNames.BRANCH_PROJECT);
2354:                    if (response.getErrorEncountered()) {
2355:                        throw new GUICommandException(response.getMessage());
2356:                    }
2357:                    printServerMessage(response.getMessage());
2358:                } catch (SourceJammerConnectionException ex) {
2359:                    throw new SourceJammerConnectionException(
2360:                            DisplayTextLibrary
2361:                                    .displayText(DisplayTextLibrary.ERR_CONNECTION),
2362:                            ex);
2363:                }
2364:            }
2365:
2366:            public void copyFile(NodeInfo flInfo, long fromProjectID,
2367:                    long toProjectID, SJRequest request)
2368:                    throws SourceJammerConnectionException, GUICommandException {
2369:                try {
2370:                    if (request == null) {
2371:                        request = getBaseRequest();
2372:                    }
2373:                    request.putLong(REQUESTED_NODE_UNIQUE_ID, flInfo
2374:                            .getUniqueID());
2375:                    request.putLong(PARENT_NODE_UNIQUE_ID, fromProjectID);
2376:                    request.putLong(NEW_PARENT_NODE_UNIQUE_ID, toProjectID);
2377:
2378:                    SourceJammerClient
2379:                            .getInstance()
2380:                            .getFileListeners()
2381:                            .notifyFileMoveCopy(request, "copy",
2382:                                    EventTimingType.BEFORE_REQUEST_SENT, flInfo);
2383:
2384:                    SJResponse response = sendRequest(request,
2385:                            SOAPPortal.MCPMethodNames.COPY_FILE);
2386:
2387:                    SourceJammerClient.getInstance().getFileListeners()
2388:                            .notifyFileMoveCopy(request, response,
2389:                                    EventTimingType.AFTER_RESPONSE_RECEIVED,
2390:                                    flInfo);
2391:
2392:                    if (response.getErrorEncountered()) {
2393:                        throw new GUICommandException(response.getMessage());
2394:                    }
2395:                    printServerMessage(response.getMessage());
2396:                } catch (SourceJammerConnectionException ex) {
2397:                    throw new SourceJammerConnectionException(
2398:                            DisplayTextLibrary
2399:                                    .displayText(DisplayTextLibrary.ERR_CONNECTION),
2400:                            ex);
2401:                }
2402:            }
2403:
2404:            public void copyProject(long projectID, long toProjectID,
2405:                    String newProjectName)
2406:                    throws SourceJammerConnectionException, GUICommandException {
2407:                try {
2408:                    SJRequest request = getBaseRequest();
2409:                    request.putLong(REQUESTED_NODE_UNIQUE_ID, projectID);
2410:                    request.putLong(NEW_PARENT_NODE_UNIQUE_ID, toProjectID);
2411:                    request.putString(REQUESTED_NODE_NAME, newProjectName);
2412:
2413:                    SJResponse response = sendRequest(request,
2414:                            SOAPPortal.MCPMethodNames.COPY_PROJECT);
2415:                    if (response.getErrorEncountered()) {
2416:                        throw new GUICommandException(response.getMessage());
2417:                    }
2418:                    printServerMessage(response.getMessage());
2419:                } catch (SourceJammerConnectionException ex) {
2420:                    throw new SourceJammerConnectionException(
2421:                            DisplayTextLibrary
2422:                                    .displayText(DisplayTextLibrary.ERR_CONNECTION),
2423:                            ex);
2424:                }
2425:            }
2426:
2427:            public void moveProject(long projectID, long toProjectID,
2428:                    String newProjectName)
2429:                    throws SourceJammerConnectionException, GUICommandException {
2430:                try {
2431:                    SJRequest request = getBaseRequest();
2432:                    request.putLong(REQUESTED_NODE_UNIQUE_ID, projectID);
2433:                    request.putLong(NEW_PARENT_NODE_UNIQUE_ID, toProjectID);
2434:                    request.putString(REQUESTED_NODE_NAME, newProjectName);
2435:
2436:                    SJResponse response = sendRequest(request,
2437:                            SOAPPortal.MCPMethodNames.MOVE_PROJECT);
2438:                    if (response.getErrorEncountered()) {
2439:                        throw new GUICommandException(response.getMessage());
2440:                    }
2441:                    printServerMessage(response.getMessage());
2442:                } catch (SourceJammerConnectionException ex) {
2443:                    throw new SourceJammerConnectionException(
2444:                            DisplayTextLibrary
2445:                                    .displayText(DisplayTextLibrary.ERR_CONNECTION),
2446:                            ex);
2447:                }
2448:            }
2449:
2450:            /**
2451:             * Gets all of the file version in the specified label from the server and
2452:             * writes them to the specified directory (building subdirectories if required and
2453:             * allowed).
2454:             */
2455:            /*
2456:            public void getLabel(String labelName, java.io.File flToDirectory, boolean bBuildSubDirs)
2457:                  throws SourceJammerConnectionException, GUICommandException, IOException {
2458:              int iEOL = getClientDefaultEOLType();
2459:              getLabel(labelName, flToDirectory, bBuildSubDirs, iEOL);
2460:            }
2461:             */
2462:
2463:            /**
2464:             * Rebuild the specified label.
2465:             */
2466:            public void rebuildLabel(long labelId, long parentProjectID,
2467:                    String comment, boolean buildChangeList)
2468:                    throws SourceJammerConnectionException,
2469:                    GUICommandException, IOException {
2470:                try {
2471:                    SJRequest request = getBaseRequest();
2472:                    request.putLong(REQUESTED_NODE_UNIQUE_ID, labelId);
2473:                    request.putString(COMMENT, comment);
2474:                    request.putLong(PARENT_NODE_UNIQUE_ID, parentProjectID);
2475:                    request.putBoolean(IS_BUILD_CHANGELIST, buildChangeList);
2476:                    SJResponse response = sendRequest(request,
2477:                            SOAPPortal.MCPMethodNames.REBUILD_LABEL);
2478:                    if (response.getErrorEncountered()) {
2479:                        throw new GUICommandException(response.getMessage());
2480:                    }
2481:                    printServerMessage(response.getMessage());
2482:                } catch (SourceJammerConnectionException ex) {
2483:                    throw new SourceJammerConnectionException(
2484:                            DisplayTextLibrary
2485:                                    .displayText(DisplayTextLibrary.ERR_CONNECTION),
2486:                            ex);
2487:                }
2488:            }
2489:
2490:            /**
2491:             * Gets all of the file version in the specified label from the server and
2492:             * writes them to the specified directory (building subdirectories if required and
2493:             * allowed).
2494:             */
2495:            public void getLabel(long labelID, int verNumber,
2496:                    java.io.File flToDirectory, boolean bBuildSubDirs,
2497:                    int eolType, boolean setReadOnly,
2498:                    RepeatingResponse repeating)
2499:                    throws SourceJammerConnectionException,
2500:                    GUICommandException, IOException {
2501:                try {
2502:                    SJRequest request = getBaseRequest();
2503:                    request.putLong(REQUESTED_NODE_UNIQUE_ID, labelID);
2504:                    request.putInt(VERSION_NUMBER, verNumber);
2505:                    SJResponse response = sendRequest(request,
2506:                            SOAPPortal.MCPMethodNames.GET_LABEL);
2507:
2508:                    //Now we need to get all the files in the label.
2509:                    if (response.getErrorEncountered()) {
2510:                        throw new GUICommandException(response.getMessage());
2511:                    }
2512:                    long lRootProjectID = response.longValue(NODE_UNIQUE_ID);
2513:
2514:                    String sBasePath = "";
2515:
2516:                    Object[] versionMappings = (Object[]) response
2517:                            .objectValue(OBJECT_ARRAY);
2518:                    for (int i = 0; i < versionMappings.length; i++) {
2519:                        LabelVersionMappingBean bnVersion = (LabelVersionMappingBean) versionMappings[i];
2520:                        //The path below is actually relative to the root project.
2521:                        String sSJPath = bnVersion.getFullPathToFile();
2522:                        long lFileID = bnVersion.getFileUniqueID();
2523:                        int iVersion = bnVersion.getVersionNumber();
2524:                        long lVersionID = bnVersion.getVersionUniqueID();
2525:
2526:                        int iLastSwitch = sSJPath.lastIndexOf(AppConfig
2527:                                .getInstance().getSourceJammerSwitch());
2528:                        String sParent = sSJPath.substring(0, iLastSwitch);
2529:                        String sFileName = sSJPath.substring(iLastSwitch + 1);
2530:
2531:                        java.io.File flTargetDir = new java.io.File(
2532:                                flToDirectory, sParent);
2533:                        if (!flTargetDir.exists() && bBuildSubDirs) {
2534:                            flTargetDir.mkdirs();
2535:                            out
2536:                                    .println(DisplayTextLibrary
2537:                                            .displayText(DisplayTextLibrary.LBL_MAKING_DIR)
2538:                                            + flTargetDir.getAbsolutePath());
2539:                        }
2540:                        if (flTargetDir.exists() && flTargetDir.isDirectory()) {
2541:                            NodeInfo nd = new NodeInfo();
2542:                            nd.setUniqueID(lFileID);
2543:                            nd.setNodeName(sFileName);
2544:                            getFileVersionFromServer(nd, iVersion, eolType,
2545:                                    lVersionID, flTargetDir, setReadOnly,
2546:                                    repeating, null);
2547:                        } else {
2548:                            out
2549:                                    .println(DisplayTextLibrary
2550:                                            .displayText(DisplayTextLibrary.LBL_DIR_NOT_EXIST)
2551:                                            + flTargetDir.getAbsoluteFile());
2552:                            out
2553:                                    .println(DisplayTextLibrary
2554:                                            .displayText(DisplayTextLibrary.LBL_SKIPPING_PROJ)
2555:                                            + sParent);
2556:                        }
2557:
2558:                    }//end for
2559:                } catch (SourceJammerConnectionException ex) {
2560:                    throw new SourceJammerConnectionException(
2561:                            DisplayTextLibrary
2562:                                    .displayText(DisplayTextLibrary.ERR_CONNECTION),
2563:                            ex);
2564:                }
2565:            }
2566:
2567:            public UserInfo[] getCompleteUserList()
2568:                    throws SourceJammerConnectionException, GUICommandException {
2569:
2570:                UserInfo[] users = getUsers(SOAPPortal.MCPMethodNames.GET_COMPLETE_USER_LIST);
2571:                return users;
2572:            }
2573:
2574:            public ArchiveProperties getArchiveProperties()
2575:                    throws GUICommandException, SourceJammerConnectionException {
2576:                ArchiveProperties props = null;
2577:                try {
2578:                    SJRequest request = getBaseRequest();
2579:                    SJResponse response = sendRequest(request,
2580:                            SOAPPortal.MCPMethodNames.GET_ARCHIVE_PROPS);
2581:                    if (response.getErrorEncountered()) {
2582:                        throw new GUICommandException(response.getMessage());
2583:                    }
2584:                    props = response.archivePropertiesValue();
2585:                } catch (SourceJammerConnectionException ex) {
2586:                    ex.printStackTrace();
2587:                    throw new SourceJammerConnectionException(
2588:                            DisplayTextLibrary
2589:                                    .displayText(DisplayTextLibrary.ERR_CONNECTION),
2590:                            ex);
2591:                }
2592:                return props;
2593:            }
2594:
2595:            public void setArchiveProperties(ArchiveProperties props)
2596:                    throws GUICommandException, SourceJammerConnectionException {
2597:                try {
2598:                    SJRequest request = getBaseRequest();
2599:                    request.putObject(ARCHIVE_PROPERTIES, props);
2600:                    SJResponse response = sendRequest(request,
2601:                            SOAPPortal.MCPMethodNames.SET_ARCHIVE_PROPS);
2602:                    if (response.getErrorEncountered()) {
2603:                        throw new GUICommandException(response.getMessage());
2604:                    }
2605:                    printServerMessage(response.getMessage());
2606:                } catch (SourceJammerConnectionException ex) {
2607:                    ex.printStackTrace();
2608:                    throw new SourceJammerConnectionException(
2609:                            DisplayTextLibrary
2610:                                    .displayText(DisplayTextLibrary.ERR_CONNECTION),
2611:                            ex);
2612:                }
2613:            }
2614:
2615:            public UserInfo[] getArchiveControllerList()
2616:                    throws SourceJammerConnectionException, GUICommandException {
2617:
2618:                UserInfo[] users = getUsers(SOAPPortal.MCPMethodNames.GET_CONTROLLER_USER_LIST);
2619:                return users;
2620:            }
2621:
2622:            public UserInfo[] getArchiveUserList()
2623:                    throws SourceJammerConnectionException, GUICommandException {
2624:
2625:                UserInfo[] users = getUsers(SOAPPortal.MCPMethodNames.GET_ARCHIVE_USER_LIST);
2626:                return users;
2627:            }
2628:
2629:            private UserInfo[] getUsers(String type)
2630:                    throws SourceJammerConnectionException, GUICommandException {
2631:
2632:                UserInfo[] users = null;
2633:                try {
2634:                    SJRequest request = getBaseRequest();
2635:                    SJResponse response = sendRequest(request, type);
2636:                    if (response.getErrorEncountered()) {
2637:                        throw new GUICommandException(response.getMessage());
2638:                    }
2639:                    Object[] o = (Object[]) response.objectValue(OBJECT_ARRAY);
2640:                    users = new UserInfo[o.length];
2641:                    for (int i = 0; i < o.length; i++) {
2642:                        users[i] = (UserInfo) o[i];
2643:                    }
2644:                } catch (SourceJammerConnectionException ex) {
2645:                    ex.printStackTrace();
2646:                    throw new SourceJammerConnectionException(
2647:                            DisplayTextLibrary
2648:                                    .displayText(DisplayTextLibrary.ERR_CONNECTION),
2649:                            ex);
2650:                }
2651:                return users;
2652:            }
2653:
2654:            public String getCurrentUserName() {
2655:                return msUserName;
2656:            }
2657:
2658:            public void setUserAdminStatus(String userName, boolean status)
2659:                    throws SourceJammerConnectionException, GUICommandException {
2660:                try {
2661:                    SJRequest request = getBaseRequest();
2662:                    request.putString(NEW_USER_NAME, userName);
2663:                    request.putBoolean(NEW_USER_ADMIN, status);
2664:                    SJResponse response = sendRequest(request,
2665:                            SOAPPortal.MCPMethodNames.SET_USER_ADMIN_STATUS);
2666:                    if (response.getErrorEncountered()) {
2667:                        throw new GUICommandException(response.getMessage());
2668:                    }
2669:                    printServerMessage(response.getMessage());
2670:                } catch (SourceJammerConnectionException ex) {
2671:                    ex.printStackTrace();
2672:                    throw new SourceJammerConnectionException(
2673:                            DisplayTextLibrary
2674:                                    .displayText(DisplayTextLibrary.ERR_CONNECTION),
2675:                            ex);
2676:                }
2677:            }
2678:
2679:            public void addUserToArchiveControllers(String userName)
2680:                    throws SourceJammerConnectionException, GUICommandException {
2681:                try {
2682:                    SJRequest request = getBaseRequest();
2683:                    request.putString(NEW_USER_NAME, userName);
2684:                    SJResponse response = sendRequest(
2685:                            request,
2686:                            SOAPPortal.MCPMethodNames.ADD_USER_TO_ARCHIVE_CONTROLLERS);
2687:                    if (response.getErrorEncountered()) {
2688:                        throw new GUICommandException(response.getMessage());
2689:                    }
2690:                    printServerMessage(response.getMessage());
2691:                } catch (SourceJammerConnectionException ex) {
2692:                    ex.printStackTrace();
2693:                    throw new SourceJammerConnectionException(
2694:                            DisplayTextLibrary
2695:                                    .displayText(DisplayTextLibrary.ERR_CONNECTION),
2696:                            ex);
2697:                }
2698:            }
2699:
2700:            public void addUserToArchiveUsers(String userName)
2701:                    throws SourceJammerConnectionException, GUICommandException {
2702:                try {
2703:                    SJRequest request = getBaseRequest();
2704:                    request.putString(NEW_USER_NAME, userName);
2705:                    SJResponse response = sendRequest(request,
2706:                            SOAPPortal.MCPMethodNames.ADD_USER_TO_ARCHIVE_USERS);
2707:                    if (response.getErrorEncountered()) {
2708:                        throw new GUICommandException(response.getMessage());
2709:                    }
2710:                    printServerMessage(response.getMessage());
2711:                } catch (SourceJammerConnectionException ex) {
2712:                    ex.printStackTrace();
2713:                    throw new SourceJammerConnectionException(
2714:                            DisplayTextLibrary
2715:                                    .displayText(DisplayTextLibrary.ERR_CONNECTION),
2716:                            ex);
2717:                }
2718:            }
2719:
2720:            public void removeUserFromArchiveControllers(String userName)
2721:                    throws SourceJammerConnectionException, GUICommandException {
2722:                try {
2723:                    SJRequest request = getBaseRequest();
2724:                    request.putString(NEW_USER_NAME, userName);
2725:                    SJResponse response = sendRequest(
2726:                            request,
2727:                            SOAPPortal.MCPMethodNames.REMOVE_USER_FROM_ARCHIVE_CONTROLLERS);
2728:                    if (response.getErrorEncountered()) {
2729:                        throw new GUICommandException(response.getMessage());
2730:                    }
2731:                    printServerMessage(response.getMessage());
2732:                } catch (SourceJammerConnectionException ex) {
2733:                    ex.printStackTrace();
2734:                    throw new SourceJammerConnectionException(
2735:                            DisplayTextLibrary
2736:                                    .displayText(DisplayTextLibrary.ERR_CONNECTION),
2737:                            ex);
2738:                }
2739:            }
2740:
2741:            public void removeUserFromArchiveUsers(String userName)
2742:                    throws SourceJammerConnectionException, GUICommandException {
2743:                try {
2744:                    SJRequest request = getBaseRequest();
2745:                    request.putString(NEW_USER_NAME, userName);
2746:                    SJResponse response = sendRequest(
2747:                            request,
2748:                            SOAPPortal.MCPMethodNames.REMOVE_USER_FROM_ARCHIVE_USERS);
2749:                    if (response.getErrorEncountered()) {
2750:                        throw new GUICommandException(response.getMessage());
2751:                    }
2752:                    printServerMessage(response.getMessage());
2753:                } catch (SourceJammerConnectionException ex) {
2754:                    ex.printStackTrace();
2755:                    throw new SourceJammerConnectionException(
2756:                            DisplayTextLibrary
2757:                                    .displayText(DisplayTextLibrary.ERR_CONNECTION),
2758:                            ex);
2759:                }
2760:            }
2761:
2762:            /**
2763:             * Rolls back a file in the SourceJammer server to the specified previous
2764:             * version of the file.
2765:             */
2766:            public void rollbackToVersion(NodeInfo flInfo, long versionID,
2767:                    SJRequest request) throws SourceJammerConnectionException,
2768:                    GUICommandException {
2769:                try {
2770:                    if (request == null) {
2771:                        request = getBaseRequest();
2772:                    }
2773:                    request.putLong(REQUESTED_NODE_UNIQUE_ID, versionID);
2774:                    request
2775:                            .putLong(PARENT_NODE_UNIQUE_ID, flInfo
2776:                                    .getUniqueID());
2777:
2778:                    SourceJammerClient
2779:                            .getInstance()
2780:                            .getFileListeners()
2781:                            .notifyFileRolledBack(request, null,
2782:                                    EventTimingType.BEFORE_REQUEST_SENT, flInfo);
2783:
2784:                    SJResponse response = sendRequest(request,
2785:                            SOAPPortal.MCPMethodNames.ROLLBACK_TO_VERSION);
2786:
2787:                    SourceJammerClient.getInstance().getFileListeners()
2788:                            .notifyFileRolledBack(request, response,
2789:                                    EventTimingType.AFTER_RESPONSE_RECEIVED,
2790:                                    flInfo);
2791:
2792:                    if (response.getErrorEncountered()) {
2793:                        throw new GUICommandException(response.getMessage());
2794:                    }
2795:                    printServerMessage(response.getMessage());
2796:                } catch (SourceJammerConnectionException ex) {
2797:                    ex.printStackTrace();
2798:                    throw new SourceJammerConnectionException(
2799:                            DisplayTextLibrary
2800:                                    .displayText(DisplayTextLibrary.ERR_CONNECTION),
2801:                            ex);
2802:                }
2803:            }
2804:
2805:            public boolean isConnected() {
2806:                boolean bReturn = false;
2807:                if (msArchiveName != null) {
2808:                    bReturn = true;
2809:                } else {
2810:                    bReturn = false;
2811:                }
2812:                return bReturn;
2813:            }
2814:
2815:            public SJRequest getBaseRequest() {
2816:                SJRequest request = new SJRequest();
2817:                request.setArchiveName(msArchiveName);
2818:                request.setUserName(msUserName);
2819:                request.setPassword(msPassword);
2820:
2821:                if (mlSessionID != -1) {
2822:                    request.setSessionID(mlSessionID);
2823:                }
2824:                return request;
2825:            }
2826:
2827:            private byte[] readLocalFile(String sFullPathAndName)
2828:                    throws IOException {
2829:
2830:                return FileSysUtil.readLocalFile(sFullPathAndName);
2831:
2832:            }
2833:
2834:            private void makeFileWritable(java.io.File file) throws IOException {
2835:                FileSysUtil.makeFileWritable(file);
2836:            }
2837:
2838:            public SJPrimaryWindow getRootAppFrame() {
2839:                return mjRootAppFrame;
2840:            }
2841:
2842:            public JTree getProjectTree() {
2843:                return mjRootAppFrame.getProjectTree();
2844:            }
2845:
2846:            public JTable getPrimaryTable() {
2847:                return mjRootAppFrame.getPrimaryTable();
2848:            }
2849:
2850:            /**
2851:             * Select the specified project in the project tree.
2852:             */
2853:            public void selectProject(ProjectTreeNode nd) {
2854:                TreePath path = new TreePath(nd.getPath());
2855:                //mjFileExplorer.fireTreeExpanded(path);
2856:                JTree jProjectTree = mjRootAppFrame.getProjectTree();
2857:                jProjectTree.expandPath(path);
2858:                int iRow = jProjectTree.getRowForPath(path);
2859:                jProjectTree.setSelectionRow(iRow);
2860:            }
2861:
2862:            /**
2863:             * Checks if a byte array about to be sent is larger than the minimum
2864:             * unzipped file size. If so, zips the file and sets the flag in the SJRequest.
2865:             */
2866:            protected byte[] zipByteArrayIfNeeded(byte[] file,
2867:                    SJRequest request, String fileName) throws IOException {
2868:                byte[] byReturn = null;
2869:                int iSize = file.length;
2870:                int iMinZipSize = SourceJammerClient.getInstance()
2871:                        .getZipIfLargerThan();
2872:                if (iSize > iMinZipSize && ZipUtil.canZip(fileName)) {
2873:                    byReturn = ZipUtil.zipByteArray(file);
2874:                    request.putBoolean(BINARY_ZIPPED, true);
2875:                }//end if needs to be zipped.
2876:                else {
2877:                    byReturn = file;
2878:                }
2879:                return byReturn;
2880:            }
2881:
2882:            public SourceVersionChecker getChecker(java.io.File flDirectory)
2883:                    throws IOException {
2884:                return new SourceVersionChecker(flDirectory, msURL,
2885:                        msArchiveName);
2886:            }
2887:
2888:            /**
2889:             * Returns temp file id.
2890:             */
2891:            protected long retrieveFileFromServer(DownloadFileIdentifier id,
2892:                    SJResponse response) throws IOException,
2893:                    SourceJammerConnectionException {
2894:                long lTempId = TempDirectoryManager.getNextID();
2895:                java.io.File flTemp = TempDirectoryManager
2896:                        .getNewTempFile(lTempId);
2897:                if (id.getFileSize() < (SourceJammerClient.getInstance()
2898:                        .getMaxFileSendChunkSize())) {
2899:                    FileTransport.downloadFullFileFromServer(id, flTemp, msURL);
2900:                } else {
2901:                    FileTransport.downloadFileFromServer(id, flTemp, msURL);
2902:                }
2903:
2904:                //Unzip if needed.
2905:                if (response.booleanValue(res_BINARY_ZIPPED)) {
2906:                    long lUnzipId = TempDirectoryManager.getNextID();
2907:                    java.io.File flUnzip = TempDirectoryManager
2908:                            .getNewTempFile(lUnzipId);
2909:                    ZipUtil.unzipFileToFile(flTemp, flUnzip);
2910:                    TempDirectoryManager.deleteTempFile(lTempId);
2911:                    lTempId = lUnzipId;
2912:                    flTemp = flUnzip;
2913:                }
2914:                return lTempId;
2915:            }
2916:
2917:            protected long sendFileToServer(java.io.File fl, SJRequest request)
2918:                    throws IOException, SourceJammerConnectionException {
2919:                //First zip file if required.
2920:                java.io.File flSend = null;
2921:                int iSize = (int) fl.length();
2922:                int iMinZipSize = SourceJammerClient.getInstance()
2923:                        .getZipIfLargerThan();
2924:                long lTempID = -1;
2925:                if (iSize > iMinZipSize && ZipUtil.canZip(fl.getName())) {
2926:                    lTempID = TempDirectoryManager.getNextID();
2927:                    java.io.File flZip = TempDirectoryManager
2928:                            .getNewTempFile(lTempID);
2929:                    ZipUtil.zipFileToFile(fl, flZip);
2930:                    flSend = flZip;
2931:                    request.putBoolean(BINARY_ZIPPED, true);
2932:                } else {
2933:                    flSend = fl;
2934:                    request.removeValue(BINARY_ZIPPED);
2935:                }
2936:                long lSendID = -1;
2937:                if (flSend.length() < (SourceJammerClient.getInstance()
2938:                        .getMaxFileSendChunkSize())) {
2939:                    lSendID = FileTransport.sendFullFileToServer(flSend, msURL);
2940:                } else {
2941:                    lSendID = FileTransport.sendFileToServer(flSend, msURL);
2942:                }
2943:                if (request.booleanValue(BINARY_ZIPPED)) {
2944:                    //remove temp file.
2945:                    TempDirectoryManager.deleteTempFile(lTempID);
2946:                }
2947:                return lSendID;
2948:            }
2949:
2950:            /*
2951:            public static void main (String[] args){
2952:              byte[] by1 = {1, 2, 3, 4, 5};
2953:              byte[] by2 = {1, 2, 3, 4, 5};
2954:
2955:              if (by1 == by2){
2956:                System.out.println("Equal.");
2957:              }
2958:              else {
2959:                System.out.println("Not equal.");
2960:              }
2961:            }
2962:             */
2963:            /**
2964:             * Returns the proxyPassword.
2965:             * @return String
2966:             */
2967:            public String getProxyPassword() {
2968:                return proxyPassword;
2969:            }
2970:
2971:            /**
2972:             * Returns the proxyPasswordSet.
2973:             * @return boolean
2974:             */
2975:            public boolean isProxyPasswordSet() {
2976:                return proxyPasswordSet;
2977:            }
2978:
2979:            /**
2980:             * Sets the proxyPassword.
2981:             * @param proxyPassword The proxyPassword to set
2982:             */
2983:            public void setProxyPassword(String proxyPassword) {
2984:                this .proxyPassword = proxyPassword;
2985:            }
2986:
2987:            /**
2988:             * Sets the proxyPasswordSet.
2989:             * @param proxyPasswordSet The proxyPasswordSet to set
2990:             */
2991:            public void setProxyPasswordSet(boolean proxyPasswordSet) {
2992:                this.proxyPasswordSet = proxyPasswordSet;
2993:            }
2994:
2995:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.