class OresHelper {

    public static String createStringRepresenting(OLATResourceable ores, String subKey) {
        String resourcableTypeName = ores.getResourceableTypeName();
        if (resourcableTypeName.length() > 80) {
            // encode into an md5 hash with fixed length of 32 characters otherwise the sting may get too long for locks or db fields
            resourcableTypeName = Encoder.encrypt(resourcableTypeName);
        }
        String derivedString = resourcableTypeName + "::" + ores.getResourceableId();
        if (subKey != null) {
            if (subKey.length() > 25) {
                // 25 is the max if the above becomes 80 + 2 + 12 + @
                // so we only add the last 25 characters
                subKey = subKey.substring(subKey.length() - 25, subKey.length());
            }
            derivedString = subKey + "@" + derivedString;
            // was: derivedString += "::"+subKey;
        }
        return derivedString;
    }

}