001/* 002 * This library is part of OpenCms - 003 * the Open Source Content Management System 004 * 005 * Copyright (c) Alkacon Software GmbH & Co. KG (http://www.alkacon.com) 006 * 007 * This library is free software; you can redistribute it and/or 008 * modify it under the terms of the GNU Lesser General Public 009 * License as published by the Free Software Foundation; either 010 * version 2.1 of the License, or (at your option) any later version. 011 * 012 * This library is distributed in the hope that it will be useful, 013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 015 * Lesser General Public License for more details. 016 * 017 * For further information about Alkacon Software, please see the 018 * company website: http://www.alkacon.com 019 * 020 * For further information about OpenCms, please see the 021 * project website: http://www.opencms.org 022 * 023 * You should have received a copy of the GNU Lesser General Public 024 * License along with this library; if not, write to the Free Software 025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 026 */ 027 028package org.opencms.ui.apps.user; 029 030import org.opencms.file.CmsObject; 031import org.opencms.file.CmsUser; 032import org.opencms.main.CmsException; 033import org.opencms.main.CmsLog; 034import org.opencms.main.CmsRuntimeException; 035import org.opencms.main.OpenCms; 036import org.opencms.security.CmsRole; 037import org.opencms.security.I_CmsPrincipal; 038import org.opencms.ui.A_CmsUI; 039import org.opencms.ui.CmsVaadinUtils; 040import org.opencms.ui.apps.Messages; 041import org.opencms.ui.components.CmsBasicDialog; 042import org.opencms.ui.components.CmsConfirmationDialog; 043import org.opencms.ui.components.editablegroup.CmsEditableGroup; 044import org.opencms.ui.components.editablegroup.I_CmsEditableGroupRow; 045import org.opencms.ui.dialogs.permissions.CmsPrincipalSelect; 046import org.opencms.ui.dialogs.permissions.CmsPrincipalSelect.WidgetType; 047import org.opencms.util.CmsStringUtil; 048import org.opencms.util.CmsUUID; 049import org.opencms.util.CmsXsltUtil; 050 051import java.io.BufferedReader; 052import java.io.ByteArrayInputStream; 053import java.io.ByteArrayOutputStream; 054import java.io.FileReader; 055import java.io.IOException; 056import java.io.InputStreamReader; 057import java.io.OutputStream; 058import java.lang.reflect.InvocationTargetException; 059import java.lang.reflect.Method; 060import java.util.ArrayList; 061import java.util.HashMap; 062import java.util.Iterator; 063import java.util.List; 064import java.util.Map; 065 066import org.apache.commons.logging.Log; 067 068import com.google.common.base.Splitter; 069import com.google.common.base.Supplier; 070import com.vaadin.data.HasValue.ValueChangeEvent; 071import com.vaadin.data.HasValue.ValueChangeListener; 072import com.vaadin.ui.Button; 073import com.vaadin.ui.Button.ClickEvent; 074import com.vaadin.ui.CheckBox; 075import com.vaadin.ui.ComboBox; 076import com.vaadin.ui.Component; 077import com.vaadin.ui.Label; 078import com.vaadin.ui.Panel; 079import com.vaadin.ui.TabSheet; 080import com.vaadin.ui.TextField; 081import com.vaadin.ui.Upload; 082import com.vaadin.ui.Upload.Receiver; 083import com.vaadin.ui.Upload.SucceededEvent; 084import com.vaadin.ui.VerticalLayout; 085import com.vaadin.ui.Window; 086 087/** 088 * Dialog for CSV im- and export.<p> 089 */ 090public final class CmsImportExportUserDialog extends A_CmsImportExportUserDialog 091implements Receiver, I_CmsPasswordFetcher { 092 093 /** The "bom" bytes as String that need to be placed at the very beginning of the produced csv. */ 094 private static final String BOM = "\ufeff"; 095 096 /**The dialog height. */ 097 public static final String DIALOG_HEIGHT = "650px"; 098 099 /** Log instance for this class. */ 100 static final Log LOG = CmsLog.getLog(CmsImportExportUserDialog.class); 101 102 /**vaadin serial id. */ 103 private static final long serialVersionUID = -2055302491540892101L; 104 105 /**Label to show uploaded file. */ 106 protected Label m_uploadname; 107 108 /**Start import button. */ 109 Button m_startImport; 110 111 /**Vaadin Component. */ 112 private Panel m_includeTechnicalFieldsPanel; 113 114 /**Vaadin Component. */ 115 private CheckBox m_includeTechnicalFields; 116 117 /**Cancel button. */ 118 private Button m_cancel; 119 120 /**CmsObject. */ 121 private CmsObject m_cms; 122 123 /**Download button for export. */ 124 private Button m_download; 125 126 /**Layout for groups. */ 127 private VerticalLayout m_exportGroups; 128 129 /**Groups. */ 130 private CmsEditableGroup m_exportGroupsGroup; 131 132 /**Layout for roles. */ 133 private VerticalLayout m_exportRoles; 134 135 /**Roles. */ 136 private CmsEditableGroup m_exportRolesGroup; 137 138 /**Generate password button. */ 139 private Button m_generateButton; 140 141 /**Should the group field be editable? */ 142 private boolean m_groupEditable = true; 143 144 /**ID of group. */ 145 private CmsUUID m_groupID; 146 147 /**Stream for upload file. */ 148 private ByteArrayOutputStream m_importFileStream; 149 150 /**Layout for groups.*/ 151 private VerticalLayout m_importGroups; 152 153 /**Groups. */ 154 private CmsEditableGroup m_importGroupsGroup; 155 156 /**Should password be imported? */ 157 private CheckBox m_importPasswords; 158 159 /**Layout for roles. */ 160 private VerticalLayout m_importRoles; 161 162 /**Roles. */ 163 private CmsEditableGroup m_importRolesGroup; 164 165 /**Password for imported user. */ 166 private TextField m_password; 167 168 /**List of user to import. */ 169 List<CmsUser> m_userImportList; 170 171 /**Should the user get an email? */ 172 private CheckBox m_sendMail; 173 174 /**Tab with import and export sheet. */ 175 private TabSheet m_tab; 176 177 /**Upload for import. */ 178 private Upload m_upload; 179 180 /** 181 * public constructor.<p> 182 * 183 * @param ou ou name 184 * @param groupID id of group 185 * @param window window 186 * @param allowTechnicalFieldsExport flag indicates if technical field export option should be available 187 */ 188 private CmsImportExportUserDialog( 189 final String ou, 190 CmsUUID groupID, 191 Window window, 192 boolean allowTechnicalFieldsExport) { 193 194 setHeight(DIALOG_HEIGHT); 195 196 m_groupID = groupID; 197 198 try { 199 m_cms = OpenCms.initCmsObject(A_CmsUI.getCmsObject()); 200 } catch (CmsException e1) { 201 // 202 } 203 CmsVaadinUtils.readAndLocalizeDesign(this, CmsVaadinUtils.getWpMessagesForCurrentLocale(), null); 204 m_includeTechnicalFieldsPanel.setVisible(allowTechnicalFieldsExport); 205 m_includeTechnicalFields.addValueChangeListener(new ValueChangeListener<Boolean>() { 206 207 public void valueChange(ValueChangeEvent event) { 208 209 initDownloadButton(); 210 211 } 212 213 }); 214 m_importPasswords.setValue(Boolean.TRUE); 215 m_sendMail.setValue(Boolean.TRUE); 216 217 setButtonVisibility(0); 218 219 m_tab.addSelectedTabChangeListener( 220 event -> setButtonVisibility(m_tab.getTabPosition(m_tab.getTab(m_tab.getSelectedTab())))); 221 222 m_password.setValue(CmsGeneratePasswordDialog.getRandomPassword()); 223 m_startImport.setEnabled(false); 224 m_startImport.addClickListener(event -> importUserFromFile()); 225 226 m_generateButton.addClickListener(new Button.ClickListener() { 227 228 private static final long serialVersionUID = 4128513094772586752L; 229 230 public void buttonClick(ClickEvent event) { 231 232 final Window windowDialog = CmsBasicDialog.prepareWindow(CmsBasicDialog.DialogWidth.content); 233 windowDialog.setCaption( 234 CmsVaadinUtils.getMessageText(Messages.GUI_USERMANAGEMENT_GEN_PASSWORD_CAPTION_0)); 235 CmsGeneratePasswordDialog dialog = new CmsGeneratePasswordDialog( 236 CmsImportExportUserDialog.this, 237 new Runnable() { 238 239 public void run() { 240 241 windowDialog.close(); 242 243 } 244 }); 245 windowDialog.setContent(dialog); 246 A_CmsUI.get().addWindow(windowDialog); 247 } 248 }); 249 250 m_upload.setReceiver(this); 251 252 m_upload.addSucceededListener(new Upload.SucceededListener() { 253 254 private static final long serialVersionUID = -6865652127878123021L; 255 256 public void uploadSucceeded(SucceededEvent event) { 257 258 try { 259 m_userImportList = getUsersFromFile(); 260 m_startImport.setEnabled(true); 261 m_uploadname.setValue(event.getFilename()); 262 } catch (Exception e) { 263 //wrong csv columns 264 m_startImport.setEnabled(false); 265 m_uploadname.setValue(""); 266 CmsConfirmationDialog.show( 267 CmsVaadinUtils.getMessageText(Messages.GUI_USERMANAGEMENT_USER_IMEXPORT_INVALID_FILE_0), 268 CmsVaadinUtils.getMessageText(Messages.GUI_USERMANAGEMENT_USER_IMEXPORT_INVALID_CSV_0), 269 new Runnable() { 270 271 public void run() { 272 273 } 274 275 }); 276 } 277 } 278 }); 279 280 if (groupID == null) { 281 282 m_importGroupsGroup = new CmsEditableGroup(m_importGroups, new Supplier<Component>() { 283 284 public Component get() { 285 286 return getGroupSelect(ou, true, null); 287 } 288 289 }, CmsVaadinUtils.getMessageText(Messages.GUI_USERMANAGEMENT_USER_IMEXPORT_ADD_GROUP_0)); 290 291 m_importGroupsGroup.init(); 292 293 m_exportGroupsGroup = new CmsEditableGroup(m_exportGroups, new Supplier<Component>() { 294 295 public Component get() { 296 297 return getGroupSelect(ou, true, null); 298 } 299 300 }, CmsVaadinUtils.getMessageText(Messages.GUI_USERMANAGEMENT_USER_IMEXPORT_ADD_GROUP_0)); 301 302 m_exportGroupsGroup.init(); 303 } else { 304 m_exportGroups.addComponent(getGroupSelect(ou, false, groupID)); 305 m_importGroups.addComponent(getGroupSelect(ou, false, groupID)); 306 } 307 308 m_importRolesGroup = new CmsEditableGroup(m_importRoles, new Supplier<Component>() { 309 310 public Component get() { 311 312 return getRoleComboBox(ou); 313 } 314 315 }, CmsVaadinUtils.getMessageText(Messages.GUI_USERMANAGEMENT_USER_IMEXPORT_ADD_ROLE_0)); 316 317 m_importRolesGroup.init(); 318 319 m_exportRolesGroup = new CmsEditableGroup(m_exportRoles, new Supplier<Component>() { 320 321 public Component get() { 322 323 return getRoleComboBox(ou); 324 } 325 326 }, CmsVaadinUtils.getMessageText(Messages.GUI_USERMANAGEMENT_USER_IMEXPORT_ADD_ROLE_0)); 327 328 m_exportRolesGroup.init(); 329 330 super.init(ou, window); 331 332 } 333 334 /** 335 * Returns a map with the users to export added.<p> 336 * @param cms CmsObject 337 * @param ou ou name 338 * @param exportUsers the map to add the users 339 * @return a map with the users to export added 340 * @throws CmsException if getting users failed 341 */ 342 public static Map<CmsUUID, CmsUser> addExportAllUsers(CmsObject cms, String ou, Map<CmsUUID, CmsUser> exportUsers) 343 throws CmsException { 344 345 List<CmsUser> users = OpenCms.getOrgUnitManager().getUsers(cms, ou, false); 346 if ((users != null) && (users.size() > 0)) { 347 Iterator<CmsUser> itUsers = users.iterator(); 348 while (itUsers.hasNext()) { 349 CmsUser user = itUsers.next(); 350 if (!exportUsers.containsKey(user.getId())) { 351 exportUsers.put(user.getId(), user); 352 } 353 } 354 } 355 return exportUsers; 356 } 357 358 /** 359 * Returns a map with the users to export added.<p> 360 * @param cms CmsObject 361 * @param groups the selected groups 362 * @param exportUsers the map to add the users 363 * 364 * @return a map with the users to export added 365 * 366 * @throws CmsException if getting groups or users of group failed 367 */ 368 public static Map<CmsUUID, CmsUser> addExportUsersFromGroups( 369 CmsObject cms, 370 List<String> groups, 371 Map<CmsUUID, CmsUser> exportUsers) 372 throws CmsException { 373 374 if ((groups != null) && (groups.size() > 0)) { 375 Iterator<String> itGroups = groups.iterator(); 376 while (itGroups.hasNext()) { 377 List<CmsUser> groupUsers = cms.getUsersOfGroup(itGroups.next()); 378 Iterator<CmsUser> itGroupUsers = groupUsers.iterator(); 379 while (itGroupUsers.hasNext()) { 380 CmsUser groupUser = itGroupUsers.next(); 381 if (!exportUsers.containsKey(groupUser.getId())) { 382 exportUsers.put(groupUser.getId(), groupUser); 383 } 384 } 385 } 386 } 387 return exportUsers; 388 } 389 390 /** 391 * Returns a map with the users to export added.<p> 392 * @param cms CmsObject 393 * @param ou ou name 394 * 395 * @param roles the selected roles 396 * @param exportUsers the map to add the users 397 * 398 * @return a map with the users to export added 399 * 400 * @throws CmsException if getting roles or users of role failed 401 */ 402 public static Map<CmsUUID, CmsUser> addExportUsersFromRoles( 403 CmsObject cms, 404 String ou, 405 List<String> roles, 406 Map<CmsUUID, CmsUser> exportUsers) 407 throws CmsException { 408 409 if ((roles != null) && (roles.size() > 0)) { 410 Iterator<String> itRoles = roles.iterator(); 411 while (itRoles.hasNext()) { 412 List<CmsUser> roleUsers = OpenCms.getRoleManager().getUsersOfRole( 413 cms, 414 CmsRole.valueOfGroupName(itRoles.next()).forOrgUnit(ou), 415 true, 416 false); 417 Iterator<CmsUser> itRoleUsers = roleUsers.iterator(); 418 while (itRoleUsers.hasNext()) { 419 CmsUser roleUser = itRoleUsers.next(); 420 // contains 421 if (exportUsers.get(roleUser.getId()) == null) { 422 exportUsers.put(roleUser.getId(), roleUser); 423 } 424 } 425 } 426 } 427 return exportUsers; 428 } 429 430 /** 431 * Gets an dialog instance for fixed group.<p> 432 * 433 * @param groupID id 434 * @param ou ou name 435 * @param window window 436 * @param allowTechnicalFieldsExport flag indicates if technical field export option should be available 437 * @return an instance of this class 438 */ 439 public static CmsImportExportUserDialog getExportUserDialogForGroup( 440 CmsUUID groupID, 441 String ou, 442 Window window, 443 boolean allowTechnicalFieldsExport) { 444 445 CmsImportExportUserDialog res = new CmsImportExportUserDialog(ou, groupID, window, allowTechnicalFieldsExport); 446 return res; 447 } 448 449 /** 450 * Gets an dialog instance for fixed group.<p> 451 * 452 * @param ou ou name 453 * @param window window 454 * @param allowTechnicalFieldsExport flag indicates if technical field export option should be available 455 * @return an instance of this class 456 */ 457 public static CmsImportExportUserDialog getExportUserDialogForOU( 458 String ou, 459 Window window, 460 boolean allowTechnicalFieldsExport) { 461 462 CmsImportExportUserDialog res = new CmsImportExportUserDialog(ou, null, window, allowTechnicalFieldsExport); 463 return res; 464 } 465 466 /** 467 * @see org.opencms.ui.apps.user.I_CmsPasswordFetcher#fetchPassword(java.lang.String) 468 */ 469 public void fetchPassword(String password) { 470 471 m_password.setValue(password); 472 473 } 474 475 /** 476 * @see com.vaadin.ui.Upload.Receiver#receiveUpload(java.lang.String, java.lang.String) 477 */ 478 public OutputStream receiveUpload(String filename, String mimeType) { 479 480 m_importFileStream = new ByteArrayOutputStream(); 481 return m_importFileStream; 482 } 483 484 /** 485 * Get a principle select for choosing groups.<p> 486 * 487 * @param ou name 488 * @param enabled enabled? 489 * @param groupID default value 490 * @return CmsPrinicpalSelect 491 */ 492 protected CmsPrincipalSelect getGroupSelect(String ou, boolean enabled, CmsUUID groupID) { 493 494 CmsPrincipalSelect select = new CmsPrincipalSelect(); 495 select.setOU(ou); 496 select.setEnabled(enabled); 497 select.setRealPrincipalsOnly(true); 498 select.setPrincipalType(I_CmsPrincipal.PRINCIPAL_GROUP); 499 select.setWidgetType(WidgetType.groupwidget); 500 501 if (groupID != null) { 502 try { 503 select.setValue(m_cms.readGroup(groupID).getName()); 504 } catch (CmsException e) { 505 LOG.error("Unable to read group", e); 506 } 507 } 508 509 //OU Change enabled because ou-user can be part of other ou-groups 510 return select; 511 } 512 513 /** 514 * Get ComboBox for selecting roles.<p> 515 * 516 * @param ou name 517 * @return ComboBox 518 */ 519 protected ComboBox<CmsRole> getRoleComboBox(String ou) { 520 521 ComboBox<CmsRole> box = new ComboBox<CmsRole>(); 522 CmsUserEditDialog.iniRole(A_CmsUI.getCmsObject(), ou, box, null); 523 box.setSelectedItem(CmsRole.EDITOR.forOrgUnit(ou)); 524 525 return box; 526 } 527 528 /** 529 * Reads user from import file.<p> 530 * 531 * @return List of user (with passwords) 532 */ 533 protected List<CmsUser> getUsersFromFile() { 534 535 String separator = null; 536 List values = null; 537 538 FileReader fileReader; 539 BufferedReader bufferedReader; 540 List<CmsUser> users = null; 541 542 boolean keepPasswordIfPossible = m_importPasswords.getValue().booleanValue(); 543 544 try { 545 bufferedReader = new BufferedReader( 546 new InputStreamReader(new ByteArrayInputStream(m_importFileStream.toByteArray()))); 547 String line; 548 boolean headline = true; 549 boolean hasBOM = false; 550 while ((line = bufferedReader.readLine()) != null) { 551 if (users == null) { 552 users = new ArrayList<CmsUser>(); 553 } 554 if (separator == null) { 555 separator = CmsXsltUtil.getPreferredDelimiter(line); 556 } 557 List lineValues = Splitter.on(separator).splitToList(line); 558 if (headline) { 559 values = new ArrayList(); 560 Iterator itLineValues = lineValues.iterator(); 561 while (itLineValues.hasNext()) { 562 String va = (String)itLineValues.next(); 563 if (va.startsWith(BOM) && va.substring(1, 2).equals("\"")) { 564 hasBOM = true; 565 va = va.substring(1); //Cut BOM 566 } 567 if (hasBOM) { 568 va = va.substring(1, va.length() - 1); 569 } 570 //} 571 values.add(va); 572 } 573 headline = false; 574 } else if (values != null) { 575 CmsUser curUser = new CmsUser(); 576 try { 577 for (int i = 0; i < values.size(); i++) { 578 String curValue = (String)values.get(i); 579 try { 580 Method method = CmsUser.class.getMethod( 581 "set" + curValue.substring(0, 1).toUpperCase() + curValue.substring(1), 582 new Class[] {String.class}); 583 String value = ""; 584 if ((lineValues.size() > i) && (lineValues.get(i) != null)) { 585 value = (String)lineValues.get(i); 586 if (hasBOM) { 587 588 value = value.substring(1, value.length() - 1); 589 } 590 591 } 592 if (curValue.equals("password")) { 593 if (CmsStringUtil.isEmptyOrWhitespaceOnly(value) | !keepPasswordIfPossible) { 594 value = m_password.getValue(); 595 } 596 } 597 if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(value) && !value.equals("null")) { 598 method.invoke(curUser, new Object[] {value}); 599 } 600 } catch (NoSuchMethodException ne) { 601 if (!CmsStringUtil.isEmptyOrWhitespaceOnly((String)lineValues.get(i))) { 602 curUser.setAdditionalInfo(curValue, lineValues.get(i)); 603 } 604 } catch (IllegalAccessException le) { 605 // 606 } catch (InvocationTargetException te) { 607 // 608 } 609 } 610 } catch (CmsRuntimeException e) { 611 // 612 } 613 users.add(curUser); 614 } 615 } 616 bufferedReader.close(); 617 } catch (IOException e) { 618 //noop 619 } 620 621 return users; 622 } 623 624 /** 625 * Import user from file. 626 */ 627 protected void importUserFromFile() { 628 629 CmsImportUserThread thread = new CmsImportUserThread( 630 m_cms, 631 m_ou, 632 m_userImportList, 633 getGroupsList(m_importGroups, true), 634 getRolesList(m_importRoles, true), 635 m_sendMail.getValue().booleanValue()); 636 thread.start(); 637 CmsShowReportDialog dialog = new CmsShowReportDialog(thread, new Runnable() { 638 639 public void run() { 640 641 m_window.close(); 642 } 643 }); 644 m_window.setContent(dialog); 645 646 } 647 648 /** 649 * @see org.opencms.ui.apps.user.A_CmsImportExportUserDialog#getCloseButton() 650 */ 651 @Override 652 Button getCloseButton() { 653 654 return m_cancel; 655 } 656 657 /** 658 * @see org.opencms.ui.apps.user.A_CmsImportExportUserDialog#getDownloadButton() 659 */ 660 @Override 661 Button getDownloadButton() { 662 663 return m_download; 664 } 665 666 /** 667 * @see org.opencms.ui.apps.user.A_CmsImportExportUserDialog#getUserToExport() 668 */ 669 @Override 670 Map<CmsUUID, CmsUser> getUserToExport() { 671 672 // get the data object from session 673 List<String> groups = getGroupsList(m_exportGroups, false); 674 675 Iterator<I_CmsEditableGroupRow> it = m_exportRolesGroup.getRows().iterator(); 676 List<String> roles = new ArrayList<String>(); 677 while (it.hasNext()) { 678 CmsRole role = (CmsRole)((ComboBox)it.next().getComponent()).getValue(); 679 roles.add(role.getGroupName()); 680 } 681 682 Map<CmsUUID, CmsUser> exportUsers = new HashMap<CmsUUID, CmsUser>(); 683 try { 684 if (((groups.size() < 1)) && ((roles.size() < 1))) { 685 exportUsers = CmsImportExportUserDialog.addExportAllUsers(m_cms, m_ou, exportUsers); 686 } else { 687 exportUsers = CmsImportExportUserDialog.addExportUsersFromGroups(m_cms, groups, exportUsers); 688 exportUsers = CmsImportExportUserDialog.addExportUsersFromRoles(m_cms, m_ou, roles, exportUsers); 689 } 690 } catch (CmsException e) { 691 LOG.error("Unable to get export user list.", e); 692 } 693 return exportUsers; 694 } 695 696 /** 697 * @see org.opencms.ui.apps.user.A_CmsImportExportUserDialog#isExportWithTechnicalFields() 698 */ 699 @Override 700 boolean isExportWithTechnicalFields() { 701 702 return m_includeTechnicalFields.getValue().booleanValue(); 703 } 704 705 /** 706 * Gets selected groups in List.<p> 707 * 708 * @param parent layout 709 * @param importCase boolean 710 * @return List of group names 711 */ 712 private List<String> getGroupsList(VerticalLayout parent, boolean importCase) { 713 714 List<String> res = new ArrayList<String>(); 715 716 if (m_groupID != null) { 717 try { 718 res.add(m_cms.readGroup(m_groupID).getName()); 719 } catch (CmsException e) { 720 LOG.error("Unable to read group", e); 721 } 722 return res; 723 } 724 725 if (m_groupEditable) { 726 CmsEditableGroup editableGroup = importCase ? m_importGroupsGroup : m_exportGroupsGroup; 727 for (I_CmsEditableGroupRow row : editableGroup.getRows()) { 728 String groupName = ((CmsPrincipalSelect)row.getComponent()).getValue(); 729 if (!CmsStringUtil.isEmptyOrWhitespaceOnly(groupName)) { 730 res.add(groupName); 731 } 732 } 733 } else { 734 TextField comp = (TextField)parent.getComponent(0); 735 res.add(comp.getValue()); 736 } 737 return res; 738 } 739 740 /** 741 * Get selected roles list.<p> 742 * 743 * @param parent layout 744 * @param importCase boolean 745 * @return List of roles 746 */ 747 private List<CmsRole> getRolesList(VerticalLayout parent, boolean importCase) { 748 749 List<CmsRole> res = new ArrayList<CmsRole>(); 750 751 CmsEditableGroup editableGroup = importCase ? m_importRolesGroup : m_exportRolesGroup; 752 for (I_CmsEditableGroupRow row : editableGroup.getRows()) { 753 res.add(((ComboBox<CmsRole>)row.getComponent()).getValue()); 754 } 755 return res; 756 } 757 758 /** 759 * Set the visibility of the buttons.<p> 760 * 761 * @param tab which is selected. 762 */ 763 private void setButtonVisibility(int tab) { 764 765 m_download.setVisible(tab == 1); 766 m_startImport.setVisible(tab == 0); 767 768 } 769}