Skip to main content
All CollectionsSystem TasksWorking with Groovy ScriptsGroovy Script Library
Groovy Script - Push associated files to Bluebeam Studio
Groovy Script - Push associated files to Bluebeam Studio
Updated this week

Description: Sample groovy script to push associated files to Bluebeam Studio

Click here for detailed help.

Context: App

Remark: Accessible in 'Post' task mode only

Script:

def execute(){

def bluebeamInstance = customService.createInstance("Bluebeam",ContextEnum.FORM_CONTEXT);

Map<String,Object> formAssocsMap = new HashMap<String,Object>();

formAssocsMap.put(IGroovyConstant.FORM_ASSOCS,formService.getFormAssociations("ALL_MSGS"));

Map<String,Object> filesMap = bluebeamInstance.filterSupportedFilesFromAssoc(formAssocsMap);

FormVO form = formService.getFormDetails(true);

if(filesMap.size() > 0) {

Map<String,Object> tokenMap = new HashMap<>();

tokenMap.put(IGroovyConstant.ACTION_USERID,formService.getActionUserId());

String accessToken = bluebeamInstance.getTocken(tokenMap);

Map<String,Object> createSessionMap = new HashMap<>();

SessionCreateDTO session = getSessionCreateDTO(accessToken);

createSessionMap.put(IGroovyConstant.SESSION_DTO,session);

Map<String,String> sessionIdTokenMap = bluebeamInstance.createSession(createSessionMap);

Map<String,Object> addUsersMap = new HashMap<>();

addUsersMap.putAll(sessionIdTokenMap);

addUsersMap.put(IGroovyConstant.DIST_USER_LIST,formService.getFormDistributionList());

bluebeamInstance.addUsers(addUsersMap);

Map<String,Object> getShareLinksMap = new HashMap<>();

getShareLinksMap.putAll(filesMap);

Map<String,Map<String,String>> shareLinksMap = documentService.getShareLinkOfAssociations(getShareLinksMap);

Map<String,Object> pushFilesMap = new HashMap<>();

pushFilesMap.put(IGroovyConstant.SUPPORTED_FILES_REVIDS, filesMap.get(IGroovyConstant.SUPPORTED_FILES_REVIDS));

pushFilesMap.put(IGroovyConstant.SHARE_LINKS, shareLinksMap);

pushFilesMap.put(IGroovyConstant.FORM_VO,form);

pushFilesMap.putAll(sessionIdTokenMap);

bluebeamInstance.push(pushFilesMap);

} else {

return getFailedScriptResposne("Form associations not contains any supported files.");

}

}

private getFailedScriptResposne(String errorMsg) {

FormVO formVO = new FormVO();

formVO.setResponseStatus(false);

formVO.setResponseMessage(errorMsg);

return formVO;

}

private SessionCreateDTO getSessionCreateDTO(String accessToken) {

SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH-mm-ss.SSS");

String sessionName = "Test" + dateFormat.format(new Date());

String sessionEndDate = "";

boolean isSendNotification = true;

boolean isRestricted = true;

SessionCreateDTO session = new SessionCreateDTO();

session.setName(sessionName);

session.setSendNotification(isSendNotification);

session.setRestricted(isRestricted);

session.setSessionEndDate(sessionEndDate);

session.setAccessToken(accessToken);

session.setDefaultPermissions(getDefaultPermissions());

return session;

}

private List<PermissionVO> getDefaultPermissions() {

List<PermissionVO> permissionList = new ArrayList<>();

String ALLOW = "Allow";

String DENY = "Deny";

permissionList.add(getPermission("SaveCopy",ALLOW));

permissionList.add(getPermission("PrintCopy",ALLOW));

permissionList.add(getPermission("Markup",ALLOW));

permissionList.add(getPermission("MarkupAlert",ALLOW));

permissionList.add(getPermission("AddDocuments",DENY));

permissionList.add(getPermission("FullControl",DENY));

return permissionList;

}

private PermissionVO getPermission(String permissionName, String permission) {

PermissionVO permissionVO = new PermissionVO();

permissionVO.setType(permissionName);

permissionVO.setAllow(permission);

return permissionVO;

}



Did this answer your question?