Example usage for javax.xml.ws WebServiceException WebServiceException

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

Introduction

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

Prototype

public WebServiceException(Throwable cause) 

Source Link

Document

Constructs a new WebServiceException with the specified cause and a detail message of (cause==null ?

Usage

From source file:com.mytube.MyTubeWS.java

public void videoUpload(String videoName, String desc,
        @XmlMimeType("application/octet-stream") DataHandler data) throws RemoteException, NotBoundException {

    String videoID = "bbb"; //arruma isso jao SEM PONTO E VIRGULA!!! 
    //---------RMI----No toque porra        
    File file = null;// w w w.j  av a 2  s.  com
    //Video handler
    try (StreamingDataHandler dh = (StreamingDataHandler) data) {
        file = new File("e://WS/" + videoName);
        dh.moveTo(file);
        dh.close();
        try (InputStream is = new FileInputStream(file)) {
            RMIClient rmiClient = new RMIClient("192.168.0.145", "MyTubeRMI");
            rmiClient.upload(videoID, is);
        }
    } catch (IOException e) {
        throw new WebServiceException(e);
    }
    file.delete();
}

From source file:com.edgenius.wiki.integration.webservice.impl.WsUserServiceImpl.java

public Integer createUser(WsUser wsUser) {
    User user = new User();
    Set<Role> roleObjects = new HashSet<Role>();
    user.setRoles(roleObjects);/*from w  w  w.ja v a  2  s.co  m*/

    //put role objects into role list
    RoleList roles = wsUser.getRoles();
    if (roles != null) {
        for (String name : roles.getRolename()) {
            Role role = roleService.getRoleByName(name);
            if (role == null)
                throw new WebServiceException("Role [" + name + "] does not exist.");

            roleObjects.add(role);
        }
    }
    //default role - so far only RegisterUser role
    roleObjects.addAll(roleService.getDefaultRole());

    wsUser.copyTo(user);
    if (Global.EncryptPassword) {
        user.setPassword(CodecUtil.encodePassword(wsUser.getPassword(), Global.PasswordEncodingAlgorithm));
    }
    user.setCreatedDate(new Date());

    //TODO: always enable, not check Global.registerMethod yet.
    user.setEnabled(true);
    try {
        user = userService.saveUser(user);
        activityLog.logUserSignup(user, REGISTER_METHOD.approval);

        //TODO: not send out email to user

        return user.getUid();
    } catch (UserExistsException e) {
        throw new WebServiceException(e);
    } catch (UserOverLimitedException e) {
        throw new WebServiceException(e);
    }
}

From source file:com.omertron.thetvdbapi.TheTVDBApi.java

/**
 * Get the mirror information from TheTVDb
 *
 * @return True if everything is OK, false otherwise.
 *//* w  ww .j  a  va 2 s  . c  om*/
private static void getMirrors(String apiKey) {
    // If we don't need to get the mirrors, then just return
    if (xmlMirror != null && bannerMirror != null) {
        return;
    }

    Mirrors mirrors = new Mirrors(apiKey);
    xmlMirror = mirrors.getMirror(Mirrors.TYPE_XML);
    bannerMirror = mirrors.getMirror(Mirrors.TYPE_BANNER);

    if (xmlMirror == null) {
        throw new WebServiceException(
                "There is a problem getting the xmlMirror data from TheTVDB, this means it is likely to be down.");
    } else {
        xmlMirror += "/api/";
    }

    if (bannerMirror == null) {
        throw new WebServiceException(
                "There is a problem getting the bannerMirror data from TheTVDB, this means it is likely to be down.");
    } else {
        bannerMirror += "/banners/";
    }
}

From source file:com.mkl.websuites.internal.tests.ScenarioFolderTest.java

private void processRecursivelyFolder(Path folderPath, TestSuite parentSuite) {

    TestSuite currentFolderSuite;/*from www.ja v  a  2s  .  c  o m*/
    if (isTopTest) {
        currentFolderSuite = new TestSuite(folderPath.toString());
        isTopTest = false;
    } else {
        currentFolderSuite = new TestSuite(
                folderPath.subpath(folderPath.getNameCount() - 1, folderPath.getNameCount()).toString());
    }

    List<Test> testsInCurrentFolder = processScenarioFilesInFolder(folderPath.toString());

    for (Test test : testsInCurrentFolder) {
        currentFolderSuite.addTest(test);
    }

    parentSuite.addTest(currentFolderSuite);

    if (ignoreSubfolders) {
        return;
    }

    File folder = new File(folderPath.toString());

    File[] nestedFolders = folder.listFiles(new FileFilter() {

        @Override
        public boolean accept(File file) {
            return file.isDirectory();
        }
    });

    if (nestedFolders == null) {
        throw new WebServiceException(String.format("Error while traversing through folder "
                + "structure starting from path '%s'. Probably there is something wrong "
                + "in the path string.", folderPath));
    }

    sort(nestedFolders);

    for (File nested : nestedFolders) {

        processRecursivelyFolder(Paths.get(nested.toURI()), currentFolderSuite);
    }

}

From source file:com.edgenius.wiki.integration.webservice.impl.WsSecurityInterceptor.java

@Override
public void handleMessage(Message message) throws Fault {
    // This is set by CXF
    AuthorizationPolicy policy = message.get(AuthorizationPolicy.class);

    // If the policy is not set, the user did not specify credentials
    // This could be anonymous request
    if (policy == null) {
        log.info("User attempted to log in with no credentials, treat it as anonymous");
        securityService.proxyLogin(null);
    } else {/*from   ww  w .  j a  va2 s.  com*/
        if (log.isDebugEnabled()) {
            log.debug("Logging in use: " + policy.getUserName());
        }
        // Verify the password
        User user = userReadingService.getUserByName(policy.getUserName());
        // !!! Must do password validation here as SecurityServiceproxyLogin() always give authentication
        String passwd = CodecUtil.encodePassword(policy.getPassword(), Global.PasswordEncodingAlgorithm);
        if (user == null || !StringUtils.equals(user.getPassword(), passwd)) {
            log.warn("Invalid username or password for user: " + policy.getUserName());
            //stopResponse(message, HttpURLConnection.HTTP_FORBIDDEN);
            throw new WebServiceException("Invalid username or password for user: " + policy.getUserName());
        }
        securityService.proxyLogin(user.getUsername());
    }

}

From source file:com.edgenius.wiki.integration.webservice.impl.WsUserServiceImpl.java

public Integer updateUser(WsUser wsUser) {
    if (StringUtils.isBlank(wsUser.getUsername())) {
        throw new WebServiceException("Username can't be blank when update user.");
    }//from w ww. ja v  a  2  s .  c  o m
    User user = userReadingService.getUserByName(wsUser.getUsername().trim());
    if (user == null) {
        throw new WebServiceException("User doesn't exist by username [" + wsUser.getUsername() + "]");
    }

    Set<Role> roles = user.getRoles();
    RoleList wsRoles = wsUser.getRoles();
    roles.clear();
    if (wsRoles != null) {
        for (String name : wsRoles.getRolename()) {
            Role role = roleService.getRoleByName(name);
            if (role == null)
                throw new WebServiceException("Role [" + name + "] does not exist.");

            roles.add(role);
        }
    } else {
        //default role - so far only RegisterUser role
        roles.addAll(roleService.getDefaultRole());
    }

    wsUser.copyTo(user);
    if (Global.EncryptPassword) {
        user.setPassword(CodecUtil.encodePassword(wsUser.getPassword(), Global.PasswordEncodingAlgorithm));
    }

    user = userService.updateUserWithIndex(user);

    return user.getUid();
}

From source file:com.moviejukebox.tools.SearchEngineTools.java

public SearchEngineTools(String country) {
    httpClient = YamjHttpClientBuilder.getHttpClient();

    // sites to search for URLs
    searchSites = new LinkedList<>();
    searchSites.addAll(//from  w w w  .jav  a  2s.c o  m
            Arrays.asList(PropertiesUtil.getProperty("searchengine.sites", "google,yahoo,bing").split(",")));

    // country specific presets
    if ("us".equalsIgnoreCase(country)) {
        this.country = "us";
        // Leave the rest as defaults
    } else if ("de".equalsIgnoreCase(country)) {
        this.country = "de";
        language = "de";
        googleHost = "www.google.de";
        yahooHost = "de.search.yahoo.com";
    } else if ("it".equalsIgnoreCase(country)) {
        this.country = "it";
        language = "it";
        googleHost = "www.google.it";
        yahooHost = "it.search.yahoo.com";
        bingHost = "it.bing.com";
    } else if ("se".equalsIgnoreCase(country)) {
        this.country = "se";
        language = "sv";
        googleHost = "www.google.se";
        yahooHost = "se.search.yahoo.com";
    } else if ("pl".equalsIgnoreCase(country)) {
        this.country = "pl";
        language = "pl";
        googleHost = "www.google.pl";
        yahooHost = "pl.search.yahoo.com";
    } else if ("ru".equalsIgnoreCase(country)) {
        this.country = "ru";
        language = "ru";
        googleHost = "www.google.ru";
        yahooHost = "ru.search.yahoo.com";
    } else if ("il".equalsIgnoreCase(country)) {
        this.country = "il";
        language = "il";
        googleHost = "www.google.co.il";
    } else if ("fr".equalsIgnoreCase(country)) {
        this.country = "fr";
        language = "fr";
        googleHost = "www.google.fr";
    } else if ("nl".equalsIgnoreCase(country)) {
        this.country = "nl";
        language = "nl";
        googleHost = "www.google.nl";
    } else {
        throw new WebServiceException("Invalid country '" + country + "' specified");
    }
}

From source file:com.mkl.websuites.internal.tests.ScenarioFolderTest.java

protected List<Test> processScenarioFilesInFolder(String folderPath) {

    File folder = new File(folderPath);

    if (!folder.exists()) {
        throw new WebServiceException(String.format(
                "Specified root folder in @Folder(path='%s') does not exist " + "(actual path is '%s')",
                folderPath, folder.getAbsolutePath()));
    }//from   ww  w.j a v  a2s . c o m

    ScenarioFileProcessor scenarioFileProcessor = ServiceFactory.get(ScenarioFileProcessor.class);

    File[] scenarioFiles = folder.listFiles(new FileFilter() {

        @Override
        public boolean accept(File file) {
            return file.getName().toLowerCase(Locale.getDefault()).endsWith(".scn");
        }
    });

    if (scenarioFiles == null) {
        throw new WebServiceException(String.format(
                "Error while reading scenario files in "
                        + "the folder path '%s'. Probably there is something wrong in the path string.",
                folderPath));
    }

    sort(scenarioFiles);

    List<Test> testsInThisFolder = new ArrayList<Test>();

    for (File scnearioFile : scenarioFiles) {

        List<Test> testsInScenarioFile = scenarioFileProcessor
                .processSingleScenarioFile(scnearioFile.getAbsolutePath());

        testsInThisFolder.addAll(testsInScenarioFile);
    }

    return testsInThisFolder;
}

From source file:com.omertron.thetvdbapi.TheTVDBApi.java

/**
 * Set the web browser proxy information
 *
 * @param host//from w w w.j a v a2s .  c om
 * @param port
 * @param username
 * @param password
 */
public void setProxy(String host, int port, String username, String password) {
    if (httpClient == null) {
        throw new WebServiceException("Failed to set proxy information");
    } else {
        httpClient.setProxy(host, port, username, password);
    }
}

From source file:com.omertron.thetvdbapi.TheTVDBApi.java

/**
 * Set the web browser timeout settings/*from w  w  w.ja v  a  2 s  .  c o m*/
 *
 * @param webTimeoutConnect
 * @param webTimeoutRead
 */
public void setTimeout(int webTimeoutConnect, int webTimeoutRead) {
    if (httpClient == null) {
        throw new WebServiceException("Failed to set timeout information");
    } else {
        httpClient.setTimeouts(webTimeoutConnect, webTimeoutRead);
    }
}