private String getSiteId(Reference ref) { return ref.getContext(); }
private String getSiteId(Reference ref) { return ref.getContext(); }
/** * From EntityProducer */ public Collection getEntityAuthzGroups(Reference ref, String userId) { log.debug("getEntityAuthzGroups(Ref ID:{},{})", ref.getId(), userId); List ids = new ArrayList(); ids.add("/site/" + ref.getContext()); return ids; }
public String getContext(String ref) { return entityManager.newReference(ref).getContext(); }
private String getSiteId(Reference ref) { String context = ref.getContext(); if (context.startsWith("/site/")) { context = context.substring("/site/".length()); } if (context.startsWith("/")) { context = context.substring(1); } int slash = context.indexOf("/"); if (slash > 0) { context = context.substring(0, slash); } if (log.isDebugEnabled()) { log.debug("Wiki.getSiteId" + ref + ":" + context); } return context; }
/** * Check security for this entity. * * @param ref * The Reference to the entity. * @return true if allowed, false if not. */ protected boolean checkSecurity(Reference ref) { String contextId = ref.getContext(); try { Site site = SiteService.getSiteVisit(contextId); if ( site != null ) return true; } catch(IdUnusedException ex) { return false; } catch(PermissionException ex) { return false; } // System.out.println("ID="+ref.getId()); // System.out.println("Type="+ref.getType()); // System.out.println("SubType="+ref.getSubType()); return false; } /*******************************************************************************
public String getSiteId() { RWikiObjectService rwobjService = getObjectService(); RWikiObject rwobj = getRWikiObject(); Reference ref = rwobjService.getReference(rwobj); String siteContext = ref.getContext(); if (siteContext.startsWith("/site/")) //$NON-NLS-1$ { String siteId = siteContext.substring(6); int slash = siteId.indexOf("/"); //$NON-NLS-1$ if (slash != -1) { siteId = siteId.substring(0, slash - 1); } return siteId; } return null; }
/** * @inheritDoc */ public String getRssUrl(Reference ref) { String alias = null; List aliasList = aliasService.getAliases( ref.getReference() ); if ( ! aliasList.isEmpty() ) alias = ((Alias)aliasList.get(0)).getId(); StringBuilder rssUrlString = new StringBuilder(); rssUrlString.append( m_serverConfigurationService.getAccessUrl() ); rssUrlString.append(getAccessPoint(true)); rssUrlString.append(Entity.SEPARATOR); rssUrlString.append(REF_TYPE_ANNOUNCEMENT_RSS); rssUrlString.append(Entity.SEPARATOR); if ( alias != null) rssUrlString.append(alias); else rssUrlString.append(ref.getContext()); return rssUrlString.toString(); }
/** * Checks if a dropbox owner is in any group with current user, so AUTH_DROPBOX_GROUPS is rightly applied. * @return true if the dropbox owner is in the group, false otherwise. */ public boolean isDropboxOwnerInCurrentUserGroups(String refString, String userId) { String currentUser = sessionManager.getCurrentSessionUserId(); List<Group> site_groups = new ArrayList<Group>(); Reference ref = m_entityManager.newReference(refString); try { Site site = m_siteService.getSite(ref.getContext()); site_groups.addAll(site.getGroupsWithMembers(new String[]{currentUser,userId})); if (site_groups.size()>0) { return true; } } catch (IdUnusedException e) { } return false; }
/** * Construct with a reference. * * @param ref * The channel reference. */ public BaseMessageChannelEdit(String ref) { // set the ids Reference r = m_entityManager.newReference(ref); m_context = r.getContext(); m_id = r.getId(); // setup for properties m_properties = new BaseResourcePropertiesEdit(); } // BaseMessageChannelEdit
/** * Construct with a reference. * * @param ref * The channel reference. */ public BaseMessageChannelEdit(String ref) { // set the ids Reference r = m_entityManager.newReference(ref); m_context = r.getContext(); m_id = r.getId(); // setup for properties m_properties = new BaseResourcePropertiesEdit(); } // BaseMessageChannelEdit
public boolean parseEntityReference(String reference, Reference ref) { if (reference.startsWith(getContext())) { // removing our label, we expose the wrapped Entity reference String wrappedRef = reference.substring(getLabel().length() + 1); // make a reference for this Reference wrapped = entityManager.newReference(wrappedRef); // use the wrapped id, container and context - our own type (no subtype) ref.set(getLabel(), null, wrapped.getId(), wrapped.getContainer(), wrapped.getContext()); return true; } return false; }
/** * Construct with a reference. * * @param ref * The channel reference. */ public BaseMessageChannelEdit(String ref) { // set the ids Reference r = m_entityManager.newReference(ref); m_context = r.getContext(); m_id = r.getId(); // setup for properties m_properties = new BaseResourcePropertiesEdit(); } // BaseMessageChannelEdit
Reference siteRef = entityManager.newReference(Entity.SEPARATOR+ SiteService.SITE_SUBTYPE+ Entity.SEPARATOR+ contentRef.getContext()); Entity entity = siteRef.getEntity();
public boolean available(ContentEntity entity) {; return ServerConfigurationService.getBoolean("content.make.site.page",true) // Not in a dropbox && !ContentHostingService.isInDropbox(entity.getId()) // Not in a user site. && !SiteService.isUserSite(EntityManager.newReference(entity.getReference()).getContext()); } }
private String generateContentForType(boolean shouldProduceHtml, Event event) { // get the content & properties Reference ref = entityManager.newReference(event.getResource()); // TODO: ResourceProperties props = ref.getProperties(); // get the function String function = event.getEvent(); String subject = getSubject(event); // use either the configured site, or if not configured, the site (context) of the resource String siteId = (getSite() != null) ? getSite() : ref.getContext(); // get a site title String title = siteId; try { Site site = siteService.getSite(siteId); title = site.getTitle(); } catch (Exception ignore) { } StringBuilder buf = new StringBuilder(); addMessageText(buf, ref, subject, title, function, shouldProduceHtml); return buf.toString(); }
private String generateContentForType(boolean shouldProduceHtml, Event event) { // get the content & properties Reference ref = entityManager.newReference(event.getResource()); // TODO: ResourceProperties props = ref.getProperties(); // get the function String function = event.getEvent(); String subject = getSubject(event); // use either the configured site, or if not configured, the site (context) of the resource String siteId = (getSite() != null) ? getSite() : ref.getContext(); // get a site title String title = siteId; try { Site site = siteService.getSite(siteId); title = site.getTitle(); } catch (Exception ignore) { } StringBuilder buf = new StringBuilder(); addMessageText(buf, ref, subject, title, function, shouldProduceHtml); return buf.toString(); }
public String initializeAction(Reference reference) { ToolSession toolSession = SessionManager.getCurrentToolSession(); toolSession.setAttribute(PermissionsHelper.TARGET_REF, reference.getReference()); // use the folder's context (as a site and as a resource) for roles Collection<String> rolesRefs = new ArrayList<String>(); rolesRefs.add(SiteService.siteReference(reference.getContext())); rolesRefs.add(reference.getReference()); toolSession.setAttribute(PermissionsHelper.ROLES_REF, rolesRefs); // ... with this description String title = reference.getProperties().getProperty(ResourceProperties.PROP_DISPLAY_NAME); String[] args = { title }; toolSession.setAttribute(PermissionsHelper.DESCRIPTION, rb.getFormattedMessage("title.permissions", args)); // ... showing only locks that are prpefixed with this toolSession.setAttribute(PermissionsHelper.PREFIX, "content."); return BaseInteractionAction.getInitializationId(reference.getReference(), this.getTypeId(), this.getId()); }
/** * Format a to address, to the related site, but with no reply. * * @param event * The event that matched criteria to cause the notification. * @return a to address, to the related site, but with no reply. */ protected String getToSiteNoReply(Event event) { Reference ref = EntityManager.newReference(event.getResource()); // use either the configured site, or if not configured, the site (context) of the resource String siteId = (getSite() != null) ? getSite() : ref.getContext(); // get a site title String title = siteId; try { Site site = SiteService.getSite(siteId); title = site.getTitle(); } catch (Exception ignore) { } return "\"" + title + "\" <"+ ServerConfigurationService.getString("setup.request","no-reply@" + ServerConfigurationService.getServerName()) + ">"; }
/** * Format the announcement notification subject line. * * @param event * The event that matched criteria to cause the notification. * @return the announcement notification subject line. */ protected String getSubject(Event event) { // get the message Reference ref = entityManager.newReference(event.getResource()); AnnouncementMessage msg = (AnnouncementMessage) ref.getEntity(); AnnouncementMessageHeader hdr = (AnnouncementMessageHeader) msg.getAnnouncementHeader(); // use either the configured site, or if not configured, the site (context) of the resource String siteId = (getSite() != null) ? getSite() : ref.getContext(); // get a site title String title = siteId; try { Site site = siteService.getSite(siteId); title = site.getTitle(); } catch (Exception ignore) { } // use the message's subject return rb.getFormattedMessage("noti.subj", new Object[]{title, hdr.getSubject()}); }