CarrotChat v2.8.60.240131版本的 MD5 值为:2baf8b9f31830b86b5c5a85ae6b47e05
以下内容为反编译后的 af.java 源代码,内容仅作参考
package ak.im.sdk.manager;
import ak.im.BuildConfig;
import ak.im.module.BoxBean;
import ak.im.module.EnterpriseInfo;
import ak.im.module.OrganizationBean;
import ak.im.module.Server;
import ak.im.modules.display_name.OrgDepartmentManger;
import ak.im.p1;
import ak.im.utils.AkeyChatUtils;
import ak.im.utils.HttpURLTools;
import ak.im.utils.Log;
import android.content.Context;
import android.text.TextUtils;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
import org.apache.commons.httpclient.cookie.CookieSpec;
import retrofit2.m;
public class af {
private String a;
private ArrayList<String> f889b;
private Context f890c;
private ConcurrentHashMap<String, OrganizationBean> f891d;
private boolean f892e;
private EnterpriseInfo f;
private String g;
public Server h;
private BoxBean i;
public class a implements io.reactivex.s0.o<String, io.reactivex.z<ArrayList<OrganizationBean>>> {
final StringBuilder a;
a(StringBuilder sb) {
this.a = sb;
}
@Override
public io.reactivex.z<ArrayList<OrganizationBean>> apply(String str) {
Log.i(af.this.a, "server json data:1");
Server loads = Server.loads(str);
if (loads == null || !loads.isEffective()) {
Log.w(af.this.a, "server is null");
return null;
}
this.a.append(loads.getAppSrvHost());
this.a.append(":");
this.a.append(loads.getAppSrvPort());
return ((ak.i.z) new m.b().baseUrl(this.a.toString()).client(HttpURLTools.getOkHttpClientBuilder(this.a.toString(), ye.getInstance().getAccessToken(), false).build()).addCallAdapterFactory(retrofit2.adapter.rxjava2.g.create()).addConverterFactory(retrofit2.p.a.a.create()).build().create(ak.i.z.class)).getOrganizations();
}
}
class b extends ak.j.a<ArrayList<OrganizationBean>> {
b() {
}
@Override
public void onNext(ArrayList<OrganizationBean> arrayList) {
af.this.inflateOrganizationData(arrayList, false);
}
}
public static class c {
private static af a = new af(null);
}
af(a aVar) {
this();
}
private String b(String str, String str2) {
if ("akeychat".equalsIgnoreCase(str)) {
return "akeychat.enterprise.akey.im";
}
if ("yhy".equalsIgnoreCase(str)) {
return "yhy.enterprise.akeychat.cn";
}
if ("novasky".equalsIgnoreCase(str)) {
return "novasky.enterprise.akeychat.cn";
}
if ("bhcmi".equalsIgnoreCase(str)) {
return "bhcmi.enterprise.akeychat.cn";
}
if ("bhisip".equalsIgnoreCase(str)) {
return "bhisip.enterprise.akeychat.cn";
}
if ("pomm97".equalsIgnoreCase(str)) {
return "pomm97.enterprise.akeychat.cn";
}
if ("liusuotekong".equalsIgnoreCase(str)) {
return "liusuozhida.enterprise.akeychat.cn";
}
if ("qixinxieli".equalsIgnoreCase(str)) {
return "qixinxieli.enterprise.akeychat.cn";
}
if ("sxjlw".equalsIgnoreCase(str)) {
return "sxjlw.enterprise.akeychat.cn";
}
if ("zhiyin".equalsIgnoreCase(str)) {
return "zhiyin.app.duoyuanyigou.com";
}
if ("knownfuture".equalsIgnoreCase(str)) {
return "knownfuture.enterprise.akeychat.cn";
}
if ("server5".equalsIgnoreCase(str)) {
return "server5.pro.akeychat.cn:30349";
}
if ("server3".equalsIgnoreCase(str)) {
return "server3.test.enterprise.akeychat.cn";
}
if ("shangjia".equalsIgnoreCase(str)) {
return "shangjia.pro.akeychat.cn";
}
return str + str2;
}
private int c(OrganizationBean organizationBean) {
OrganizationBean organizationById;
if ("0".equals(organizationBean.mParentId) || (organizationById = getOrganizationById(organizationBean.mParentId)) == null) {
return 0;
}
int level = organizationById.getLevel();
if (level > 0) {
int i = level + 1;
organizationBean.setLevel(i);
return i;
}
int c2 = c(organizationById) + 1;
organizationBean.setLevel(c2);
return c2;
}
private ArrayList<Object> d(String str) {
ArrayList<Object> arrayList = new ArrayList<>();
ConcurrentHashMap<String, OrganizationBean> concurrentHashMap = this.f891d;
if (concurrentHashMap == null) {
return arrayList;
}
for (String str2 : concurrentHashMap.keySet()) {
OrganizationBean organizationBean = this.f891d.get(str2);
if (organizationBean.mParentId.equals(str)) {
arrayList.add(organizationBean);
}
}
return arrayList;
}
public static Long e(Long l) throws Exception {
nf.getInstance().notifyOrganizationsDataSetUpdated();
df.getInstance().refreshSortLettersAmongGroups();
return l;
}
public static ArrayList f(ArrayList arrayList) throws Exception {
int size = arrayList == null ? 0 : arrayList.size();
ArrayList arrayList2 = new ArrayList(size);
if (size == 0) {
return new ArrayList();
}
Iterator it = arrayList.iterator();
while (it.hasNext()) {
Object next = it.next();
if (next instanceof OrganizationBean) {
arrayList2.add((OrganizationBean) next);
}
}
return arrayList2;
}
private void g(String str) {
String str2 = this.g;
String[] strArr = {"cy", "lixin", "libo", "qy", "yingfeng", "huage", "chao", "biwan8", "fx", "mechat", "888999", "m588", "WT88", "qianyi", "w588", "smh", "a655655", "jz", "OK8899", "quanmin", "lb99", "vip666", "bh", "hhyl888", "YY", "lc6869", "mx888", "shanghai518", "zq888", "sx", "xf", "DACHUI", "qq123", "jj88", "bs99", "bs99", "kkk888", "xm168", "516888", "a666", "C998", "CS1080", "dz", "LH", "m6688", "qx", "wyy", "YLY", "fa888", "178", "678999", "71552", "okw666", "ss8888", "vip8888", "www666", "y60020", "akeychat", "71552os", "a556556", "a666os", "a688688", "bhos", "biwan8os", "c998os", "chaoos", "ck888os", "cs1080os", "csos", "cyos", "df666os", "fa888os", "h678os", "jzos", "kkk888os", "lb99os", "lc6869os", "lhos", "liboos", "lixinos", "m588os", "mbos", "mechatos", "mixin5os", "mixin7os", "mx888os", "okw666os", "qyos", "smhos", "ss8888os", "sxos", "w588os", "www666os", "wyyos", "xfos", "y60020os", "ylyout", "ylyxjp", "yyos", "yyos2", "zq888os", "server5", "ck888", "ck888os", "df666", "df666os", "18768", "18768os", "mixyan88", "mb", "mbos", "50458", "50458os", "yc", "ycos", "678999os", "888999os", "DACHUIos", "dzos", "m6688os", "mixyan88os", "OK8899os", "quanminos", "shanghai518os", "ss8888os", "w588os", "xm168os", "h678", "cd888", "fxos", "yingfengos", "nh1311", "nh1311os", "hyc", "hycos", "ds888", "ds888os"};
ArrayList arrayList = new ArrayList();
for (int i = 0; i < 137; i++) {
arrayList.add(strArr[i].toLowerCase());
}
if (arrayList.contains(str.toLowerCase())) {
return;
}
Server.setTmpDiscoverUrl(str + str2);
}
public static af getInstance() {
return c.a;
}
public static String getLocalEnterpriseIPAddress() {
try {
String string = ak.im.o1.get().getSharedPreferences("enterprise_config", 0).getString("enterpriser_info_key", null);
TextUtils.isEmpty(string);
return string;
} catch (Exception e2) {
e2.printStackTrace();
return null;
}
}
private void h(String str) {
String str2;
String str3 = this.g;
if ("akeychat".equalsIgnoreCase(str)) {
str2 = "akeychat.enterprise.akey.im";
} else if ("shangjia".equalsIgnoreCase(str)) {
str2 = "shangjia.pro.akeychat.cn";
} else if ("server5".equalsIgnoreCase(str)) {
str2 = "server5.pro.akeychat.cn:30349";
} else if ("server3".equalsIgnoreCase(str)) {
str2 = "server3.test.enterprise.akeychat.cn";
} else {
str2 = str + str3;
}
Log.d(this.a, "carrot server is " + str2);
Server.setTmpDiscoverUrl(str2);
}
public Boolean changeCurrentDomain() {
if (TextUtils.isEmpty(".app.boxnet.org.cn")) {
return Boolean.FALSE;
}
if (this.g.equals(".app.boxnet.org.cn")) {
this.g = ".app.akeyme.cn";
return Boolean.TRUE;
}
this.g = ".app.boxnet.org.cn";
return Boolean.FALSE;
}
public void chooseEnterprise(EnterpriseInfo enterpriseInfo) {
if (enterpriseInfo == null) {
Log.w(this.a, "current info is null do not choose ,use old ");
return;
}
this.f = enterpriseInfo;
enterpriseInfo.chooseTimestamp = System.currentTimeMillis();
Log.d("lwxx2", "discovery ip is " + enterpriseInfo.discoverServerIP);
ye.getInstance().chooseOneEnterprise(enterpriseInfo);
ye.getInstance().M0();
p1.a.a = ak.im.utils.l4.getAppDataPath();
ye.getInstance().saveNewServerId();
ak.im.utils.j4.sendEvent(new ak.event.l0(enterpriseInfo));
}
public io.reactivex.z<BoxBean> discoverBox(String str, String str2) {
String str3;
if (TextUtils.isEmpty(str)) {
Log.w(this.a, "discover stop key is empty");
return io.reactivex.z.empty();
}
StringBuilder sb = new StringBuilder();
sb.append("https://");
if (!str.contains(".")) {
if ("akeychat".equalsIgnoreCase(str)) {
str3 = "akeychat.enterprise.akey.im";
} else if ("yhy".equalsIgnoreCase(str)) {
str3 = "yhy.enterprise.akeychat.cn";
} else if ("novasky".equalsIgnoreCase(str)) {
str3 = "novasky.enterprise.akeychat.cn";
} else if ("bhcmi".equalsIgnoreCase(str)) {
str3 = "bhcmi.enterprise.akeychat.cn";
} else if ("bhisip".equalsIgnoreCase(str)) {
str3 = "bhisip.enterprise.akeychat.cn";
} else if ("pomm97".equalsIgnoreCase(str)) {
str3 = "pomm97.enterprise.akeychat.cn";
} else if ("liusuotekong".equalsIgnoreCase(str)) {
str3 = "liusuozhida.enterprise.akeychat.cn";
} else if ("qixinxieli".equalsIgnoreCase(str)) {
str3 = "qixinxieli.enterprise.akeychat.cn";
} else if ("sxjlw".equalsIgnoreCase(str)) {
str3 = "sxjlw.enterprise.akeychat.cn";
} else if ("zhiyin".equalsIgnoreCase(str)) {
str3 = "zhiyin.app.duoyuanyigou.com";
} else if ("knownfuture".equalsIgnoreCase(str)) {
str3 = "knownfuture.enterprise.akeychat.cn";
} else if ("server5".equalsIgnoreCase(str)) {
str3 = "server5.pro.akeychat.cn";
} else if ("server3".equalsIgnoreCase(str)) {
str3 = "server3.test.enterprise.akeychat.cn";
} else {
str3 = str + ".pro.akeychat.cn";
}
Server.setTmpDiscoverUrl(str3);
if (!ak.im.g2.c.a.isFlavor("beepchat") && !ak.im.g2.c.a.isFlavor("teleme")) {
h(str);
} else {
g(str);
}
} else if (str.matches("\\b(([01]?\\d?\\d|2[0-4]\\d|25[0-5])\\.){3}([01]?\\d?\\d|2[0-4]\\d|25[0-5])\\b")) {
Server.setTmpDiscoverUrl(str);
} else {
Server.setTmpDiscoverUrl(str);
}
sb.append(Server.getTmpDiscoverUrl());
if (!Server.getTmpDiscoverUrl().contains(":")) {
Server.setTmpDiscoverPort(BuildConfig.bnDiscoverNodePort);
sb.append(":");
sb.append(Server.getTmpDiscoverPort());
}
sb.append(CookieSpec.PATH_DELIM);
Log.d(this.a, "path is " + sb.toString());
return AkeyChatUtils.discoverBoxNew(sb.toString(), str2);
}
public io.reactivex.z<String> discoverServer(String str) {
if (TextUtils.isEmpty(str)) {
Log.w(this.a, "discover stop key is empty");
return io.reactivex.z.empty();
}
StringBuilder sb = new StringBuilder();
sb.append("https://");
if (!str.contains(".")) {
Server.setTmpDiscoverUrl(b(str, ".pro.akeychat.cn"));
if (!ak.im.g2.c.a.isFlavor("beepchat") && !ak.im.g2.c.a.isFlavor("teleme")) {
h(str);
} else {
g(str);
}
} else if (str.matches("\\b(([01]?\\d?\\d|2[0-4]\\d|25[0-5])\\.){3}([01]?\\d?\\d|2[0-4]\\d|25[0-5])\\b")) {
Server.setTmpDiscoverUrl(str);
} else {
Server.setTmpDiscoverUrl(str);
}
sb.append(Server.getTmpDiscoverUrl());
if (!Server.getTmpDiscoverUrl().contains(":")) {
Server.setTmpDiscoverPort("30149");
sb.append(":");
sb.append(Server.getTmpDiscoverPort());
}
sb.append("/app/");
String str2 = this.a;
Log.d(str2, "lwx current path is " + ((Object) sb));
return AkeyChatUtils.discoverServerFromRemote(sb.toString(), "get_server_https");
}
public long getChildOrgCount(String str) {
ArrayList<Object> d2 = d(str);
if (d2 == null) {
return 0L;
}
return d2.size();
}
public BoxBean getCurrentBoxBean() {
return this.i;
}
public EnterpriseInfo getCurrentEnterpriseInfo() {
if (this.f == null) {
this.f = ye.getInstance().getmEnterpriseCfg().getCurrentEnterpriseInfo();
}
return this.f;
}
public String getDiscoverServerIpById(String str) {
StringBuilder sb = new StringBuilder();
sb.append("https://");
if (!str.contains(".")) {
Server.setTmpDiscoverUrl(b(str, ".pro.akeychat.cn"));
if (!ak.im.g2.c.a.isFlavor("beepchat") && !ak.im.g2.c.a.isFlavor("teleme")) {
h(str);
} else {
g(str);
}
} else if (str.matches("\\b(([01]?\\d?\\d|2[0-4]\\d|25[0-5])\\.){3}([01]?\\d?\\d|2[0-4]\\d|25[0-5])\\b")) {
Server.setTmpDiscoverUrl(str);
} else {
Server.setTmpDiscoverUrl(str);
}
sb.append(Server.getTmpDiscoverUrl());
if (!Server.getTmpDiscoverUrl().contains(":")) {
Server.setTmpDiscoverPort("30149");
sb.append(":");
sb.append(Server.getTmpDiscoverPort());
}
sb.append("/app/");
String str2 = this.a;
Log.d(str2, "lwx current path is " + ((Object) sb));
return sb.toString();
}
public String getDiscoverServerUrl(String str) {
if (TextUtils.isEmpty(str)) {
Log.w(this.a, " key is empty");
return "";
}
StringBuilder sb = new StringBuilder();
sb.append("https://");
if (!str.contains(".")) {
b(str, ".pro.akeychat.cn");
str = str + this.g;
} else {
str.matches("\\b(([01]?\\d?\\d|2[0-4]\\d|25[0-5])\\.){3}([01]?\\d?\\d|2[0-4]\\d|25[0-5])\\b");
}
sb.append(str);
if (!str.contains(":")) {
sb.append(":");
sb.append("30149");
}
sb.append("/app/");
Log.d(this.a, "getDiscoverServerUrl path is " + ((Object) sb));
return sb.toString();
}
public int getOrgNodeChildCountExceptForDirectChild(OrganizationBean organizationBean) {
int i = 0;
if (organizationBean == null) {
return 0;
}
Iterator<String> it = organizationBean.getChildIds().iterator();
while (it.hasNext()) {
i = (int) (i + getOrganizationById(it.next()).mCount);
}
return i;
}
public OrganizationBean getOrganizationById(String str) {
ConcurrentHashMap<String, OrganizationBean> concurrentHashMap = this.f891d;
if (concurrentHashMap == null) {
return null;
}
return concurrentHashMap.get(str);
}
public ArrayList<Object> getOrganizationList(String str) {
ArrayList<Object> d2 = d(str);
if (d2 != null) {
Collections.sort(d2, new ak.im.utils.b5());
}
return d2;
}
public ArrayList<String> getOrganizationListById(String str) {
if (this.f891d != null && !str.equals("0")) {
OrganizationBean organizationBean = this.f891d.get(str);
if (organizationBean == null) {
return new ArrayList<>();
}
this.f889b.add(organizationBean.mDepartment);
return getOrganizationListById(organizationBean.mParentId);
}
Collections.reverse(this.f889b);
ArrayList<String> arrayList = new ArrayList<>();
arrayList.addAll(this.f889b);
this.f889b.clear();
return arrayList;
}
public int getOrganizationSize() {
ConcurrentHashMap<String, OrganizationBean> concurrentHashMap = this.f891d;
if (concurrentHashMap == null) {
return 0;
}
return concurrentHashMap.size();
}
public String getOrgnaizationWithParentById(String str) {
OrganizationBean organizationBean;
OrganizationBean organizationBean2;
ConcurrentHashMap<String, OrganizationBean> concurrentHashMap = this.f891d;
String str2 = "";
if (concurrentHashMap == null || (organizationBean = concurrentHashMap.get(str)) == null) {
return "";
}
if (this.f891d.get(organizationBean.mParentId) != null) {
str2 = organizationBean2.getDisplayName() + "-";
}
return str2 + organizationBean.getDisplayName();
}
public Server getTmpServer() {
return this.h;
}
public void inflateOrganizationData(ArrayList<OrganizationBean> arrayList, boolean z) {
if (arrayList == null) {
Log.w(this.a, "org list is null");
return;
}
ConcurrentHashMap<String, OrganizationBean> concurrentHashMap = this.f891d;
if (concurrentHashMap == null) {
this.f891d = new ConcurrentHashMap<>(arrayList.size());
} else {
concurrentHashMap.clear();
}
int i = 0;
while (i < arrayList.size()) {
OrganizationBean organizationBean = arrayList.get(i);
i++;
for (int i2 = i; i2 < arrayList.size(); i2++) {
OrganizationBean organizationBean2 = arrayList.get(i2);
if (organizationBean2.mParentId.equals(organizationBean.mId)) {
organizationBean.addChildId(organizationBean2.mId);
organizationBean2.mParentId = organizationBean.mId;
} else if (organizationBean2.mId.equals(organizationBean.mParentId)) {
organizationBean2.addChildId(organizationBean.mId);
organizationBean.mParentId = organizationBean2.mId;
}
}
this.f891d.put(organizationBean.mId, organizationBean);
}
Iterator<OrganizationBean> it = arrayList.iterator();
while (it.hasNext()) {
OrganizationBean next = it.next();
next.refreshPinYin();
c(next);
}
OrgDepartmentManger.setDetailOrgNameInList(arrayList);
this.f892e = true;
if (!z) {
io.reactivex.z.timer(0L, TimeUnit.SECONDS, io.reactivex.w0.a.io()).map(new io.reactivex.s0.o() {
@Override
public final Object apply(Object obj) {
Long l = (Long) obj;
af.e(l);
return l;
}
}).subscribe();
return;
}
nf.getInstance().notifyOrganizationsDataSetUpdated();
df.getInstance().refreshSortLettersAmongGroups();
}
public void initOrganizations() {
if (this.f892e) {
Log.w(this.a, "had init do not need init it again");
return;
}
io.reactivex.z<ArrayList<OrganizationBean>> queryOrganizationFromServer = queryOrganizationFromServer();
if (queryOrganizationFromServer == null) {
Log.w(this.a, "observer is null");
} else {
queryOrganizationFromServer.subscribe(new b());
}
}
public boolean judgeDiscoverKeyToNewID(String str) {
return str.contains(".");
}
public Boolean judgeProductType() {
return Boolean.FALSE;
}
public EnterpriseInfo parseEnterpriseInfo(Server server) {
EnterpriseInfo enterpriseInfo = null;
try {
if (server == null) {
Log.w(this.a, "info obj is null");
return null;
}
this.h = server;
EnterpriseInfo enterpriseInfo2 = new EnterpriseInfo(server.getEnterpriseId());
try {
enterpriseInfo2.enterpriseName = server.getEnterpriseName();
enterpriseInfo2.discoverServerIP = Server.getTmpDiscoverUrl();
enterpriseInfo2.discoverServerPort = Server.getTmpDiscoverPort();
enterpriseInfo2.enterpriseLogoUrl = server.getEnterpriseLogo();
enterpriseInfo2.enterpriseDescription = server.getEnterpriseDes();
enterpriseInfo2.cloudVendor = server.getCloudFS();
enterpriseInfo2.uploadUrl = server.getQiniuUploadUrlPrefix();
enterpriseInfo2.downloadUrlPrefix = server.getQiniuDownloadUrlPrefix();
enterpriseInfo2.fileBucketName = server.getQiniuFileBucketName();
return enterpriseInfo2;
} catch (Exception e2) {
e = e2;
enterpriseInfo = enterpriseInfo2;
e.printStackTrace();
return enterpriseInfo;
}
} catch (Exception e3) {
e = e3;
}
}
public io.reactivex.z<ArrayList<OrganizationBean>> queryOrganizationFromLocal(String str) {
return io.reactivex.z.just(str).map(new io.reactivex.s0.o() {
@Override
public final Object apply(Object obj) {
return af.this.getOrganizationList((String) obj);
}
}).map(new io.reactivex.s0.o() {
@Override
public final Object apply(Object obj) {
return af.f((ArrayList) obj);
}
});
}
public io.reactivex.z<ArrayList<OrganizationBean>> queryOrganizationFromServer() {
io.reactivex.z<String> zVar;
StringBuilder sb = new StringBuilder();
sb.append("https://");
Server server = ye.getInstance().getServer();
if (server == null) {
Log.w(this.a, "info is null,query it again");
StringBuilder sb2 = new StringBuilder();
sb2.append("https://");
sb2.append(this.f.discoverServerIP);
if (!this.f.discoverServerIP.contains(":")) {
sb2.append(":");
sb2.append(this.f.discoverServerPort);
}
sb2.append("/app/");
zVar = AkeyChatUtils.discoverServerFromRemote(sb2.toString(), "get_server_https");
} else {
sb.append(server.getAppSrvHost());
sb.append(":");
sb.append(server.getAppSrvPort());
zVar = null;
}
if (zVar != null) {
return zVar.flatMap(new a(sb));
}
sb.append(CookieSpec.PATH_DELIM);
return ((ak.i.z) new m.b().baseUrl(sb.toString()).client(HttpURLTools.getOkHttpClientBuilder(sb.toString(), ye.getInstance().getAccessToken(), false).build()).addCallAdapterFactory(retrofit2.adapter.rxjava2.g.create()).addConverterFactory(retrofit2.p.a.a.create()).build().create(ak.i.z.class)).getOrganizations();
}
public void setCurrentBoxBean(BoxBean boxBean) {
this.i = boxBean;
}
public void setmCurrentEnterpriseInfo(EnterpriseInfo enterpriseInfo) {
this.f = enterpriseInfo;
}
private af() {
this.a = "EnterpriseManager";
this.f889b = new ArrayList<>();
this.f890c = ak.im.o1.get();
this.f = ye.getInstance().getmEnterpriseCfg().getCurrentEnterpriseInfo();
this.g = ".app.boxnet.org.cn";
}
}