@Test public void getType() { Assert.assertEquals("user", this.component.getType(OWNER)); Assert.assertEquals("group", this.component.getType(GROUP)); Assert.assertEquals("unknown", this.component.getType(COLLABORATOR)); }
@Nonnull @Override public String getType(@Nullable EntityReference userOrGroup) { if (userOrGroup == null) { return USER_LABEL; } try { XWikiDocument doc = (XWikiDocument) this.bridge.getDocument((DocumentReference) userOrGroup); if (doc.getXObject(USER_CLASS) != null) { return USER_LABEL; } else if (doc.getXObject(GROUP_CLASS) != null) { return GROUP_LABEL; } } catch (Exception ex) { this.logger.warn("Failed to determine user type: {}", ex.getMessage(), ex); } return UNKNOWN_LABEL; }
DefaultEntityAccessHelper implements EntityAccessHelper { @Nonnull @Override public String getType(@Nullable EntityReference userOrGroup) { if (userOrGroup == null) { return USER_LABEL; } try { XWikiDocument doc = (XWikiDocument) this.bridge.getDocument((DocumentReference) userOrGroup); if (doc.getXObject(USER_CLASS) != null) { return USER_LABEL; } else if (doc.getXObject(GROUP_CLASS) != null) { return GROUP_LABEL; } } catch (Exception ex) { this.logger.warn("Failed to determine user type: {}", ex.getMessage(), ex); } return UNKNOWN_LABEL; } }
DefaultEntityAccessHelper implements EntityAccessHelper { @Nonnull @Override public String getType(@Nullable EntityReference userOrGroup) { if (userOrGroup == null) { return USER_LABEL; } try { XWikiDocument doc = (XWikiDocument) this.bridge.getDocument((DocumentReference) userOrGroup); if (doc.getXObject(USER_CLASS) != null) { return USER_LABEL; } else if (doc.getXObject(GROUP_CLASS) != null) { return GROUP_LABEL; } } catch (Exception ex) { this.logger.warn("Failed to determine user type: {}", ex.getMessage(), ex); } return UNKNOWN_LABEL; }  }
DefaultEntityAccessHelper implements EntityAccessHelper { @Nonnull @Override public String getType(@Nullable EntityReference userOrGroup) { if (userOrGroup == null) { return USER_LABEL; } try { XWikiDocument doc = (XWikiDocument) this.bridge.getDocument((DocumentReference) userOrGroup); if (doc.getXObject(USER_CLASS) != null) { return USER_LABEL; } else if (doc.getXObject(GROUP_CLASS) != null) { return GROUP_LABEL; } } catch (Exception ex) { this.logger.warn("Failed to determine user type: {}", ex.getMessage(), ex); } return UNKNOWN_LABEL; }  @Override DocumentReference getCurrentUser(); @Nonnull @Override String getType(@Nullable EntityReference userOrGroup); @Override boolean isGroup(@Nullable final EntityReference userOrGroup); @Override boolean isUser(@Nullable final EntityReference userOrGroup); @Nonnull @Override Document getDocument(EntityReference userOrGroup); @Nullable @Override String getStringProperty(
        @Nonnull final XWikiDocument doc,
        @Nullable final DocumentReference classReference,
        @Nullable final String propertyName); @Override void setProperty(
        @Nonnull final XWikiDocument doc,
        @Nullable final DocumentReference classReference,
        @Nullable final String propertyName,
        @Nullable final Object propertyValue); }
DefaultEntityAccessHelper implements EntityAccessHelper { @Nonnull @Override public String getType(@Nullable EntityReference userOrGroup) { if (userOrGroup == null) { return USER_LABEL; } try { XWikiDocument doc = (XWikiDocument) this.bridge.getDocument((DocumentReference) userOrGroup); if (doc.getXObject(USER_CLASS) != null) { return USER_LABEL; } else if (doc.getXObject(GROUP_CLASS) != null) { return GROUP_LABEL; } } catch (Exception ex) { this.logger.warn("Failed to determine user type: {}", ex.getMessage(), ex); } return UNKNOWN_LABEL; }  @Override DocumentReference getCurrentUser(); @Nonnull @Override String getType(@Nullable EntityReference userOrGroup); @Override boolean isGroup(@Nullable final EntityReference userOrGroup); @Override boolean isUser(@Nullable final EntityReference userOrGroup); @Nonnull @Override Document getDocument(EntityReference userOrGroup); @Nullable @Override String getStringProperty(
        @Nonnull final XWikiDocument doc,
        @Nullable final DocumentReference classReference,
        @Nullable final String propertyName); @Override void setProperty(
        @Nonnull final XWikiDocument doc,
        @Nullable final DocumentReference classReference,
        @Nullable final String propertyName,
        @Nullable final Object propertyValue);  }