@Override public boolean isFragmentOwner(IPerson person) { return this.fragmentUtils.getFragmentDefinitionByOwner(person) != null; }
@Override public boolean isFragmentOwner(String username) { boolean rslt = false; // default final List<FragmentDefinition> definitions = this.fragmentUtils.getFragmentDefinitions(); if (definitions != null) { for (final FragmentDefinition fragmentDefinition : definitions) { if (fragmentDefinition.getOwnerId().equals(username)) { rslt = true; break; } } } return rslt; }
this.fragmentUtils.getFragmentDefinitionByOwner(person); final boolean isLayoutOwnerDefault = this.isLayoutOwnerDefault(person); final Set<String> fragmentNames = new LinkedHashSet<>(); final Locale locale = profile.getLocaleManager().getLocales().get(0); final List<FragmentDefinition> applicableFragmentDefinitions = this.fragmentUtils.getFragmentDefinitionsApplicableToPerson(person); final List<Document> applicableLayouts = this.fragmentUtils.getFragmentDefinitionUserViewLayouts( applicableFragmentDefinitions, locale); final IntegrationResult integrationResult = new IntegrationResult(); this.fragmentUtils.getFragmentNames(applicableFragmentDefinitions));
/** * Method for acquiring copies of fragment layouts to assist in debugging. No infrastructure * code calls this but channels designed to expose the structure of the cached fragments use * this to obtain copies. * * @return Map */ @Override public Map<String, Document> getFragmentLayoutCopies() { // since this is only visible in fragment list in administrative portlet, use default portal // locale final Locale defaultLocale = localeManagerFactory.getPortalLocales().get(0); final Map<String, Document> layouts = new HashMap<>(); final List<FragmentDefinition> definitions = this.fragmentUtils.getFragmentDefinitions(); for (final FragmentDefinition fragmentDefinition : definitions) { final Document layout = DocumentFactory.getThreadDocument(); final UserView userView = this.fragmentUtils.getUserView(fragmentDefinition, defaultLocale); if (userView == null) { logger.warn( "No UserView found for FragmentDefinition {}, it will be skipped.", fragmentDefinition.getName()); continue; } final Node copy = layout.importNode(userView.getLayout().getDocumentElement(), true); layout.appendChild(copy); layouts.put(fragmentDefinition.getOwnerId(), layout); } return layouts; }
this.fragmentUtils.getFragmentDefinitionByName(fragName); final UserView userView = this.fragmentUtils.getUserView(fragmentDefinition, locale); if (userView == null) { logger.warn(
/** * Replaces the layout Document stored on a fragment definition with a new version. This is * called when a fragment owner updates their layout. */ private void updateCachedLayout( Document layout, IUserProfile profile, FragmentDefinition fragment) { final Locale locale = profile.getLocaleManager().getLocales().get(0); // need to make a copy that we can fragmentize layout = (Document) layout.cloneNode(true); // Fix later to handle multiple profiles final Element root = layout.getDocumentElement(); final UserView userView = this.fragmentUtils.getUserView(fragment, locale); if (userView == null) { throw new IllegalStateException( "No UserView found for fragment: " + fragment.getName()); } root.setAttribute( Constants.ATT_ID, Constants.FRAGMENT_ID_USER_PREFIX + userView.getUserId() + Constants.FRAGMENT_ID_LAYOUT_PREFIX + "1"); try { this.fragmentActivator.clearChacheForOwner(fragment.getOwnerId()); this.fragmentUtils.getUserView(fragment, locale); } catch (final Exception e) { logger.error("An exception occurred attempting to update a layout.", e); } }
@Override public FragmentNodeInfo getFragmentNodeInfo(String sId) { final List<FragmentDefinition> fragments = this.fragmentUtils.getFragmentDefinitions(); final Locale defaultLocale = localeManagerFactory.getPortalLocales().get(0); for (final FragmentDefinition fragmentDefinition : fragments) { final UserView userView = this.fragmentUtils.getUserView(fragmentDefinition, defaultLocale); if (userView == null) { logger.warn(
protected boolean isFragmentOwner(final IPerson person) { return this.fragmentUtils.getFragmentDefinitionByOwner(person) != null; } }
@Override public double getFragmentPrecedence(long id) { final List<FragmentDefinition> definitions = this.fragmentUtils.getFragmentDefinitions(); // must pass through the array looking for the fragment with this // index since the array was sorted by precedence and then index // within precedence. for (final FragmentDefinition fragmentDefinition : definitions) { if (fragmentDefinition.getId() == id) { return fragmentDefinition.getPrecedence(); } } return 0D; // should never get here. }
/** * This method overrides the same method in the super class to persist only layout information * stored in the user's person layout fragment or PLF. If fragment cache update is requested * then it checks to see if this person is a layout owner and if so then their changes are * pushed into the appropriate layout fragment. */ @Override public void setUserLayout( IPerson person, IUserProfile profile, Document layoutXML, boolean channelsAdded, boolean updateFragmentCache) { final Document plf = (Document) person.getAttribute(Constants.PLF); if (logger.isDebugEnabled()) { logger.debug( "PLF for {}\n{}", person.getAttribute(IPerson.USERNAME), XmlUtilitiesImpl.toString(plf)); } super.setUserLayout(person, profile, plf, channelsAdded); if (updateFragmentCache) { final FragmentDefinition fragment = this.fragmentUtils.getFragmentDefinitionByOwner(person); if (fragment != null) { this.updateCachedLayout(plf, profile, fragment); } } }
/** * Returns true if the user is the owner of a layout which is copied as the default for any * fragment when first created. */ private boolean isLayoutOwnerDefault(IPerson person) { final String userName = (String) person.getAttribute("username"); final List<FragmentDefinition> definitions = this.fragmentUtils.getFragmentDefinitions(); if (userName != null && definitions != null) { for (final FragmentDefinition fragmentDefinition : definitions) { if (fragmentDefinition.defaultLayoutOwnerID != null && fragmentDefinition.defaultLayoutOwnerID.equals(userName)) { return true; } } } final String globalDefault = PropertiesManager.getProperty(DEFAULT_LAYOUT_OWNER_PROPERTY); if (globalDefault != null && globalDefault.equals(userName)) { return true; } return false; }