semeru/Code-Code-CloneDetection-BigCloneBench huggingface dataset:
private void checkSettings() throws ConfigurationException {
        List serverList = getConfiguration().getServerList();
        for (Object aServerList : serverList) {
            JiraServerDetails jiraServerDetails = (JiraServerDetails) aServerList;
            URL url = null;
            try {
                if (jiraServerDetails.getBaseurl() == null || "".equals(jiraServerDetails.getBaseurl())) {
                    throw new ConfigurationException("BaseURL is empty.");
                }
                url = new URL(jiraServerDetails.getBaseurl());
                String content = getURLContent(url.openConnection().getInputStream());
                if (content.indexOf("Atlassian JIRA") == -1) {
                    throw new ConfigurationException("URL (" + url.toString() + ") Doesn't put to an installation of Atlassian JIRA");
                }
                try {
                    jiraServerDetails.getRpcClient(true).login();
                } catch (JiraException e) {
                    throw new ConfigurationException("Jira Server ( " + url.toString() + " ) is earlier than 2.6 or has RPC disabled.");
                }
            } catch (MalformedURLException e) {
                throw new ConfigurationException("Malformed URL: " + url);
            } catch (IOException e) {
                throw new ConfigurationException("Unable to contact server: " + url);
            }
            try {
                MyIssuesFeedBuilder feed = new MyIssuesFeedBuilder(new JiraServerDetails[] { jiraServerDetails });
                feed.buildFeedData();
            } catch (FeedException feedException) {
                throw new ConfigurationException(feedException.getMessage());
            }
        }
    }
public static void setFinishedFlag(String ip, String port, String user, String dbname, String password, int flag) throws Exception {
        String sql = "update flag set flag = " + flag;
        Connection conn = CubridDBCenter.getConnection(ip, port, dbname, user, password);
        System.out.println("====:::===" + ip);
        Statement stmt = null;
        try {
            conn.setAutoCommit(false);
            stmt = conn.createStatement();
            stmt.executeUpdate(sql);
            conn.commit();
        } catch (Exception ex) {
            ex.printStackTrace();
            conn.rollback();
            throw ex;
        } finally {
            stmt.close();
            conn.close();
        }
    }
public String getHash(String str) {
        try {
            MessageDigest md = MessageDigest.getInstance("MD5");
            md.update(str.getBytes());
            byte[] toChapter1Digest = md.digest();
            return Keystore.hexEncode(toChapter1Digest);
        } catch (Exception e) {
            logger.error("Error in creating DN hash: " + e.getMessage());
            return null;
        }
    }
public static AudioInputStream getWavFromURL(String urlstr) {
        URL url;
        AudioInputStream ais = null;
        try {
            url = new URL(urlstr);
            URLConnection c = url.openConnection();
            c.connect();
            InputStream stream = c.getInputStream();
            ais = new AudioInputStream(stream, playFormat, AudioSystem.NOT_SPECIFIED);
            LOG.debug("[getWavFromURL]Getting audio from URL: {0}");
        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return ais;
    }
@Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException {
        PrintWriter writer = null;
        InputStream is = null;
        FileOutputStream fos = null;
        try {
            writer = response.getWriter();
        } catch (IOException ex) {
            log(OctetStreamReader.class.getName() + "has thrown an exception: " + ex.getMessage());
        }
        String filename = request.getHeader("X-File-Name");
        try {
            is = request.getInputStream();
            fos = new FileOutputStream(new File(realPath + filename));
            IOUtils.copy(is, fos);
            response.setStatus(response.SC_OK);
            writer.print("{success: true}");
        } catch (FileNotFoundException ex) {
            response.setStatus(response.SC_INTERNAL_SERVER_ERROR);
            writer.print("{success: false}");
            log(OctetStreamReader.class.getName() + "has thrown an exception: " + ex.getMessage());
        } catch (IOException ex) {
            response.setStatus(response.SC_INTERNAL_SERVER_ERROR);
            writer.print("{success: false}");
            log(OctetStreamReader.class.getName() + "has thrown an exception: " + ex.getMessage());
        } finally {
            try {
                fos.close();
                is.close();
            } catch (IOException ignored) {
            }
        }
        writer.flush();
        writer.close();
    }
public FileAttribute getAttribute(URL url) throws VFSException {
        try {
            con = (HttpURLConnection) url.openConnection();
            con.setInstanceFollowRedirects(false);
            int response = con.getResponseCode();
            if (response >= 400) {
                return new DefaultFileAttribute(false, 0, null, FileType.NOT_EXISTS);
            }
            boolean redirect = (response >= 300 && response <= 399);
            if (redirect) {
                String location = con.getHeaderField("Location");
                return getAttribute(new URL(url, location));
            }
            return new DefaultFileAttribute(true, con.getContentLength(), new Date(con.getLastModified()), url.toString().endsWith("/") ? FileType.DIRECTORY : FileType.FILE);
        } catch (MalformedURLException e) {
            e.printStackTrace();
            throw new WrongPathException(file.getAbsolutePath());
        } catch (IOException e) {
            throw new VFSIOException("IOException opening " + file.getAbsolutePath(), e);
        } finally {
            if (con != null) {
                con.disconnect();
            }
        }
    }
private void enumeratePathArchive(final String archive) throws IOException {
                final boolean trace1 = m_trace1;
                final File fullArchive = new File(m_currentPathDir, archive);
                JarInputStream in = null;
                try {
                    in = new JarInputStream(new BufferedInputStream(new FileInputStream(fullArchive), 32 * 1024));
                    final IPathHandler handler = m_handler;
                    Manifest manifest = in.getManifest();
                    if (manifest == null) manifest = readManifestViaJarFile(fullArchive);
                    handler.handleArchiveStart(m_currentPathDir, new File(archive), manifest);
                    for (ZipEntry entry; (entry = in.getNextEntry()) != null; ) {
                        if (trace1) m_log.trace1("enumeratePathArchive", "processing archive entry [" + entry.getName() + "] ...");
                        handler.handleArchiveEntry(in, entry);
                        in.closeEntry();
                    }
                    if (m_processManifest) {
                        if (manifest == null) manifest = in.getManifest();
                        if (manifest != null) {
                            final Attributes attributes = manifest.getMainAttributes();
                            if (attributes != null) {
                                final String jarClassPath = attributes.getValue(Attributes.Name.CLASS_PATH);
                                if (jarClassPath != null) {
                                    final StringTokenizer tokenizer = new StringTokenizer(jarClassPath);
                                    for (int p = 1; tokenizer.hasMoreTokens(); ) {
                                        final String relPath = tokenizer.nextToken();
                                        final File archiveParent = fullArchive.getParentFile();
                                        final File path = archiveParent != null ? new File(archiveParent, relPath) : new File(relPath);
                                        final String fullPath = m_canonical ? Files.canonicalizePathname(path.getPath()) : path.getPath();
                                        if (m_pathSet.add(fullPath)) {
                                            if (m_verbose) m_log.verbose("  added manifest Class-Path entry [" + path + "]");
                                            m_path.add(m_pathIndex + (p++), path);
                                        }
                                    }
                                }
                            }
                        }
                    }
                } catch (FileNotFoundException fnfe) {
                    if ($assert.ENABLED) throw fnfe;
                } finally {
                    if (in != null) try {
                        in.close();
                    } catch (Exception ignore) {
                    }
                }
            }
public List<String> selectSynchrnServerFiles(SynchrnServerVO synchrnServerVO) throws Exception {
        List<String> list = new ArrayList<String>();
        try {
            FTPClient ftpClient = new FTPClient();
            ftpClient.setControlEncoding("euc-kr");
            if (!EgovWebUtil.isIPAddress(synchrnServerVO.getServerIp())) {
                throw new RuntimeException("IP is needed. (" + synchrnServerVO.getServerIp() + ")");
            }
            InetAddress host = InetAddress.getByName(synchrnServerVO.getServerIp());
            try {
                ftpClient.connect(host, Integer.parseInt(synchrnServerVO.getServerPort()));
                boolean isLogin = ftpClient.login(synchrnServerVO.getFtpId(), synchrnServerVO.getFtpPassword());
                if (!isLogin) throw new Exception("FTP Client Login Error : \n");
            } catch (SocketException se) {
                System.out.println(se);
                throw new Exception(se);
            } catch (Exception e) {
                System.out.println(e);
                throw new Exception(e);
            }
            FTPFile[] fTPFile = null;
            try {
                ftpClient.changeWorkingDirectory(synchrnServerVO.getSynchrnLc());
                fTPFile = ftpClient.listFiles(synchrnServerVO.getSynchrnLc());
                for (int i = 0; i < fTPFile.length; i++) {
                    if (fTPFile[i].isFile()) list.add(fTPFile[i].getName());
                }
            } catch (Exception e) {
                System.out.println(e);
            } finally {
                ftpClient.logout();
            }
        } catch (Exception e) {
            list.add("noList");
        }
        return list;
    }
public void deleteSynchrnServerFile(SynchrnServerVO synchrnServerVO) throws Exception {
        FTPClient ftpClient = new FTPClient();
        ftpClient.setControlEncoding("euc-kr");
        if (!EgovWebUtil.isIPAddress(synchrnServerVO.getServerIp())) {
            throw new RuntimeException("IP is needed. (" + synchrnServerVO.getServerIp() + ")");
        }
        InetAddress host = InetAddress.getByName(synchrnServerVO.getServerIp());
        ftpClient.connect(host, Integer.parseInt(synchrnServerVO.getServerPort()));
        ftpClient.login(synchrnServerVO.getFtpId(), synchrnServerVO.getFtpPassword());
        FTPFile[] fTPFile = null;
        try {
            ftpClient.changeWorkingDirectory(synchrnServerVO.getSynchrnLc());
            fTPFile = ftpClient.listFiles(synchrnServerVO.getSynchrnLc());
            for (int i = 0; i < fTPFile.length; i++) {
                if (synchrnServerVO.getDeleteFileNm().equals(fTPFile[i].getName())) ftpClient.deleteFile(fTPFile[i].getName());
            }
            SynchrnServer synchrnServer = new SynchrnServer();
            synchrnServer.setServerId(synchrnServerVO.getServerId());
            synchrnServer.setReflctAt("N");
            synchrnServerDAO.processSynchrn(synchrnServer);
        } catch (Exception e) {
            System.out.println(e);
        } finally {
            ftpClient.logout();
        }
    }
public void downloadFtpFile(SynchrnServerVO synchrnServerVO, String fileNm) throws Exception {
        FTPClient ftpClient = new FTPClient();
        ftpClient.setControlEncoding("euc-kr");
        if (!EgovWebUtil.isIPAddress(synchrnServerVO.getServerIp())) {
            throw new RuntimeException("IP is needed. (" + synchrnServerVO.getServerIp() + ")");
        }
        InetAddress host = InetAddress.getByName(synchrnServerVO.getServerIp());
        ftpClient.connect(host, Integer.parseInt(synchrnServerVO.getServerPort()));
        ftpClient.login(synchrnServerVO.getFtpId(), synchrnServerVO.getFtpPassword());
        ftpClient.changeWorkingDirectory(synchrnServerVO.getSynchrnLc());
        File downFile = new File(EgovWebUtil.filePathBlackList(synchrnServerVO.getFilePath() + fileNm));
        OutputStream outputStream = null;
        try {
            outputStream = new FileOutputStream(downFile);
            ftpClient.retrieveFile(fileNm, outputStream);
        } catch (Exception e) {
            System.out.println(e);
        } finally {
            if (outputStream != null) outputStream.close();
        }
        ftpClient.logout();
    }
public List<String> getFtpFileList(String serverIp, int port, String user, String password, String synchrnPath) throws Exception {
        List<String> list = new ArrayList<String>();
        FTPClient ftpClient = new FTPClient();
        ftpClient.setControlEncoding("euc-kr");
        if (!EgovWebUtil.isIPAddress(serverIp)) {
            throw new RuntimeException("IP is needed. (" + serverIp + ")");
        }
        InetAddress host = InetAddress.getByName(serverIp);
        ftpClient.connect(host, port);
        ftpClient.login(user, password);
        ftpClient.changeWorkingDirectory(synchrnPath);
        FTPFile[] fTPFile = ftpClient.listFiles(synchrnPath);
        for (int i = 0; i < fTPFile.length; i++) {
            list.add(fTPFile[i].getName());
        }
        return list;
    }
public boolean processFtp(String serverIp, int port, String user, String password, String synchrnPath, String filePath, File[] uploadFile) throws Exception {
        boolean upload = false;
        try {
            FTPClient ftpClient = new FTPClient();
            ftpClient.setControlEncoding("euc-kr");
            if (!EgovWebUtil.isIPAddress(serverIp)) {
                throw new RuntimeException("IP is needed. (" + serverIp + ")");
            }
            InetAddress host = InetAddress.getByName(serverIp);
            ftpClient.connect(host, port);
            if (!ftpClient.login(user, password)) throw new Exception("FTP Client Login Error : \n");
            if (synchrnPath.length() != 0) ftpClient.changeWorkingDirectory(synchrnPath);
            FTPFile[] fTPFile = ftpClient.listFiles(synchrnPath);
            FileInputStream fis = null;
            try {
                for (int i = 0; i < uploadFile.length; i++) {
                    if (uploadFile[i].isFile()) {
                        if (!isExist(fTPFile, uploadFile[i])) {
                            fis = new FileInputStream(uploadFile[i]);
                            ftpClient.storeFile(synchrnPath + uploadFile[i].getName(), fis);
                        }
                        if (fis != null) {
                            fis.close();
                        }
                    }
                }
                fTPFile = ftpClient.listFiles(synchrnPath);
                deleteFtpFile(ftpClient, fTPFile, uploadFile);
                upload = true;
            } catch (IOException ex) {
                System.out.println(ex);
            } finally {
                if (fis != null) try {
                    fis.close();
                } catch (IOException ignore) {
                    System.out.println("IGNORE: " + ignore);
                }
            }
            ftpClient.logout();
        } catch (Exception e) {
            System.out.println(e);
            upload = false;
        }
        return upload;
    }
public static void copyFile(final File source, final File target) throws FileNotFoundException, IOException {
        FileChannel in = new FileInputStream(source).getChannel(), out = new FileOutputStream(target).getChannel();
        ByteBuffer buffer = ByteBuffer.allocate(1024);
        while (in.read(buffer) != -1) {
            buffer.flip();
            out.write(buffer);
            buffer.clear();
        }
        out.close();
        in.close();
    }
public void loginToServer() {
        new Thread(new Runnable() {

            public void run() {
                if (!shouldLogin) {
                    u.p("skipping the auto-login");
                    return;
                }
                try {
                    u.p("logging in to the server");
                    String query = "hostname=blahfoo2.com" + "&osname=" + URLEncoder.encode(System.getProperty("os.name"), "UTF-8") + "&javaver=" + URLEncoder.encode(System.getProperty("java.runtime.version"), "UTF-8") + "&timezone=" + URLEncoder.encode(TimeZone.getDefault().getID(), "UTF-8");
                    u.p("unencoded query: \n" + query);
                    String login_url = "http://joshy.org:8088/org.glossitopeTracker/login.jsp?";
                    String url = login_url + query;
                    u.p("final encoded url = \n" + url);
                    InputStream in = new URL(url).openStream();
                    byte[] buf = new byte[256];
                    while (true) {
                        int n = in.read(buf);
                        if (n == -1) break;
                        for (int i = 0; i < n; i++) {
                        }
                    }
                } catch (MalformedURLException ex) {
                    ex.printStackTrace();
                } catch (IOException ex) {
                    ex.printStackTrace();
                }
            }
        }, "LoginToServerAction").start();
    }
public void run() {
                if (!shouldLogin) {
                    u.p("skipping the auto-login");
                    return;
                }
                try {
                    u.p("logging in to the server");
                    String query = "hostname=blahfoo2.com" + "&osname=" + URLEncoder.encode(System.getProperty("os.name"), "UTF-8") + "&javaver=" + URLEncoder.encode(System.getProperty("java.runtime.version"), "UTF-8") + "&timezone=" + URLEncoder.encode(TimeZone.getDefault().getID(), "UTF-8");
                    u.p("unencoded query: \n" + query);
                    String login_url = "http://joshy.org:8088/org.glossitopeTracker/login.jsp?";
                    String url = login_url + query;
                    u.p("final encoded url = \n" + url);
                    InputStream in = new URL(url).openStream();
                    byte[] buf = new byte[256];
                    while (true) {
                        int n = in.read(buf);
                        if (n == -1) break;
                        for (int i = 0; i < n; i++) {
                        }
                    }
                } catch (MalformedURLException ex) {
                    ex.printStackTrace();
                } catch (IOException ex) {
                    ex.printStackTrace();
                }
            }
public void retrieveChallenge() throws MalformedURLException, IOException, FBConnectionException, FBErrorException {
        URL url = new URL(getHost() + getPath());
        HttpURLConnection conn = (HttpURLConnection) url.openConnection();
        conn.setRequestProperty("X-FB-User", getUser());
        conn.setRequestProperty("X-FB-Mode", "GetChallenge");
        conn.connect();
        Element fbresponse;
        try {
            fbresponse = readXML(conn);
        } catch (FBConnectionException fbce) {
            error = true;
            throw fbce;
        } catch (FBErrorException fbee) {
            error = true;
            throw fbee;
        } catch (Exception e) {
            error = true;
            FBConnectionException fbce = new FBConnectionException("XML parsing failed");
            fbce.attachSubException(e);
            throw fbce;
        }
        NodeList nl = fbresponse.getElementsByTagName("GetChallengeResponse");
        for (int i = 0; i < nl.getLength(); i++) {
            if (nl.item(i) instanceof Element && hasError((Element) nl.item(i))) {
                error = true;
                FBErrorException e = new FBErrorException();
                e.setErrorCode(errorcode);
                e.setErrorText(errortext);
                throw e;
            }
        }
        NodeList challenge = fbresponse.getElementsByTagName("Challenge");
        for (int i = 0; i < challenge.getLength(); i++) {
            NodeList children = challenge.item(i).getChildNodes();
            for (int j = 0; j < children.getLength(); j++) {
                if (children.item(j) instanceof Text) {
                    challenges.offer(children.item(j).getNodeValue());
                }
            }
        }
    }
public void retrieveChallenges(int num) throws MalformedURLException, IOException, FBErrorException, FBConnectionException {
        if (num < 1 || num > 100) {
            error = true;
            FBErrorException fbee = new FBErrorException();
            fbee.setErrorCode(-100);
            fbee.setErrorText("Invalid GetChallenges range");
            throw fbee;
        }
        URL url = new URL(getHost() + getPath());
        HttpURLConnection conn = (HttpURLConnection) url.openConnection();
        conn.setRequestProperty("X-FB-User", getUser());
        conn.setRequestProperty("X-FB-Mode", "GetChallenges");
        conn.setRequestProperty("X-FB-GetChallenges.Qty", new Integer(num).toString());
        conn.connect();
        Element fbresponse;
        try {
            fbresponse = readXML(conn);
        } catch (FBConnectionException fbce) {
            error = true;
            throw fbce;
        } catch (FBErrorException fbee) {
            error = true;
            throw fbee;
        } catch (Exception e) {
            error = true;
            FBConnectionException fbce = new FBConnectionException("XML parsing failed");
            fbce.attachSubException(e);
            throw fbce;
        }
        NodeList nl = fbresponse.getElementsByTagName("GetChallengesResponse");
        for (int i = 0; i < nl.getLength(); i++) {
            if (nl.item(i) instanceof Element && hasError((Element) nl.item(i))) {
                error = true;
                FBErrorException e = new FBErrorException();
                e.setErrorCode(errorcode);
                e.setErrorText(errortext);
                throw e;
            }
        }
        NodeList challenge = fbresponse.getElementsByTagName("Challenge");
        for (int i = 0; i < challenge.getLength(); i++) {
            NodeList children = challenge.item(i).getChildNodes();
            for (int j = 0; j < children.getLength(); j++) {
                if (children.item(j) instanceof Text) {
                    challenges.offer(children.item(j).getNodeValue());
                }
            }
        }
    }