public Folder initFolderService(ActionRequest actionRequest,ThemeDisplay themeDisplay){
  String dateFolderName=DateTimeUtil.getStringDate();
  Folder folder=null;
  try {
    long rootFolderId=0;
    long parentFolderId=0;
    boolean isRootFolderExist=isFolderExist(themeDisplay.getScopeGroupId(),0,ROOT_FOLDER_NAME);
    ServiceContext serviceContext=ServiceContextFactory.getInstance(actionRequest);
    serviceContext.setAddGroupPermissions(true);
    serviceContext.setAddGuestPermissions(true);
    if (isRootFolderExist) {
      Folder rootFolder=null;
      rootFolder=DLAppServiceUtil.getFolder(themeDisplay.getScopeGroupId(),0,ROOT_FOLDER_NAME);
      rootFolderId=rootFolder.getFolderId();
    }
 else {
      Folder rootFolder=DLAppServiceUtil.addFolder(themeDisplay.getScopeGroupId(),0,ROOT_FOLDER_NAME,"All documents of OpenCPS",serviceContext);
      rootFolderId=rootFolder.getFolderId();
    }
    boolean isParentFolderExist=isFolderExist(themeDisplay.getScopeGroupId(),rootFolderId,PARENT_FOLDER_NAME);
    if (isParentFolderExist) {
      Folder parentFolder=DLAppServiceUtil.getFolder(themeDisplay.getScopeGroupId(),rootFolderId,PARENT_FOLDER_NAME);
      parentFolderId=parentFolder.getFolderId();
    }
 else {
      Folder parentFolder=DLAppServiceUtil.addFolder(themeDisplay.getScopeGroupId(),rootFolderId,PARENT_FOLDER_NAME,"All documents of Service Template File",serviceContext);
      parentFolderId=parentFolder.getFolderId();
    }
    boolean isDateFolderExist=isFolderExist(themeDisplay.getScopeGroupId(),parentFolderId,dateFolderName);
    Folder dateFolder=null;
    if (isDateFolderExist) {
      dateFolder=DLAppServiceUtil.getFolder(themeDisplay.getScopeGroupId(),parentFolderId,dateFolderName);
    }
 else {
      dateFolder=DLAppServiceUtil.addFolder(themeDisplay.getScopeGroupId(),parentFolderId,dateFolderName,"All documents of Service Template File upload in a day",serviceContext);
    }
    folder=dateFolder;
  }
 catch (  Exception e) {
  }
  return folder;
}

public Folder initFolderService ( ActionRequest actionRequest , ThemeDisplay themeDisplay ) { String dateFolderName = DateTimeUtil . getStringDate ( ) ; Folder folder = null ; try { long rootFolderId = 0 ; long parentFolderId = 0 ; boolean isRootFolderExist = isFolderExist ( themeDisplay . getScopeGroupId ( ) , 0 , ROOT_FOLDER_NAME ) ; ServiceContext serviceContext = ServiceContextFactory . getInstance ( actionRequest ) ; serviceContext . setAddGroupPermissions ( true ) ; serviceContext . setAddGuestPermissions ( true ) ; if ( isRootFolderExist ) { Folder rootFolder = null ; rootFolder = DLAppServiceUtil . getFolder ( themeDisplay . getScopeGroupId ( ) , 0 , ROOT_FOLDER_NAME ) ; rootFolderId = rootFolder . getFolderId ( ) ; } else { Folder rootFolder = DLAppServiceUtil . addFolder ( themeDisplay . getScopeGroupId ( ) , 0 , ROOT_FOLDER_NAME , "All documents of OpenCPS" , serviceContext ) ; rootFolderId = rootFolder . getFolderId ( ) ; } boolean isParentFolderExist = isFolderExist ( themeDisplay . getScopeGroupId ( ) , rootFolderId , PARENT_FOLDER_NAME ) ; if ( isParentFolderExist ) { Folder parentFolder = DLAppServiceUtil . getFolder ( themeDisplay . getScopeGroupId ( ) , rootFolderId , PARENT_FOLDER_NAME ) ; parentFolderId = parentFolder . getFolderId ( ) ; } else { Folder parentFolder = DLAppServiceUtil . addFolder ( themeDisplay . getScopeGroupId ( ) , rootFolderId , PARENT_FOLDER_NAME , "All documents of Service Template File" , serviceContext ) ; parentFolderId = parentFolder . getFolderId ( ) ; } boolean isDateFolderExist = isFolderExist ( themeDisplay . getScopeGroupId ( ) , parentFolderId , dateFolderName ) ; Folder dateFolder = null ; if ( isDateFolderExist ) { dateFolder = DLAppServiceUtil . getFolder ( themeDisplay . getScopeGroupId ( ) , parentFolderId , dateFolderName ) ; } else { dateFolder = DLAppServiceUtil . addFolder ( themeDisplay . getScopeGroupId ( ) , parentFolderId , dateFolderName , "All documents of Service Template File upload in a day" , serviceContext ) ; } folder = dateFolder ; } catch ( Exception e ) { } return folder ; }
create tree folder . return folder contains template files
