@Override public Set<String> getAllPublishingEnvironments(String site) { SiteService siteService = _servicesManager.getService(SiteService.class); Map<String, PublishingChannelGroupConfigTO> groupConfigTOs = siteService.getPublishingChannelGroupConfigs(site); Set<String> environments = new HashSet<String>(); if (groupConfigTOs != null && groupConfigTOs.size() > 0) { for (PublishingChannelGroupConfigTO groupConfigTO : groupConfigTOs.values()) { if (StringUtils.isNotEmpty(groupConfigTO.getName())) { environments.add(groupConfigTO.getName()); } } } return environments; }
@Override public Set<PublishingTargetItem> getAllTargetsForSite(String site) { PersistenceManagerService persistenceManagerService = _servicesManager.getService(PersistenceManagerService.class); SiteService siteService = _servicesManager.getService(SiteService.class); Map<String, PublishingChannelGroupConfigTO> groupConfigTOs = siteService.getPublishingChannelGroupConfigs(site); Set<PublishingTargetItem> targets = new HashSet<PublishingTargetItem>(); Map<String, PublishingTargetItem> targetMap = new HashMap<String, PublishingTargetItem>(); if (groupConfigTOs != null && groupConfigTOs.size() > 0) { for (PublishingChannelGroupConfigTO groupConfigTO : groupConfigTOs.values()) { List<PublishingChannelConfigTO> channelConfigTOs = groupConfigTO.getChannels(); if (channelConfigTOs != null && channelConfigTOs.size() > 0) { for (PublishingChannelConfigTO channelConfigTO : channelConfigTOs) { DeploymentEndpointConfigTO endpoint = siteService.getDeploymentEndpoint(site, channelConfigTO.getName()); if (endpoint != null) { PublishingTargetItem targetItem = targetMap.get(endpoint.getName()); if (targetItem == null) { targetItem = new PublishingTargetItem(); targetItem.setId(endpoint.getName()); targetItem.setName(endpoint.getName()); targetItem.setTarget(endpoint.getTarget()); targetItem.setType(endpoint.getType()); targetItem.setServerUrl(endpoint.getServerUrl()); targetItem.setStatusUrl(endpoint.getStatusUrl()); targetItem.setVersionUrl(endpoint.getVersionUrl()); targetItem.setPassword(endpoint.getPassword()); targetItem.setExcludePattern(endpoint.getExcludePattern()); targetItem.setIncludePattern(endpoint.getIncludePattern()); targetItem.setBucketSize(endpoint.getBucketSize()); targetItem.setSiteId(endpoint.getSiteId()); targets.add(targetItem); targetMap.put(endpoint.getName(), targetItem); } targetItem.addEnvironment(groupConfigTO.getName()); } } } } } return targets; }
@Override public void delete(Context context, Community community) throws SQLException, AuthorizeException, IOException { // Check authorisation // FIXME: If this was a subcommunity, it is first removed from it's // parent. // This means the parentCommunity == null // But since this is also the case for top-level communities, we would // give everyone rights to remove the top-level communities. // The same problem occurs in removing the logo if (!authorizeService.authorizeActionBoolean( context, getParentObject(context, community), Constants.REMOVE)) { authorizeService.authorizeAction(context, community, Constants.DELETE); } ArrayList<String> removedIdentifiers = getIdentifiers(context, community); String removedHandle = community.getHandle(); UUID removedId = community.getID(); // If not a top-level community, have parent remove me; this // will call rawDelete() before removing the linkage Community parent = (Community) getParentObject(context, community); if (parent != null) { // remove the subcommunities first Iterator<Community> subcommunities = community.getSubcommunities().iterator(); while (subcommunities.hasNext()) { Community subCommunity = subcommunities.next(); subcommunities.remove(); delete(context, subCommunity); } // now let the parent remove the community removeSubcommunity(context, parent, community); return; } rawDelete(context, community); context.addEvent( new Event( Event.REMOVE, Constants.SITE, siteService.findSite(context).getID(), Constants.COMMUNITY, removedId, removedHandle, removedIdentifiers)); }
@Override public Community create(Community parent, Context context, String handle) throws SQLException, AuthorizeException { if (!(authorizeService.isAdmin(context) || (parent != null && authorizeService.authorizeActionBoolean(context, parent, Constants.ADD)))) { throw new AuthorizeException("Only administrators can create communities"); } Community newCommunity = communityDAO.create(context, new Community()); try { if (handle == null) { handleService.createHandle(context, newCommunity); } else { handleService.createHandle(context, newCommunity, handle); } } catch (IllegalStateException ie) { // If an IllegalStateException is thrown, then an existing object is already using this handle throw ie; } if (parent != null) { parent.addSubCommunity(newCommunity); newCommunity.addParentCommunity(parent); } // create the default authorization policy for communities // of 'anonymous' READ Group anonymousGroup = groupService.findByName(context, Group.ANONYMOUS); authorizeService.createResourcePolicy( context, newCommunity, anonymousGroup, null, Constants.READ, null); communityDAO.save(context, newCommunity); context.addEvent( new Event( Event.CREATE, Constants.COMMUNITY, newCommunity.getID(), newCommunity.getHandle(), getIdentifiers(context, newCommunity))); // if creating a top-level Community, simulate an ADD event at the Site. if (parent == null) { context.addEvent( new Event( Event.ADD, Constants.SITE, siteService.findSite(context).getID(), Constants.COMMUNITY, newCommunity.getID(), newCommunity.getHandle(), getIdentifiers(context, newCommunity))); } log.info( LogManager.getHeader(context, "create_community", "community_id=" + newCommunity.getID()) + ",handle=" + newCommunity.getHandle()); return newCommunity; }
@Override public String getLiveEnvironmentName(String site) { SiteService siteService = getServicesManager().getService(SiteService.class); return siteService.getLiveEnvironmentName(site); }
@Override public Set<String> getAllAvailableSites() { SiteService siteService = _servicesManager.getService(SiteService.class); return siteService.getAllAvailableSites(); }