public UpdateMD5Command() {
super(ServerCommands.UPDATE_MD5.NAME);
}
public Object securedInvoke(UAK uak, Map m) {
final ModuleDescriptorDao dao = WOJServer.getInstance().getDataService().getModuleDescriptorDao();
String wojBaseDir = ((FileContentService) WOJServer.getInstance().getContentService()).getBaseDir()+"/"+Visibility.PUBLIC.getName();
File wojBaseDirFile = new File(wojBaseDir);
File[] orgs = wojBaseDirFile.listFiles();
for (int i = 0; i < orgs.length; i++) {
File org = orgs[i];
File[] modules = org.listFiles();
for (int j = 0; j < modules.length; j++) {
File module = modules[j];
File[] revs = module.listFiles();
for (int k = 0; k < revs.length; k++) {
File rev = revs[k];
ModuleDescriptor md = dao.getModuleDescriptor(org.getName(), module.getName(), rev.getName(), uak.getUserId(), uak.getGroups(),Visibility.PUBLIC);
if(md != null && !md.isNew()) {
File[] jars = new File(rev.getAbsolutePath()+"/"+Parameters.BINARIES_FOLDER).listFiles(new FileFilter() {
public boolean accept(File pathname) {
return pathname.getName().endsWith("zip") || pathname.getName().endsWith("jar") ;
}
});
if(jars != null && jars.length >0) {
String md5s[] = new String[jars.length];
for (int index = 0; index < jars.length; index++) {
File jar = jars[index];
md5s[index] = ChecksumUtil.MD5.computeAsString(jar.getAbsolutePath());
}
dao.addMd5s(md, md5s);
//just to avoid server overcharge
try {
Thread.sleep(100);
} catch (InterruptedException e) {}
}