public static String generateFormattedGUID() { //xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx String guid = generateGUID(); return guid.substring(0, 8) + '-' + guid.substring(8, 12) + '-' + guid.substring(12, 16) + '-' + guid.substring(16, 20) + '-' + guid.substring(20); }
public static void main(String[] args) { for (int i = 1; i <= 100; i++) { System.out.println("guid = " + GUID.generateFormattedGUID()); } } }
public static String generateFormattedGUID() { //xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx String guid = generateGUID(); return guid.substring(0, 8) + '-' + guid.substring(8, 12) + '-' + guid.substring(12, 16) + '-' + guid.substring(16, 20) + '-' + guid.substring(20); }
/** * Sets a transaction token into the session using the provided token name. * * @param tokenName the name to store into the session with the token as the value * @return the token string */ public static String setToken(String tokenName) { Map session = ActionContext.getContext().getSession(); String token = GUID.generateGUID(); try { session.put(tokenName, token); } catch(IllegalStateException e) { // WW-1182 explain to user what the problem is String msg = "Error creating HttpSession due response is commited to client. You can use the CreateSessionInterceptor or create the HttpSession from your action before the result is rendered to the client: " + e.getMessage(); LOG.error(msg, e); throw new IllegalArgumentException(msg); } return token; }