All Downloads are FREE. Search and download functionalities are using the official Maven repository.

prerna.util.ProjectSyncUtility Maven / Gradle / Ivy

The newest version!
package prerna.util;

import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.locks.ReentrantLock;

import prerna.auth.User;
import prerna.auth.utils.SecurityAdminUtils;

public class ProjectSyncUtility {

	private static ConcurrentMap prorjectLocks = new ConcurrentHashMap<>();

	public static ReentrantLock getProjectLock(String projectId) {
		prorjectLocks.putIfAbsent(projectId, new ReentrantLock());
		return prorjectLocks.get(projectId);
	}
	
	public static ConcurrentMap getAllLocks(User user) {
		if(!SecurityAdminUtils.userIsAdmin(user)) {
			throw new IllegalArgumentException("User must be an admin to perform this method");
		}
		return prorjectLocks;
	}
	
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy