jivekb

03-09-10 skyleaf24
一个人恢复代码,好无聊,还有没谁正玩这个的,一起啦。

skyleaf24
2003-09-11 11:04
我们来打靶吧

jivekb.jar

kb.action.KbSearch

kb.action.EditCategories

kb.database.CommentBlockIterator

kb.database.DbEntry

kb.database.DbCategory

kb.database.DbQuery

kb.database.DbQueryLogger

kb.database.DbSearchManager

kb.database.DbWatchManager

kb.database.EntryBlockIterator

kb.database.EntryPartBlockIterator

kb.database.KbCategoryBlockIterator

kb.database.RecommendationBlockIterator

kb.database.WatchListener

jivebase.jar

com.jivesoftware.base.AuthFactory

com.jivesoftware.base.JivePropertyClusterTask

com.jivesoftware.base.util.PDFExtractor

com.jivesoftware.base.log.output.AsyncLogTarget

com.jivesoftware.base.database.ConnectionPool

com.jivesoftware.base.database.DbPresenceManager

com.jivesoftware.base.database.DbRoster

com.jivesoftware.base.database.SSOAuthFactory

差不多就剩这些啦。

skyleaf24
2003-09-11 11:25
开始打啦。

我用的工具DJ Java Decompiler 3.5

AuthFactory反编译后,

protected AuthToken createAuthToken(HttpServletRequest request, HttpServletResponse response)不正确,结果如下:

protected AuthToken createAuthToken(HttpServletRequest request, HttpServletResponse response)

throws UnauthorizedException

{

HttpSession session;

AuthToken authToken;

Cookie cookie;

session = request.getSession();

authToken = (AuthToken)session.getAttribute("jive.authToken");

if(authToken != null)

return authToken;

cookie = CookieUtils.getCookie(request, "jive.authToken.autologin");

if(cookie == null)

break MISSING_BLOCK_LABEL_110;

String authInfo[] = decryptAuthInfo(cookie.getValue());

if(authInfo == null)

break MISSING_BLOCK_LABEL_90;

String username = authInfo[0];

String password = authInfo[1];

authToken = getAuthToken(username, password);

session.setAttribute("jive.authToken", authToken);

return authToken;

try

{

CookieUtils.deleteCookie(response, cookie);

}

catch(UnauthorizedException ue)

{

CookieUtils.deleteCookie(response, cookie);

throw ue;

}

throw new UnauthorizedException();

}

修改后:

protected AuthToken createAuthToken(HttpServletRequest request, HttpServletResponse response)

throws UnauthorizedException

{

HttpSession session;

AuthToken authToken;

Cookie cookie;

session = request.getSession();

authToken = (AuthToken)session.getAttribute("jive.authToken");

if(authToken != null)

return authToken;

cookie = CookieUtils.getCookie(request, "jive.authToken.autologin");

if(cookie == null)

throw new UnauthorizedException();

String authInfo[] = decryptAuthInfo(cookie.getValue());

if(authInfo == null)

{

CookieUtils.deleteCookie(response, cookie);

throw new UnauthorizedException();

}

String username = authInfo[0];

String password = authInfo[1];

authToken = getAuthToken(username, password);

session.setAttribute("jive.authToken", authToken);

return authToken;

}

skyleaf24
2003-09-11 11:41
JivePropertyClusterTask

编译后run()

public void run()

{

int i;

if(name != null && (value == null || "".equals(value.trim())))

{

JiveGlobals.deleteJiveProperty(name, false);

break MISSING_BLOCK_LABEL_119;

}

if(name == null || value == null)

break MISSING_BLOCK_LABEL_119;

i = 0;

_L2:

if(i >= excludedProperties.size())

break MISSING_BLOCK_LABEL_99;

String s = (String)excludedProperties.get(i);

if(name.equals(s))

return;

i++;

if(true) goto _L2; else goto _L1

_L1:

JiveGlobals.setJiveProperty(name, value, false);

break MISSING_BLOCK_LABEL_119;

Exception e;

e;

Log.error(e);

}

这些_L1,_L2的弄得心里真不舒服

修改后

public void run()

{

if (name != null && (value == null || "".equals(value.trim()))) {

JiveGlobals.deleteJiveProperty(name, false);

return;

}

if (name == null || value == null)

return;

for (int i = 0; i < excludedProperties.size(); i++) {

String s = (String) excludedProperties.get(i);

if (name.equals(s))

JiveGlobals.setJiveProperty(name, value, false);

}

}

skyleaf24
2003-09-11 12:01
哦,JiveProperty应该不会是重名吧。

再改一下,

    public void run()
    {
      if (name != null && (value == null || "".equals(value.trim()))) {
        JiveGlobals.deleteJiveProperty(name, false);
        return;
      }
      if (name == null || value == null)
        return;
      for (int i = 0; i < excludedProperties.size(); i++) {
        String s = (String) excludedProperties.get(i);
        if (name.equals(s))
        {
          JiveGlobals.setJiveProperty(name, value, false);
          return;
        }
      }
    }

skyleaf24
2003-09-11 12:13
JivePropertyClusterTask反编译后

private String extractTextWithNative(String filename)

throws IOException 不正确,代码如下:

    private String extractTextWithNative(String filename)
        throws IOException
    {
        StringWriter out = null;
        String nativeExec;
        Process p;
        char buf[];
        nativeExec = JiveGlobals.getJiveProperty("search.pdfToText.executable");
        String cmd[] = {
            JiveGlobals.getJiveHome() + File.separator + nativeExec, "-enc", "UTF-8", "-q", filename, "-"
        };
        p = Runtime.getRuntime().exec(cmd);
        BufferedInputStream bis = new BufferedInputStream(p.getInputStream());
        InputStreamReader reader = new InputStreamReader(bis, "UTF-8");
        out = new StringWriter();
        buf = new char[512];
        int len;
        while((len = reader.read(buf)) >= 0) 
            out.write(buf, 0, len);
        reader.close();
        bis.close();
        p.exitValue();
        p.destroy();
        break MISSING_BLOCK_LABEL_205;
        IllegalThreadStateException e;
        e;
        try
        {
            Thread.sleep(250L);
        }
        catch(InterruptedException e1)
        {
            Log.error(e1);
        }
        p.destroy();
        break MISSING_BLOCK_LABEL_205;
        Exception exception;
        exception;
        p.destroy();
        throw exception;
        if(p.exitValue() == 3)
        {
            String cmd[] = {
                JiveGlobals.getJiveHome() + File.separator + nativeExec, "-enc", "UTF-8", "-q", "-upw", "", filename, "-"
            };
            p = Runtime.getRuntime().exec(cmd);
            BufferedInputStream bis = new BufferedInputStream(p.getInputStream());
            InputStreamReader reader = new InputStreamReader(bis, "UTF-8");
            out = new StringWriter();
            int len;
            while((len = reader.read(buf)) >= 0) 
                out.write(buf, 0, len);
            reader.close();
            bis.close();
        }
        p.exitValue();
        p.destroy();
        break MISSING_BLOCK_LABEL_416;
        e;
        try
        {
            Thread.sleep(250L);
        }
        catch(InterruptedException e1)
        {
            Log.error(e1);
        }
        p.destroy();
        break MISSING_BLOCK_LABEL_416;
        Exception exception1;
        exception1;
        p.destroy();
        throw exception1;
        if(p.exitValue() == 0)
            break MISSING_BLOCK_LABEL_491;
        Log.error("pdf parser returned exit code of: " + p.exitValue() + " for document " + filename);
        Log.error("Falling back to PDFBox to parse pdf");
        return extractTextWithPdfBox(filename);
        IOException e;
        e;
        Log.error("IOException thrown attempting to use native code to parse pdf", e);
        Log.error("Falling back to PDFBox to parse pdf");
        return extractTextWithPdfBox(filename);
        return out.toString();
    }

用本地方法获取PDF文件内容。

改成

private String extractTextWithNative(String filename)
        throws IOException{
        Log.error("哇,好长啦!怕啦你啦。");
        return extractTextWithPdfBox(filename);
}

skyleaf24
2003-09-11 12:15
搞错了,上面这个类是com.jivesoftware.base.util.PDFExtractor。

skyleaf24
2003-09-11 12:28
com.jivesoftware.base.log.output.AsyncLogTarget

编译后 run方法出错。

唉,无聊,用别人开源的东东,也就是啦,非得打在自己包里标上"jivesoftware 荣誉出品"

本类参看org.apache.log.output.AsyncLogTarget

猜你喜欢