/** * Access the resource date. * * @param r * The resource. * @return The resource date. */ public Time getDate(Entity r) { return ((Message) r).getHeader().getDate(); }
/** * Access the resource date. * * @param r * The resource. * @return The resource date. */ public Time getDate(Entity r) { return ((Message) r).getHeader().getDate(); }
/** * Access the resource Message Order. * * @param r * The resource. * @return The resource order. */ public Integer getMessage_order(Entity r) { return ((Message) r).getHeader().getMessage_order(); }
/** * Access the resource owner user id. * * @param r * The resource. * @return The resource owner user id. */ public String getOwnerId(Entity r) { return ((Message) r).getHeader().getFrom().getId(); }
/** * Access the resource owner user id. * * @param r * The resource. * @return The resource owner user id. */ public String getOwnerId(Entity r) { return ((Message) r).getHeader().getFrom().getId(); }
/** * check permissions for removeMessage(). * * @param m * The message from this channel to remove. * @return true if the user is allowed to removeMessage(...), false if not. */ public boolean allowRemoveMessage(Message m) { // this is true if we can remove it due to any of our group membership boolean allowed = allowEditMessage(m, SECURE_REMOVE_OWN, SECURE_REMOVE_ANY); // but we must also assure, that for grouped messages, we can remove it from ALL of the groups if (allowed && (m.getHeader().getAccess() == MessageHeader.MessageAccess.GROUPED)) { boolean own = (m.getHeader().getFrom() == null) ? true : m.getHeader().getFrom().getId().equals(m_sessionManager.getCurrentSessionUserId()); allowed = EntityCollections.isContainedEntityRefsToEntities(m.getHeader().getGroups(), getGroupsAllowRemoveMessage(own)); } return allowed; } // allowRemoveMessage
/** * check permissions for removeMessage(). * * @param m * The message from this channel to remove. * @return true if the user is allowed to removeMessage(...), false if not. */ public boolean allowRemoveMessage(Message m) { // this is true if we can remove it due to any of our group membership boolean allowed = allowEditMessage(m, SECURE_REMOVE_OWN, SECURE_REMOVE_ANY); // but we must also assure, that for grouped messages, we can remove it from ALL of the groups if (allowed && (m.getHeader().getAccess() == MessageHeader.MessageAccess.GROUPED)) { boolean own = (m.getHeader().getFrom() == null) ? true : m.getHeader().getFrom().getId().equals(m_sessionManager.getCurrentSessionUserId()); allowed = EntityCollections.isContainedEntityRefsToEntities(m.getHeader().getGroups(), getGroupsAllowRemoveMessage(own)); } return allowed; } // allowRemoveMessage
/** * check permissions for removeMessage(). * * @param m * The message from this channel to remove. * @return true if the user is allowed to removeMessage(...), false if not. */ public boolean allowRemoveMessage(Message m) { // this is true if we can remove it due to any of our group membership boolean allowed = allowEditMessage(m, SECURE_REMOVE_OWN, SECURE_REMOVE_ANY); // but we must also assure, that for grouped messages, we can remove it from ALL of the groups if (allowed && (m.getHeader().getAccess() == MessageHeader.MessageAccess.GROUPED)) { boolean own = (m.getHeader().getFrom() == null) ? true : m.getHeader().getFrom().getId().equals(m_sessionManager.getCurrentSessionUserId()); allowed = EntityCollections.isContainedEntityRefsToEntities(m.getHeader().getGroups(), getGroupsAllowRemoveMessage(own)); } return allowed; } // allowRemoveMessage
/** * Compare this object with the specified object for order. * * @return A negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object. */ public int compareTo(Object obj) { if (!(obj instanceof Message)) throw new ClassCastException(); // if the object are the same, say so if (obj == this) return 0; // compare the header's date int compare = getHeader().getDate().compareTo(((Message) obj).getHeader().getDate()); return compare; } // compareTo
/** * Collect the fields that need to be stored outside the XML (for the resource). * * @return An array of field values to store in the record outside the XML (for the resource). */ public Object[] storageFields(Entity r) { Object[] rv = new Object[5]; rv[0] = ((Message) r).getHeader().getDate(); rv[1] = ((Message) r).getHeader().getFrom().getId(); rv[2] = ((AnnouncementMessage) r).getAnnouncementHeader().getDraft() ? "1" : "0"; rv[3] = r.getProperties().getProperty(ResourceProperties.PROP_PUBVIEW) == null ? "0" : "1"; rv[4] = ((Message) r).getHeader().getMessage_order(); // rv[3] = ((AnnouncementMessage) r).getAnnouncementHeader().getAccess() == MessageHeader.MessageAccess.PUBLIC ? "1" : "0"; return rv; }
/** * Compare this object with the specified object for order. * * @return A negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object. */ public int compareTo(Object obj) { if (!(obj instanceof Message)) throw new ClassCastException(); // if the object are the same, say so if (obj == this) return 0; // compare the header's date int compare = getHeader().getDate().compareTo(((Message) obj).getHeader().getDate()); return compare; } // compareTo
/** * Compare this object with the specified object for order. * * @return A negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object. */ public int compareTo(Object obj) { if (!(obj instanceof Message)) throw new ClassCastException(); // if the object are the same, say so if (obj == this) return 0; // compare the header's date int compare = getHeader().getDate().compareTo(((Message) obj).getHeader().getDate()); return compare; } // compareTo
/** * Does this object satisfy the criteria of the filter? * * @return true if the object is accepted by the filter, false if not. */ public boolean accept(Object o) { // reject if not a public message if (o instanceof Message) { Message msg = (Message) o; if ((msg.getProperties().getProperty(ResourceProperties.PROP_PUBVIEW) == null || !msg.getProperties().getProperty(ResourceProperties.PROP_PUBVIEW).equals(Boolean.TRUE.toString())) && !m_isChannelPublic) return false; else if (msg.getHeader().getDraft()) return false; } // next, use the specified filter, if present if (m_filter != null) return m_filter.accept(o); return true; } // accept
/** * Collect the fields that need to be stored outside the XML (for the resource). * * @return An array of field values to store in the record outside the XML (for the resource). */ public Object[] storageFields(Entity r) { Object[] rv = new Object[6]; rv[0] = ((Message) r).getHeader().getDate(); rv[1] = ((Message) r).getHeader().getFrom().getId(); rv[2] = "0"; rv[3] = r.getProperties().getProperty(ResourceProperties.PROP_PUBVIEW) == null ? "0" : "1"; rv[4] = ((MailArchiveMessage) r).getMailArchiveHeader().getSubject(); rv[5] = ((Message) r).getBody(); return rv; }
/** * Take all values from this object. * * @param user * The other object to take values from. */ protected void setAll(Message other) { // copy the header m_header = newMessageHeader(this, other.getHeader()); // body m_body = other.getBody(); // setup for properties m_properties = new BaseResourcePropertiesEdit(); m_properties.addAll(other.getProperties()); } // setAll
/** * Take all values from this object. * * @param user * The other object to take values from. */ protected void setAll(Message other) { // copy the header m_header = newMessageHeader(this, other.getHeader()); // body m_body = other.getBody(); // setup for properties m_properties = new BaseResourcePropertiesEdit(); m_properties.addAll(other.getProperties()); } // setAll
/** * Take all values from this object. * * @param user * The other object to take values from. */ protected void setAll(Message other) { // copy the header m_header = newMessageHeader(this, other.getHeader()); // body m_body = other.getBody(); // setup for properties m_properties = new BaseResourcePropertiesEdit(); m_properties.addAll(other.getProperties()); } // setAll
/** * check permissions for the message, to be able to edit or save it. * * @param m * The message. * @return true if the user is allowed to update the message, false if not. */ protected boolean allowEditMessage(Message m, String fOwn, String fAny) { // is this the user's own? if (m.getHeader().getFrom().getId().equals(m_sessionManager.getCurrentSessionUserId())) { // own or any return unlockCheck2(fOwn, fAny, m.getReference()); } else { // just any return unlockCheck(fAny, m.getReference()); } }
/** * check permissions for the message, to be able to edit or save it. * * @param m * The message. * @return true if the user is allowed to update the message, false if not. */ protected boolean allowEditMessage(Message m, String fOwn, String fAny) { // is this the user's own? if (m.getHeader().getFrom().getId().equals(m_sessionManager.getCurrentSessionUserId())) { // own or any return unlockCheck2(fOwn, fAny, m.getReference()); } else { // just any return unlockCheck(fAny, m.getReference()); } }
/** * check permissions for the message, to be able to edit or save it. * * @param m * The message. * @return true if the user is allowed to update the message, false if not. */ protected boolean allowEditMessage(Message m, String fOwn, String fAny) { // is this the user's own? if (m.getHeader().getFrom().getId().equals(m_sessionManager.getCurrentSessionUserId())) { // own or any return unlockCheck2(fOwn, fAny, m.getReference()); } else { // just any return unlockCheck(fAny, m.getReference()); } }