Example usage for javax.xml.ws WebServiceException getCause

List of usage examples for javax.xml.ws WebServiceException getCause

Introduction

In this page you can find the example usage for javax.xml.ws WebServiceException getCause.

Prototype

public synchronized Throwable getCause() 

Source Link

Document

Returns the cause of this throwable or null if the cause is nonexistent or unknown.

Usage

From source file:com.docdoku.client.actions.MainController.java

public WorkflowModel saveWorkflowModel(WorkflowModel pWorkflowModel) throws Exception {
    try {/*  www .j a v a2 s .  c om*/
        System.out.println("Saving workflow model " + pWorkflowModel);
        WorkflowModel model;

        //TODO remove and create in the same tx
        try {
            mWorkflowService.deleteWorkflowModel(pWorkflowModel.getKey());
        } catch (WorkflowModelNotFoundException pWNFEx) {
        }
        ActivityModel[] activityModels = pWorkflowModel.getActivityModels()
                .toArray(new ActivityModel[pWorkflowModel.getActivityModels().size()]);
        model = Tools
                .resetParentReferences(mWorkflowService.createWorkflowModel(pWorkflowModel.getWorkspaceId(),
                        pWorkflowModel.getId(), pWorkflowModel.getFinalLifeCycleState(), activityModels));
        MainModel.getInstance().updater.saveWorkflowModel(model);
        return model;
    } catch (WebServiceException pWSEx) {
        Throwable t = pWSEx.getCause();
        if (t instanceof Exception) {
            throw (Exception) t;
        } else {
            throw pWSEx;
        }
    }
}

From source file:com.docdoku.client.actions.MainController.java

public void saveFile(Component pParent, DocumentMasterTemplate pTemplate, File pLocalFile) throws Exception {
    if (!NamingConvention.correct(pLocalFile.getName())) {
        throw new NotAllowedException(Locale.getDefault(), "NotAllowedException9");
    }//ww w  .  j a va 2s  . c o  m
    MainModel model = MainModel.getInstance();
    String message = I18N.BUNDLE.getString("UploadMsg_part1") + " " + pLocalFile.getName() + " ("
            + (int) (pLocalFile.length() / 1024) + I18N.BUNDLE.getString("UploadMsg_part2");
    DataHandler data = new DataHandler(new ProgressMonitorFileDataSource(pParent, pLocalFile, message));
    try {
        Map<String, Object> ctxt = ((BindingProvider) mFileService).getRequestContext();
        try {
            if (ctxt.containsKey(Config.HTTP_CLIENT_STREAMING_CHUNK_SIZE)) {
                mFileService.uploadToTemplate(model.getWorkspace().getId(), pTemplate.getId(),
                        pLocalFile.getName(), data);
            } else {
                //workaround mode
                uploadFileWithServlet(pParent, pLocalFile, getServletURL(pTemplate, pLocalFile));
            }
        } catch (Exception ex) {
            if (ex.getCause() instanceof InterruptedIOException) {
                throw ex;
            }
            //error encountered, try again, workaround mode

            if (ctxt.containsKey(Config.HTTP_CLIENT_STREAMING_CHUNK_SIZE)) {
                System.out.println("Disabling chunked mode");
                ctxt.remove(Config.HTTP_CLIENT_STREAMING_CHUNK_SIZE);
                uploadFileWithServlet(pParent, pLocalFile, getServletURL(pTemplate, pLocalFile));
            } else {
                //we were already not using the chunked mode
                //there's not much to do...
                throw ex;
            }
        }
    } catch (WebServiceException pWSEx) {
        Throwable t = pWSEx.getCause();
        if (t instanceof Exception) {
            throw (Exception) t;
        } else {
            throw pWSEx;
        }
    }
}

From source file:com.docdoku.client.actions.MainController.java

public void saveFile(Component pParent, DocumentIteration pDocument, File pLocalFile) throws Exception {
    if (!NamingConvention.correct(pLocalFile.getName())) {
        throw new NotAllowedException(Locale.getDefault(), "NotAllowedException9");
    }//from   ww  w  . ja v  a2 s. co m
    MainModel model = MainModel.getInstance();
    String message = I18N.BUNDLE.getString("UploadMsg_part1") + " " + pLocalFile.getName() + " ("
            + (int) (pLocalFile.length() / 1024) + I18N.BUNDLE.getString("UploadMsg_part2");
    DataHandler data = new DataHandler(new ProgressMonitorFileDataSource(pParent, pLocalFile, message));
    try {
        Map<String, Object> ctxt = ((BindingProvider) mFileService).getRequestContext();
        try {
            if (ctxt.containsKey(Config.HTTP_CLIENT_STREAMING_CHUNK_SIZE)) {
                mFileService.uploadToDocument(model.getWorkspace().getId(), pDocument.getDocumentMasterId(),
                        pDocument.getDocumentMasterVersion(), pDocument.getIteration(), pLocalFile.getName(),
                        data);
            } else {
                //workaround mode
                uploadFileWithServlet(pParent, pLocalFile, getServletURL(pDocument, pLocalFile));
            }

        } catch (Exception ex) {
            Throwable currentEx = ex;
            while (currentEx != null) {
                if (currentEx instanceof InterruptedIOException)
                    throw ex;
                if (currentEx instanceof ApplicationException)
                    throw ex;

                currentEx = currentEx.getCause();
            }

            //error encountered, try again, workaround mode
            if (ctxt.containsKey(Config.HTTP_CLIENT_STREAMING_CHUNK_SIZE)) {
                System.out.println("Disabling chunked mode");
                ctxt.remove(Config.HTTP_CLIENT_STREAMING_CHUNK_SIZE);
                uploadFileWithServlet(pParent, pLocalFile, getServletURL(pDocument, pLocalFile));
            } else {
                //we were already not using the chunked mode
                //there's not much to do...
                throw ex;
            }
        }
    } catch (WebServiceException pWSEx) {
        Throwable t = pWSEx.getCause();
        if (t instanceof Exception) {
            throw (Exception) t;
        } else {
            throw pWSEx;
        }
    }

}

From source file:com.docdoku.client.data.MainModel.java

public DocumentMaster[] searchDocMs(String pDocMId, String pTitle, Version pVersion, User pAuthor, String pType,
        Date pCreationDateFrom, Date pCreationDateTo, SearchQuery.AbstractAttributeQuery[] pAttributes,
        String[] pTags, String pContent) throws Exception {
    DocumentMaster[] docMs = null;//from www . j  av  a2s.c o  m
    try {
        System.out.println("Searching for document master " + pDocMId + " version " + pVersion + " title "
                + pTitle + " author " + pAuthor + " creation date between " + pCreationDateFrom + " and "
                + pCreationDateTo + " tags " + pTags + " content " + pContent);
        docMs = Tools.resetParentReferences(mDocumentService.searchDocumentMasters(new SearchQuery(
                getWorkspace().getId(), pDocMId, pTitle, pVersion == null ? null : pVersion.toString(),
                pAuthor == null ? null : pAuthor.getLogin(), pType, pCreationDateFrom, pCreationDateTo,
                pAttributes, pTags, pContent)));
        //TODO cache docMs ?
    } catch (WebServiceException pWSEx) {
        Throwable t = pWSEx.getCause();
        if (t instanceof Exception) {
            throw (Exception) t;
        } else {
            throw pWSEx;
        }
    }
    return docMs;
}

From source file:com.docdoku.client.data.MainModel.java

public File getFile(Component pParent, DocumentMasterTemplate pTemplate, BinaryResource pBin) throws Exception {
    File folder = Config.getCacheFolder(pTemplate);
    File localFile = new File(folder, pBin.getName());

    if (!localFile.exists()) {
        MainModel model = MainModel.getInstance();
        folder.mkdirs();//from   w w w  .  j  a v  a2  s  .co  m
        try {
            Map<String, Object> ctxt = ((BindingProvider) mFileService).getRequestContext();
            try {
                if (ctxt.containsKey(Config.HTTP_CLIENT_STREAMING_CHUNK_SIZE)) {
                    DataHandler dh = mFileService.downloadFromTemplate(model.getWorkspace().getId(),
                            pTemplate.getId(), pBin.getName());
                    downloadFile(pParent, localFile, (int) pBin.getContentLength(), dh.getInputStream());
                } else {
                    //workaround mode
                    downloadFileWithServlet(pParent, localFile, getServletURL(pTemplate, pBin.getName()));
                }

            } catch (Exception ex) {
                if (ex.getCause() instanceof InterruptedIOException) {
                    throw ex;
                }
                if (ctxt.containsKey(Config.HTTP_CLIENT_STREAMING_CHUNK_SIZE)) {
                    System.out.println("Disabling chunked mode");
                    ctxt.remove(Config.HTTP_CLIENT_STREAMING_CHUNK_SIZE);
                    downloadFileWithServlet(pParent, localFile, getServletURL(pTemplate, pBin.getName()));
                } else {
                    //we were already not using the chunked mode
                    //there's not much to do...
                    throw ex;
                }
            }
        } catch (WebServiceException pWSEx) {
            Throwable t = pWSEx.getCause();
            if (t instanceof Exception) {
                throw (Exception) t;
            } else {
                throw pWSEx;
            }
        }
        localFile.deleteOnExit();
    }
    return localFile;
}

From source file:com.docdoku.client.data.MainModel.java

public WorkflowModel[] getWorkflowModels() {
    WorkflowModel[] models = mCache.getWorkflowModels();

    if (models == null) {
        try {//w  ww  .  j a v a 2  s.c o  m
            System.out.println("Retrieving workflow models");
            models = Tools.resetParentReferences(mWorkflowService.getWorkflowModels(getWorkspace().getId()));
            mCache.cacheWorkflowModels(models);
        } catch (WebServiceException pWSEx) {
            String message;
            Throwable t = pWSEx.getCause();
            if (t != null) {
                message = t.getMessage() == null ? I18N.BUNDLE.getString("Error_unknown") : t.getMessage();
            } else {
                message = pWSEx.getMessage() == null ? I18N.BUNDLE.getString("Error_unknown")
                        : pWSEx.getMessage();
            }

            showContinueOrExitDialog(message);
        } catch (Exception pEx) {
            String message = pEx.getMessage() == null ? I18N.BUNDLE.getString("Error_unknown")
                    : pEx.getMessage();
            showContinueOrExitDialog(message);
        }
    }
    return models;
}

From source file:com.docdoku.client.data.MainModel.java

public DocumentMasterKey[] getStateChangeEventSubscriptions() {
    DocumentMasterKey[] subKeys = mCache.getStateSubscriptions();

    if (subKeys == null) {
        try {/*w  w  w. j  a v  a 2  s  . co m*/
            System.out.println("Retrieving state subscriptions");
            subKeys = mDocumentService.getStateChangeEventSubscriptions(getWorkspace().getId());
            mCache.cacheStateSubscriptions(subKeys);
        } catch (WebServiceException pWSEx) {
            String message;
            Throwable t = pWSEx.getCause();
            if (t != null) {
                message = t.getMessage() == null ? I18N.BUNDLE.getString("Error_unknown") : t.getMessage();
            } else {
                message = pWSEx.getMessage() == null ? I18N.BUNDLE.getString("Error_unknown")
                        : pWSEx.getMessage();
            }

            showContinueOrExitDialog(message);
        } catch (Exception pEx) {
            String message = pEx.getMessage() == null ? I18N.BUNDLE.getString("Error_unknown")
                    : pEx.getMessage();
            showContinueOrExitDialog(message);
        }
    }
    return subKeys;
}

From source file:com.docdoku.client.data.MainModel.java

public DocumentMasterKey[] getIterationChangeEventSubscriptions() {
    DocumentMasterKey[] subKeys = mCache.getIterationSubscriptions();

    if (subKeys == null) {
        try {// w ww . jav  a2  s  . c  o m
            System.out.println("Retrieving iteration subscriptions");
            subKeys = mDocumentService.getIterationChangeEventSubscriptions(getWorkspace().getId());
            mCache.cacheIterationSubscriptions(subKeys);
        } catch (WebServiceException pWSEx) {
            String message;
            Throwable t = pWSEx.getCause();
            if (t != null) {
                message = t.getMessage() == null ? I18N.BUNDLE.getString("Error_unknown") : t.getMessage();
            } else {
                message = pWSEx.getMessage() == null ? I18N.BUNDLE.getString("Error_unknown")
                        : pWSEx.getMessage();
            }

            showContinueOrExitDialog(message);
        } catch (Exception pEx) {
            String message = pEx.getMessage() == null ? I18N.BUNDLE.getString("Error_unknown")
                    : pEx.getMessage();
            showContinueOrExitDialog(message);
        }
    }
    return subKeys;
}

From source file:com.docdoku.client.data.MainModel.java

public DocumentMaster[] findDocMsByFolder(String pCompletePath) {
    DocumentMaster[] docMs = mCache.findDocMsByFolder(pCompletePath);

    if (docMs == null) {
        try {/*from w w  w.  j  a  v  a  2  s.c om*/
            System.out.println("Searching document masters by folder " + pCompletePath);
            docMs = Tools.resetParentReferences(mDocumentService.findDocumentMastersByFolder(pCompletePath));
            mCache.cacheDocMsByFolder(pCompletePath, docMs);
        } catch (WebServiceException pWSEx) {
            String message;
            Throwable t = pWSEx.getCause();
            if (t != null) {
                message = t.getMessage() == null ? I18N.BUNDLE.getString("Error_unknown") : t.getMessage();
            } else {
                message = pWSEx.getMessage() == null ? I18N.BUNDLE.getString("Error_unknown")
                        : pWSEx.getMessage();
            }

            showContinueOrExitDialog(message);
        } catch (Exception pEx) {
            String message = pEx.getMessage() == null ? I18N.BUNDLE.getString("Error_unknown")
                    : pEx.getMessage();
            showContinueOrExitDialog(message);
        }
    }
    return docMs;
}

From source file:com.docdoku.client.data.MainModel.java

public String[] getTags() {
    String[] tags = mCache.getTags();

    if (tags == null) {
        try {/*from ww w.jav  a2s .c  o  m*/
            System.out.println("Retrieving tags");
            tags = mDocumentService.getTags(getWorkspace().getId());
            mCache.cacheTags(tags);
        } catch (WebServiceException pWSEx) {
            String message;
            Throwable t = pWSEx.getCause();
            if (t != null) {
                message = t.getMessage() == null ? I18N.BUNDLE.getString("Error_unknown") : t.getMessage();
            } else {
                message = pWSEx.getMessage() == null ? I18N.BUNDLE.getString("Error_unknown")
                        : pWSEx.getMessage();
            }

            showContinueOrExitDialog(message);
        } catch (Exception pEx) {
            String message = pEx.getMessage() == null ? I18N.BUNDLE.getString("Error_unknown")
                    : pEx.getMessage();
            showContinueOrExitDialog(message);
        }
    }
    return tags;
}