You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rave.apache.org by mf...@apache.org on 2012/06/26 20:19:38 UTC
svn commit: r1354148 [2/9] - in /rave/trunk: ./ rave-components/
rave-components/rave-commons/
rave-components/rave-commons/src/main/java/org/apache/rave/model/
rave-components/rave-commons/src/main/java/org/apache/rave/persistence/jpa/
rave-components...
Modified: rave/trunk/rave-components/rave-commons/src/main/java/org/apache/rave/persistence/jpa/util/JpaUtil.java
URL: http://svn.apache.org/viewvc/rave/trunk/rave-components/rave-commons/src/main/java/org/apache/rave/persistence/jpa/util/JpaUtil.java?rev=1354148&r1=1354147&r2=1354148&view=diff
==============================================================================
--- rave/trunk/rave-components/rave-commons/src/main/java/org/apache/rave/persistence/jpa/util/JpaUtil.java (original)
+++ rave/trunk/rave-components/rave-commons/src/main/java/org/apache/rave/persistence/jpa/util/JpaUtil.java Tue Jun 26 18:18:57 2012
@@ -24,6 +24,7 @@ import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.TypedQuery;
+import org.apache.rave.exception.NotSupportedException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.dao.IncorrectResultSizeDataAccessException;
@@ -95,4 +96,25 @@ public class JpaUtil {
query.setFirstResult(offset).setMaxResults(pageSize);
return query.getResultList();
}
+
+ /**
+ * Clears an original list and adds all items from the passed in base type list
+ * @param target the list to replace
+ * @param newList the list to replace with
+ * @param clazz the target class
+ * @param <E> The base type
+ * @param <T> The target type
+ */
+ public static <E, T extends E> void clearAndAdd(List<T> target, List<E> newList, Class<T> clazz) {
+ target.clear();
+ if (newList != null) {
+ for (E e : newList) {
+ if (e.getClass().equals(clazz)) {
+ target.add((T)e);
+ } else {
+ throw new NotSupportedException("Cannot directly set list composed of non JPA Entities");
+ }
+ }
+ }
+ }
}
Modified: rave/trunk/rave-components/rave-commons/src/main/java/org/apache/rave/util/CollectionUtils.java
URL: http://svn.apache.org/viewvc/rave/trunk/rave-components/rave-commons/src/main/java/org/apache/rave/util/CollectionUtils.java?rev=1354148&r1=1354147&r2=1354148&view=diff
==============================================================================
--- rave/trunk/rave-components/rave-commons/src/main/java/org/apache/rave/util/CollectionUtils.java (original)
+++ rave/trunk/rave-components/rave-commons/src/main/java/org/apache/rave/util/CollectionUtils.java Tue Jun 26 18:18:57 2012
@@ -107,17 +107,27 @@ public class CollectionUtils {
}
/**
- * Converts the wildcard list to a typed list
+ * Workaround for compile time checking of list types. Generics are not persisted through runtime. The compile time
+ * type system will still check that the items are castable to the base type.
* @param initial the wildcard list
* @param <T> the type constraint for the target list
- * @return the new, type constrained list
+ * @return if initial is null, null otherwise the new, type constrained list
*/
+ @SuppressWarnings("unchecked")
public static <T> List<T> toBaseTypedList(List<? extends T> initial) {
- List<T> list = new ArrayList<T>();
- for(T f : initial) {
- list.add(f);
- }
- return list;
+ return (List<T>)initial;
+ }
+
+ /**
+ * Workaround for compile time checking of list types. Generics are not persisted through runtime. The compile time
+ * type system will still check that the items are castable to the base type.
+ * @param initial the wildcard collection
+ * @param <T> the type constraint for the target collection
+ * @return if initial is null, null otherwise the new, type constrained collection
+ */
+ @SuppressWarnings("unchecked")
+ public static <T> Collection<T> toBaseTypedCollection(Collection<? extends T> initial) {
+ return (Collection<T>)initial;
}
/**
Modified: rave/trunk/rave-components/rave-commons/src/test/java/org/apache/rave/util/CollectionUtilsTest.java
URL: http://svn.apache.org/viewvc/rave/trunk/rave-components/rave-commons/src/test/java/org/apache/rave/util/CollectionUtilsTest.java?rev=1354148&r1=1354147&r2=1354148&view=diff
==============================================================================
--- rave/trunk/rave-components/rave-commons/src/test/java/org/apache/rave/util/CollectionUtilsTest.java (original)
+++ rave/trunk/rave-components/rave-commons/src/test/java/org/apache/rave/util/CollectionUtilsTest.java Tue Jun 26 18:18:57 2012
@@ -191,6 +191,14 @@ public class CollectionUtilsTest {
}
@Test
+ public void toBaseTypedList_null() {
+ List<SubTestObject> list = null;
+
+ List<TestObject> down = CollectionUtils.toBaseTypedList((List<? extends TestObject>)list);
+ assertThat(down, is(nullValue()));
+ }
+
+ @Test
public void addUniqueValues() {
List<TestObject> source = new ArrayList<TestObject>();
TestObject testObject1 = new TestObject("a", "b");
Modified: rave/trunk/rave-components/rave-core/pom.xml
URL: http://svn.apache.org/viewvc/rave/trunk/rave-components/rave-core/pom.xml?rev=1354148&r1=1354147&r2=1354148&view=diff
==============================================================================
--- rave/trunk/rave-components/rave-core/pom.xml (original)
+++ rave/trunk/rave-components/rave-core/pom.xml Tue Jun 26 18:18:57 2012
@@ -79,10 +79,6 @@
<artifactId>spring-context</artifactId>
</dependency>
<dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-orm</artifactId>
- </dependency>
- <dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
</dependency>
@@ -101,18 +97,6 @@
<version>20090211</version>
</dependency>
- <!--Persistence-->
- <dependency>
- <groupId>org.apache.openjpa</groupId>
- <artifactId>openjpa</artifactId>
- </dependency>
-
- <dependency>
- <groupId>com.h2database</groupId>
- <artifactId>h2</artifactId>
- <scope>test</scope>
- </dependency>
-
<!-- Logging -->
<dependency>
<groupId>org.slf4j</groupId>
@@ -176,40 +160,5 @@
<build>
<defaultGoal>install</defaultGoal>
- <plugins>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>openjpa-maven-plugin</artifactId>
- <version>1.2</version>
- <configuration>
- <includes>org/apache/rave/portal/model/*.class</includes>
- <excludes>org/apache/rave/portal/model/WidgetStatus.class</excludes>
- <addDefaultConstructor>true</addDefaultConstructor>
- <enforcePropertyRestrictions>true</enforcePropertyRestrictions>
- </configuration>
- <executions>
- <execution>
- <id>enhancer</id>
- <phase>process-classes</phase>
- <goals>
- <goal>enhance</goal>
- </goals>
- </execution>
- </executions>
- <dependencies>
- <dependency>
- <exclusions>
- <exclusion>
- <groupId>xerces</groupId>
- <artifactId>xmlParserAPIs</artifactId>
- </exclusion>
- </exclusions>
- <groupId>org.apache.openjpa</groupId>
- <artifactId>openjpa</artifactId>
- <version>${openjpa.version}</version>
- </dependency>
- </dependencies>
- </plugin>
- </plugins>
</build>
</project>
Modified: rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/model/Category.java
URL: http://svn.apache.org/viewvc/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/model/Category.java?rev=1354148&r1=1354147&r2=1354148&view=diff
==============================================================================
--- rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/model/Category.java (original)
+++ rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/model/Category.java Tue Jun 26 18:18:57 2012
@@ -15,166 +15,33 @@
*/
package org.apache.rave.portal.model;
-import org.apache.rave.persistence.BasicEntity;
-import org.codehaus.jackson.annotate.JsonIgnore;
-
-import javax.persistence.*;
-import javax.xml.bind.annotation.XmlRootElement;
-import java.io.Serializable;
+import javax.xml.bind.annotation.XmlTransient;
import java.util.Date;
import java.util.List;
/**
* A category for a widget.
*/
-@Entity
-@Table(name = "category")
-@XmlRootElement
-@NamedQueries({
- @NamedQuery(name = Category.GET_ALL, query = "select c from Category c order by c.text")
-})
-public class Category implements BasicEntity, Serializable {
- // constants for JPA query names
- public static final String GET_ALL = "Category.getAll";
-
- @Id
- @Column(name = "entity_id")
- @GeneratedValue(strategy = GenerationType.TABLE, generator = "categoryIdGenerator")
- @TableGenerator(name = "categoryIdGenerator", table = "RAVE_PORTAL_SEQUENCES", pkColumnName = "SEQ_NAME",
- valueColumnName = "SEQ_COUNT", pkColumnValue = "category",
- allocationSize = 1, initialValue = 1)
- private Long entityId;
-
- @Basic
- @Column(name = "text", unique = true)
- private String text;
-
- @OneToOne(fetch=FetchType.EAGER)
- @JoinColumn(name="created_user_id")
- private User createdUser;
-
- @Basic
- @Column(name ="created_date")
- @Temporal(javax.persistence.TemporalType.TIMESTAMP)
- private Date createdDate;
-
-
- @OneToOne(fetch=FetchType.EAGER)
- @JoinColumn(name="last_modified_user_id")
- private User lastModifiedUser;
-
- @Basic
- @Column(name ="last_modified_date")
- @Temporal(javax.persistence.TemporalType.TIMESTAMP)
- private Date lastModifiedDate;
-
- @ManyToMany(fetch = FetchType.EAGER)
- @JoinTable(name="widget_category",
- joinColumns=@JoinColumn(name="category_id", referencedColumnName = "entity_id"),
- inverseJoinColumns=@JoinColumn(name="widget_id", referencedColumnName = "entity_id")
- )
- @OrderBy("title")
- private List<Widget> widgets;
-
- public Category() {
-
- }
-
- public Category(Long entityId, String text, User createdUser, Date createdDate, User lastModifiedUser, Date lastModifiedDate) {
- this.entityId = entityId;
- this.text = text;
- this.createdUser = createdUser;
- this.createdDate = createdDate;
- this.lastModifiedUser = lastModifiedUser;
- this.lastModifiedDate = lastModifiedDate;
- }
-
- @Override
- public Long getEntityId() {
- return entityId;
- }
-
- @Override
- public void setEntityId(Long entityId) {
- this.entityId = entityId;
- }
-
- public String getText() {
- return text;
- }
-
- public void setText(String text) {
- this.text = text;
- }
-
- public User getCreatedUser() {
- return createdUser;
- }
-
- public void setCreatedUser(User createdUser) {
- this.createdUser = createdUser;
- }
-
- public Date getCreatedDate() {
- return createdDate;
- }
-
- public void setCreatedDate(Date createdDate) {
- this.createdDate = createdDate;
- }
-
- public User getLastModifiedUser() {
- return lastModifiedUser;
- }
-
- public void setLastModifiedUser(User lastModifiedUser) {
- this.lastModifiedUser = lastModifiedUser;
- }
-
- public Date getLastModifiedDate() {
- return lastModifiedDate;
- }
-
- public void setLastModifiedDate(Date lastModifiedDate) {
- this.lastModifiedDate = lastModifiedDate;
- }
-
- @JsonIgnore
- public List<Widget> getWidgets() {
- return widgets;
- }
-
- public void setWidgets(List<Widget> widgets) {
- this.widgets = widgets;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- final Category other = (Category) obj;
- if (this.entityId != other.entityId && (this.entityId == null || !this.entityId.equals(other.entityId))) {
- return false;
- }
- return true;
- }
-
- @Override
- public int hashCode() {
- int hash = 7;
- hash = 79 * hash + (this.entityId != null ? this.entityId.hashCode() : 0);
- return hash;
- }
-
- @Override
- public String toString() {
- return "Category{" +
- "entityId=" + entityId +
- ", text='" + text + '\'' +
- '}';
- }
-}
+@XmlTransient
+public interface Category {
+ public Long getId();
+ public void setId(Long id);
+
+ public String getText();
+ public void setText(String text);
+
+ public User getCreatedUser();
+ public void setCreatedUser(User createdUser);
+
+ public Date getCreatedDate();
+ public void setCreatedDate(Date createdDate);
+
+ public User getLastModifiedUser();
+ public void setLastModifiedUser(User lastModifiedUser);
+
+ public Date getLastModifiedDate();
+ public void setLastModifiedDate(Date lastModifiedDate);
+
+ public List<Widget> getWidgets();
+ public void setWidgets(List<Widget> widgets);
+}
\ No newline at end of file
Modified: rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/model/Tag.java
URL: http://svn.apache.org/viewvc/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/model/Tag.java?rev=1354148&r1=1354147&r2=1354148&view=diff
==============================================================================
--- rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/model/Tag.java (original)
+++ rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/model/Tag.java Tue Jun 26 18:18:57 2012
@@ -1,126 +1,29 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
+ * Copyright 2011 The Apache Software Foundation.
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
*
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.rave.portal.model;
-import org.apache.rave.persistence.BasicEntity;
-
-import javax.persistence.*;
-import java.util.ArrayList;
-import java.util.Collection;
+import javax.xml.bind.annotation.XmlTransient;
import java.util.List;
-/**
- * Represents a group in the social database. The assumption in this object is that groups are
- * associated with individuals and are used by those individuals to manage people.
- */
-@Entity
-@Table(name = "tag")
-@NamedQueries({
- @NamedQuery(name = Tag.GET_ALL, query = "select t from Tag t order by t.keyword asc"),
- @NamedQuery(name = Tag.COUNT_ALL, query = "select count(t) from Tag t "),
- @NamedQuery(name = Tag.GET_ALL_NOT_IN_WIDGET, query = "select tag from Tag tag where tag.keyword not in " +
- "(select t.keyword from Tag t join t.widgets w where w.widgetId =:widgetId)"),
-
- @NamedQuery(name = Tag.FIND_BY_KEYWORD, query = "select t from Tag t where UPPER(t.keyword) = UPPER(:keyword)")
-})
-
-public class Tag implements BasicEntity {
-
- public static final String FIND_BY_KEYWORD = "findByKeyword";
- public static final String GET_ALL = "getAll";
- public static final String COUNT_ALL = "countAll";
- public static final String GET_ALL_NOT_IN_WIDGET="getAllNotInWidget" ;
-
- /**
- * The internal object ID used for references to this object. Should be generated by the
- * underlying storage mechanism
- */
- @Id
- @Column(name = "entity_id")
- @GeneratedValue(strategy = GenerationType.TABLE, generator = "tagIdGenerator")
- @TableGenerator(name = "tagIdGenerator", table = "RAVE_PORTAL_SEQUENCES", pkColumnName = "SEQ_NAME",
- valueColumnName = "SEQ_COUNT", pkColumnValue = "tag", allocationSize = 1, initialValue = 1)
- private Long entityId;
-
- @Basic
- @Column(name = "keyword", unique = true)
- private String keyword;
-
- @OneToMany(mappedBy="tag")
- public List<WidgetTag> widgets;
-
-
- public Tag() {
-
- }
-
- public Tag(Long entityId, String keyword) {
- this.entityId = entityId;
- this.keyword = keyword;
- }
-
- public String getKeyword() {
- return keyword;
- }
-
- public void setKeyword(String keyword) {
- this.keyword = keyword;
- }
-
- public Long getEntityId() {
- return entityId;
- }
-
- public void setEntityId(Long entityId) {
- this.entityId = entityId;
- }
-
- public List<WidgetTag> getWidgets() {
- if (widgets==null) widgets=new ArrayList<WidgetTag>();
- return widgets;
- }
-
- public void setWidgets(List<WidgetTag> widgets) {
- this.widgets = widgets;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
-
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
-
- Tag tag = (Tag) o;
-
- if (entityId != null ? !entityId.equals(tag.entityId) : tag.entityId != null) {
- return false;
- }
+@XmlTransient
+public interface Tag {
- return true;
- }
+ String getKeyword();
+ void setKeyword(String keyword);
+ List<WidgetTag> getWidgets();
+ void setWidgets(List<WidgetTag> widgets);
- @Override
- public int hashCode() {
- return entityId != null ? entityId.hashCode() : 0;
- }
}
Modified: rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/model/WidgetTag.java
URL: http://svn.apache.org/viewvc/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/model/WidgetTag.java?rev=1354148&r1=1354147&r2=1354148&view=diff
==============================================================================
--- rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/model/WidgetTag.java (original)
+++ rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/model/WidgetTag.java Tue Jun 26 18:18:57 2012
@@ -13,137 +13,21 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.rave.portal.model;
-import org.apache.rave.persistence.BasicEntity;
+package org.apache.rave.portal.model;
-import javax.persistence.*;
-import javax.xml.bind.annotation.XmlRootElement;
-import java.io.Serializable;
+import javax.xml.bind.annotation.XmlTransient;
import java.util.Date;
-/**
- * A tag for a widget.
- */
-@Entity
-@Table(name = "widget_tag")
-@XmlRootElement
-@NamedQueries({
- @NamedQuery(name = WidgetTag.FIND_BY_WIDGET_AND_KEYWORD, query = "select t from WidgetTag t where t.widgetId=:widgetId and UPPER(t.tag.keyword) = UPPER(:keyword)")
-})
-
-public class WidgetTag implements BasicEntity, Serializable {
-
- public static final String FIND_BY_WIDGET_AND_KEYWORD = "findByWidgetAndKeyword";
-
- @Id
- @Column(name = "entity_id")
- @GeneratedValue(strategy = GenerationType.TABLE, generator = "widgetTagIdGenerator")
- @TableGenerator(name = "widgetTagIdGenerator", table = "RAVE_PORTAL_SEQUENCES", pkColumnName = "SEQ_NAME",
- valueColumnName = "SEQ_COUNT", pkColumnValue = "widget_tag", allocationSize = 1, initialValue = 1)
- private Long entityId;
-
- @Basic
- @Column(name = "widget_id")
- private Long widgetId;
-
- @ManyToOne(fetch = FetchType.EAGER)
- @JoinColumn(name = "user_id")
- private User user;
-
- @ManyToOne(fetch=FetchType.EAGER,cascade = CascadeType.ALL)
- @JoinColumn(name = "tag_id")
- private Tag tag;
-
- @Basic
- @Column(name = "created_date")
- @Temporal(javax.persistence.TemporalType.TIMESTAMP)
- private Date createdDate;
-
- public WidgetTag() {
-
- }
-
- public WidgetTag(Long entityId, Long widgetId, User user, Date created, Tag tag) {
- this.entityId = entityId;
- this.widgetId = widgetId;
- this.user = user;
- this.tag = tag;
- this.createdDate = created;
- }
-
- @Override
- public Long getEntityId() {
- return entityId;
- }
-
- @Override
- public void setEntityId(Long entityId) {
- this.entityId = entityId;
- }
-
- public Long getWidgetId() {
- return widgetId;
- }
-
- public void setWidgetId(Long widgetId) {
- this.widgetId = widgetId;
- }
-
- public User getUser() {
- return user;
- }
-
- public void setUser(User user) {
- this.user = user;
- }
-
-
-
- public Date getCreatedDate() {
- return createdDate;
- }
-
- public void setCreatedDate(Date created) {
- this.createdDate = created;
- }
-
- public Tag getTag() {
- return tag;
- }
-
- public void setTag(Tag tag) {
- this.tag = tag;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- final WidgetTag other = (WidgetTag) obj;
- if (this.entityId != other.entityId && (this.entityId == null || !this.entityId.equals(other.entityId))) {
- return false;
- }
- return true;
- }
-
- @Override
- public int hashCode() {
- int hash = 7;
- hash = 79 * hash + (this.entityId != null ? this.entityId.hashCode() : 0);
- return hash;
- }
-
- @Override
- public String toString() {
- StringBuilder sb=new StringBuilder("WidgetTag") ;
- sb.append("{").append("entityId=").append(entityId).append( ", widgetId=").append(widgetId);
- if (tag!=null) sb.append("tag keyword=").append(tag.getKeyword());
- sb.append("}") ;
- return sb.toString();
- }
+@XmlTransient
+public interface WidgetTag {
+
+ Long getWidgetId();
+ void setWidgetId(Long id);
+ User getUser();
+ void setUser(User user);
+ Tag getTag();
+ void setTag(Tag tag);
+ Date getCreatedDate();
+ void setCreatedDate(Date date);
}
Modified: rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/model/util/SearchResult.java
URL: http://svn.apache.org/viewvc/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/model/util/SearchResult.java?rev=1354148&r1=1354147&r2=1354148&view=diff
==============================================================================
--- rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/model/util/SearchResult.java (original)
+++ rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/model/util/SearchResult.java Tue Jun 26 18:18:57 2012
@@ -19,14 +19,12 @@
package org.apache.rave.portal.model.util;
-import org.apache.rave.persistence.BasicEntity;
-
import java.util.List;
/**
* Wrapper for search results.
*/
-public class SearchResult<T extends BasicEntity> {
+public class SearchResult<T> {
private List<T> resultSet;
private int pageSize;
private int offset;
Modified: rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/repository/AuthorityRepository.java
URL: http://svn.apache.org/viewvc/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/repository/AuthorityRepository.java?rev=1354148&r1=1354147&r2=1354148&view=diff
==============================================================================
--- rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/repository/AuthorityRepository.java (original)
+++ rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/repository/AuthorityRepository.java Tue Jun 26 18:18:57 2012
@@ -30,7 +30,7 @@ import java.util.List;
public interface AuthorityRepository extends Repository<Authority> {
/**
- * Finds the {@link Authority} by its name
+ * Finds the {@link org.apache.rave.portal.model.Authority} by its name
*
* @param authorityName (unique) name of the Authority
* @return Authority if it can be found, otherwise {@literal null}
@@ -38,12 +38,12 @@ public interface AuthorityRepository ext
Authority getByAuthority(String authorityName);
/**
- * @return a List of all {@link Authority}'s.
+ * @return a List of all {@link org.apache.rave.portal.model.Authority}'s.
*/
List<Authority> getAll();
-
+
/**
- * @return a List of all default {@link Authority}'s.
+ * @return a List of all default {@link org.apache.rave.portal.model.Authority}'s.
*/
List<Authority> getAllDefault();
Modified: rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/repository/PageRepository.java
URL: http://svn.apache.org/viewvc/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/repository/PageRepository.java?rev=1354148&r1=1354147&r2=1354148&view=diff
==============================================================================
--- rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/repository/PageRepository.java (original)
+++ rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/repository/PageRepository.java Tue Jun 26 18:18:57 2012
@@ -19,11 +19,7 @@
package org.apache.rave.portal.repository;
import org.apache.rave.persistence.Repository;
-import org.apache.rave.portal.model.Page;
-import org.apache.rave.portal.model.PageTemplate;
-import org.apache.rave.portal.model.PageType;
-import org.apache.rave.portal.model.PageUser;
-import org.apache.rave.portal.model.User;
+import org.apache.rave.portal.model.*;
import java.util.List;
@@ -65,14 +61,14 @@ public interface PageRepository extends
boolean hasPersonPage(long userId);
/**
- * Returns a list of pageUser records of a certain pageType.
- * Used to get a list of a users pages(user) with render sequencing.
+ * Returns a list of pageUser records of a certain pageType.
+ * Used to get a list of a users pages(user) with render sequencing.
* @param userId
* @param pageType
* @return a list of pageUser
*/
public List<PageUser> getPagesForUser(Long userId, PageType pageType);
-
+
/**
* Returns a single pageUser tuple based on userId and pageId
Modified: rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/repository/PortalPreferenceRepository.java
URL: http://svn.apache.org/viewvc/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/repository/PortalPreferenceRepository.java?rev=1354148&r1=1354147&r2=1354148&view=diff
==============================================================================
--- rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/repository/PortalPreferenceRepository.java (original)
+++ rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/repository/PortalPreferenceRepository.java Tue Jun 26 18:18:57 2012
@@ -25,7 +25,7 @@ import org.apache.rave.portal.model.Port
import java.util.List;
/**
- * Provides persistence operations for the {@link PortalPreference}
+ * Provides persistence operations for the {@link org.apache.rave.portal.model.PortalPreference}
*/
public interface PortalPreferenceRepository extends Repository<PortalPreference> {
Modified: rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/repository/TagRepository.java
URL: http://svn.apache.org/viewvc/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/repository/TagRepository.java?rev=1354148&r1=1354147&r2=1354148&view=diff
==============================================================================
--- rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/repository/TagRepository.java (original)
+++ rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/repository/TagRepository.java Tue Jun 26 18:18:57 2012
@@ -29,7 +29,7 @@ import java.util.List;
*/
public interface TagRepository extends Repository<Tag> {
/**
- * @return a List of all {@link Tag}'s.
+ * @return a List of all {@link org.apache.rave.portal.model.Tag}'s.
*/
List<Tag> getAll();
@@ -47,7 +47,7 @@ public interface TagRepository extends R
Tag getByKeyword(String keyword);
/**
- * @return a List of all tag not link to this widget{@link Tag}'s.
+ * @return a List of all tag not link to this widget{@link org.apache.rave.portal.model.Tag}'s.
*/
List<Tag> getAvailableTagsByWidgetId(Long widgetId);
Modified: rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/repository/UserRepository.java
URL: http://svn.apache.org/viewvc/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/repository/UserRepository.java?rev=1354148&r1=1354147&r2=1354148&view=diff
==============================================================================
--- rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/repository/UserRepository.java (original)
+++ rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/repository/UserRepository.java Tue Jun 26 18:18:57 2012
@@ -21,29 +21,28 @@ package org.apache.rave.portal.repositor
import org.apache.rave.persistence.Repository;
import org.apache.rave.portal.model.User;
-import java.util.Date;
import java.util.List;
public interface UserRepository extends Repository<User> {
/**
- * Gets a {@link User} by its username
+ * Gets a {@link org.apache.rave.portal.model.User} by its username
*
* @param username the (unique) name of the user
- * @return {@link User} if one exists, otherwise {@literal null}
+ * @return {@link org.apache.rave.portal.model.User} if one exists, otherwise {@literal null}
*/
User getByUsername(String username);
/**
- * Gets a {@link User} by its email address
+ * Gets a {@link org.apache.rave.portal.model.User} by its email address
*
* @param userEmail the (unique) email address of the user
- * @return {@link User} if one exists, otherwise {@literal null}
+ * @return {@link org.apache.rave.portal.model.User} if one exists, otherwise {@literal null}
*/
User getByUserEmail(String userEmail);
/**
- * List of {@link User}'s with a limited resultset
+ * List of {@link org.apache.rave.portal.model.User}'s with a limited resultset
*
* @param offset start point within the total resultset
* @param pageSize maximum number of items to be returned (for paging)
@@ -52,12 +51,12 @@ public interface UserRepository extends
List<User> getLimitedList(int offset, int pageSize);
/**
- * @return the total number of {@link User}'s in the repository. Useful for paging.
+ * @return the total number of {@link org.apache.rave.portal.model.User}'s in the repository. Useful for paging.
*/
int getCountAll();
/**
- * List of {@link User}'s that match a searchterm in their username or email address
+ * List of {@link org.apache.rave.portal.model.User}'s that match a searchterm in their username or email address
*
* @param searchTerm search term
* @param offset start point within the total resultset
@@ -69,7 +68,7 @@ public interface UserRepository extends
/**
*
* @param searchTerm search term
- * @return the total number of {@link User}'s that match a searchterm in their username or email address.
+ * @return the total number of {@link org.apache.rave.portal.model.User}'s that match a searchterm in their username or email address.
* Useful for paging.
*/
int getCountByUsernameOrEmail(String searchTerm);
@@ -83,10 +82,10 @@ public interface UserRepository extends
List<User> getAllByAddedWidget(long widgetId);
/**
- * Gets a {@link User} by generated forgot email hash
+ * Gets a {@link org.apache.rave.portal.model.User} by generated forgot email hash
*
* @param hash unique generated hash
- * @return {@link User} if one exists for given hash, otherwise {@literal null}
+ * @return {@link org.apache.rave.portal.model.User} if one exists for given hash, otherwise {@literal null}
*/
User getByForgotPasswordHash(String hash);
Modified: rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/repository/WidgetRatingRepository.java
URL: http://svn.apache.org/viewvc/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/repository/WidgetRatingRepository.java?rev=1354148&r1=1354147&r2=1354148&view=diff
==============================================================================
--- rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/repository/WidgetRatingRepository.java (original)
+++ rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/repository/WidgetRatingRepository.java Tue Jun 26 18:18:57 2012
@@ -25,11 +25,11 @@ import org.apache.rave.portal.model.Widg
public interface WidgetRatingRepository extends Repository<WidgetRating> {
/**
- * Tries to find a {@link WidgetRating} by the id's of a Widget and USer
+ * Tries to find a {@link org.apache.rave.portal.model.WidgetRating} by the id's of a Widget and USer
*
* @param widgetId unique identifier of a Widget
* @param userId unique identifier of a User
- * @return {@link WidgetRating} if it exists, otherwise {@literal null}
+ * @return {@link org.apache.rave.portal.model.WidgetRating} if it exists, otherwise {@literal null}
*/
WidgetRating getByWidgetIdAndUserId(Long widgetId, Long userId);
Modified: rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/repository/WidgetRepository.java
URL: http://svn.apache.org/viewvc/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/repository/WidgetRepository.java?rev=1354148&r1=1354147&r2=1354148&view=diff
==============================================================================
--- rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/repository/WidgetRepository.java (original)
+++ rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/repository/WidgetRepository.java Tue Jun 26 18:18:57 2012
@@ -124,10 +124,10 @@ public interface WidgetRepository extend
* @return {@link Widget} if it can be found, otherwise {@literal null}
*/
Widget getByUrl(String widgetUrl);
-
+
/**
* Generates the widget statistics for a gadget including the user's specific information.
- *
+ *
* @param widget_id id of the widget
* @param user_id id of the user
* @return {@link WidgetStatistics} with the rating information
@@ -146,7 +146,7 @@ public interface WidgetRepository extend
* Generates the mapping of widget ratings for the user.
*
* @param userId id of the user
- * @return Mapping of {@link WidgetRating} objects keyed off of the widget's entityId
+ * @return Mapping of {@link org.apache.rave.portal.model.WidgetRating} objects keyed off of the widget's entityId
*/
Map<Long, WidgetRating> getUsersWidgetRatings(long userId);
@@ -159,7 +159,7 @@ public interface WidgetRepository extend
* @return valid list of widgets, can be empty
*/
List<Widget> getWidgetsByTag(String tagKeyWord, int offset, int pageSize);
-
+
/**
* Counts the total number of {@link Widget}'s that match tag keyword. Useful for paging.
*
Modified: rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/repository/WidgetTagRepository.java
URL: http://svn.apache.org/viewvc/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/repository/WidgetTagRepository.java?rev=1354148&r1=1354147&r2=1354148&view=diff
==============================================================================
--- rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/repository/WidgetTagRepository.java (original)
+++ rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/repository/WidgetTagRepository.java Tue Jun 26 18:18:57 2012
@@ -24,11 +24,11 @@ import org.apache.rave.portal.model.Widg
public interface WidgetTagRepository extends Repository<WidgetTag> {
/**
- * Tries to find a {@link WidgetTag} by the id's of a Widget and Tag keyword
+ * Tries to find a {@link org.apache.rave.portal.model.WidgetTag} by the id's of a Widget and Tag keyword
*
* @param widgetId unique identifier of a Widget
* @param keyword tag's keyword
- * @return {@link WidgetTag} if it exists, otherwise {@literal null}
+ * @return {@link org.apache.rave.portal.model.WidgetTag} if it exists, otherwise {@literal null}
*/
WidgetTag getByWidgetIdAndTag(Long widgetId, String keyword);
}
Modified: rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/security/impl/DefaultCategoryPermissionEvaluator.java
URL: http://svn.apache.org/viewvc/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/security/impl/DefaultCategoryPermissionEvaluator.java?rev=1354148&r1=1354147&r2=1354148&view=diff
==============================================================================
--- rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/security/impl/DefaultCategoryPermissionEvaluator.java (original)
+++ rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/security/impl/DefaultCategoryPermissionEvaluator.java Tue Jun 26 18:18:57 2012
@@ -43,19 +43,19 @@ public class DefaultCategoryPermissionEv
public DefaultCategoryPermissionEvaluator(CategoryRepository categoryRepository) {
this.categoryRepository = categoryRepository;
}
-
+
@Override
public Class<Category> getType() {
return Category.class;
}
-
+
/**
* Checks to see if the Authentication object has the supplied Permission
* on the supplied Category object. This method invokes the private hasPermission
* function with the trustedDomainObject parameter set to false since we don't
- * know if the model being passed in was modified in any way from the
+ * know if the model being passed in was modified in any way from the
* actual entity in the database.
- *
+ *
* @param authentication the current Authentication object
* @param category the Category model object
* @param permission the Permission to check
@@ -64,16 +64,16 @@ public class DefaultCategoryPermissionEv
@Override
public boolean hasPermission(Authentication authentication, Category category, Permission permission) {
return hasPermission(authentication, category, permission, false);
- }
+ }
/**
- * Checks to see if the Authentication object has the supplied Permission
+ * Checks to see if the Authentication object has the supplied Permission
* for the Entity represented by the targetId(entityId) and targetType(model class name).
- * This method invokes the private hasPermission function with the
+ * This method invokes the private hasPermission function with the
* trustedDomainObject parameter set to true since we must pull the entity
* from the database and are guaranteed a trusted domain object,
* before performing our permission checks.
- *
+ *
* @param authentication the current Authentication object
* @param targetId the entityId of the model to check, or a RaveSecurityContext object
* @param targetType the class of the model to check
@@ -84,27 +84,27 @@ public class DefaultCategoryPermissionEv
public boolean hasPermission(Authentication authentication, Serializable targetId, String targetType, Permission permission) {
boolean hasPermission = false;
if (targetId instanceof RaveSecurityContext) {
- hasPermission = verifyRaveSecurityContext(authentication, (RaveSecurityContext)targetId);
+ hasPermission = verifyRaveSecurityContext(authentication, (RaveSecurityContext)targetId);
} else {
hasPermission = hasPermission(authentication, categoryRepository.get((Long)targetId), permission, true);
}
return hasPermission;
- }
-
+ }
+
private boolean hasPermission(Authentication authentication, Category category, Permission permission, boolean trustedDomainObject) {
// this is our container of trusted category objects that can be re-used
// in this method so that the same trusted category object doesn't have to
// be looked up in the repository multiple times
List<Category> trustedCategoryContainer = new ArrayList<Category>();
-
+
// first execute the AbstractModelPermissionEvaluator's hasPermission function
- // to see if it allows permission via it's "higher authority" logic
+ // to see if it allows permission via it's "higher authority" logic
if (super.hasPermission(authentication, category, permission)) {
return true;
}
-
+
// perform the security logic depending on the Permission type
- boolean hasPermission = false;
+ boolean hasPermission = false;
switch (permission) {
case READ:
// all users can read any Category
@@ -121,10 +121,10 @@ public class DefaultCategoryPermissionEv
log.warn("unknown permission: " + permission);
break;
}
-
+
return hasPermission;
- }
-
+ }
+
// returns a trusted Category object, either from the CategoryRepository, or the
// cached container list
private Category getTrustedCategory(long categoryId, List<Category> trustedCategoryContainer) {
@@ -137,7 +137,7 @@ public class DefaultCategoryPermissionEv
}
return p;
}
-
+
// checks to see if the Authentication object principal is the owner of the supplied category object
// if trustedDomainObject is false, pull the entity from the database first to ensure
// the model object is trusted and hasn't been modified
@@ -146,7 +146,7 @@ public class DefaultCategoryPermissionEv
if (trustedDomainObject) {
trustedCategory = category;
} else {
- trustedCategory = getTrustedCategory(category.getEntityId(), trustedCategoryContainer);
+ trustedCategory = getTrustedCategory(category.getId(), trustedCategoryContainer);
}
return isCategoryCreatedUserByUsername(authentication, trustedCategory.getCreatedUser().getUsername());
@@ -157,7 +157,7 @@ public class DefaultCategoryPermissionEv
}
private boolean isCategoryCreatedUserById(Authentication authentication, Long userId) {
- return ((User)authentication.getPrincipal()).getEntityId().equals(userId);
+ return ((User)authentication.getPrincipal()).getId().equals(userId);
}
private boolean verifyRaveSecurityContext(Authentication authentication, RaveSecurityContext raveSecurityContext) {
Modified: rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/security/impl/DefaultPagePermissionEvaluator.java
URL: http://svn.apache.org/viewvc/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/security/impl/DefaultPagePermissionEvaluator.java?rev=1354148&r1=1354147&r2=1354148&view=diff
==============================================================================
--- rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/security/impl/DefaultPagePermissionEvaluator.java (original)
+++ rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/security/impl/DefaultPagePermissionEvaluator.java Tue Jun 26 18:18:57 2012
@@ -18,10 +18,7 @@
*/
package org.apache.rave.portal.security.impl;
-import org.apache.rave.portal.model.Page;
-import org.apache.rave.portal.model.PageType;
-import org.apache.rave.portal.model.PageUser;
-import org.apache.rave.portal.model.User;
+import org.apache.rave.portal.model.*;
import org.apache.rave.portal.repository.PageRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -35,49 +32,49 @@ import java.util.List;
/**
* The default implementation of the ModelPermissionEvaluator for Page objects
- *
+ *
* @author carlucci
*/
@Component
public class DefaultPagePermissionEvaluator extends AbstractModelPermissionEvaluator<Page> {
private Logger log = LoggerFactory.getLogger(getClass());
- private PageRepository pageRepository;
-
+ private PageRepository pageRepository;
+
@Autowired
- public DefaultPagePermissionEvaluator(PageRepository pageRepository) {
- this.pageRepository = pageRepository;
+ public DefaultPagePermissionEvaluator(PageRepository pageRepository) {
+ this.pageRepository = pageRepository;
}
-
+
@Override
public Class<Page> getType() {
return Page.class;
}
-
+
/**
* Checks to see if the Authentication object has the supplied Permission
* on the supplied Page object. This method invokes the private hasPermission
* function with the trustedDomainObject parameter set to false since we don't
- * know if the model being passed in was modified in any way from the
+ * know if the model being passed in was modified in any way from the
* actual entity in the database.
- *
+ *
* @param authentication the current Authentication object
* @param page the Page model object
* @param permission the Permission to check
* @return true if the Authentication has the proper permission, false otherwise
*/
@Override
- public boolean hasPermission(Authentication authentication, Page page, Permission permission) {
+ public boolean hasPermission(Authentication authentication, Page page, Permission permission) {
return hasPermission(authentication, page, permission, false);
- }
+ }
/**
- * Checks to see if the Authentication object has the supplied Permission
+ * Checks to see if the Authentication object has the supplied Permission
* for the Entity represented by the targetId(entityId) and targetType(model class name).
- * This method invokes the private hasPermission function with the
+ * This method invokes the private hasPermission function with the
* trustedDomainObject parameter set to true since we must pull the entity
* from the database and are guaranteed a trusted domain object,
* before performing our permission checks.
- *
+ *
* @param authentication the current Authentication object
* @param targetId the entityId of the model to check, or a RaveSecurityContext object
* @param targetType the class of the model to check
@@ -88,35 +85,35 @@ public class DefaultPagePermissionEvalua
public boolean hasPermission(Authentication authentication, Serializable targetId, String targetType, Permission permission) {
boolean hasPermission = false;
if (targetId instanceof RaveSecurityContext) {
- hasPermission = verifyRaveSecurityContext(authentication, (RaveSecurityContext)targetId);
+ hasPermission = verifyRaveSecurityContext(authentication, (RaveSecurityContext)targetId);
} else {
hasPermission = hasPermission(authentication, pageRepository.get((Long)targetId), permission, true);
}
return hasPermission;
- }
-
- private boolean hasPermission(Authentication authentication, Page page, Permission permission, boolean trustedDomainObject) {
- // this is our container of trusted page objects that can be re-used
+ }
+
+ private boolean hasPermission(Authentication authentication, Page page, Permission permission, boolean trustedDomainObject) {
+ // this is our container of trusted page objects that can be re-used
// in this method so that the same trusted page object doesn't have to
// be looked up in the repository multiple times
- List<Page> trustedPageContainer = new ArrayList<Page>();
-
+ List<Page> trustedPageContainer = new ArrayList<Page>();
+
// first execute the AbstractModelPermissionEvaluator's hasPermission function
- // to see if it allows permission via it's "higher authority" logic
+ // to see if it allows permission via it's "higher authority" logic
if (super.hasPermission(authentication, page, permission)) {
return true;
}
-
+
// perform the security logic depending on the Permission type
- boolean hasPermission = false;
- switch (permission) {
+ boolean hasPermission = false;
+ switch (permission) {
case ADMINISTER:
- // if you are here, you are not an administrator, so you can't administer pages
+ // if you are here, you are not an administrator, so you can't administer pages
break;
- case CREATE:
- case DELETE:
+ case CREATE:
+ case DELETE:
case UPDATE:
- // anyone can create, delete, or update a page that they own
+ // anyone can create, delete, or update a page that they own
hasPermission = isPageOwner(authentication, page, trustedPageContainer, trustedDomainObject)
|| isPageMember(authentication, page, trustedPageContainer, trustedDomainObject, true);
break;
@@ -129,45 +126,45 @@ public class DefaultPagePermissionEvalua
log.warn("unknown permission: " + permission);
break;
}
-
+
return hasPermission;
- }
-
+ }
+
// returns a trusted Page object, either from the PageRepository, or the
// cached container list
- private Page getTrustedPage(long pageId, List<Page> trustedPageContainer) {
+ private Page getTrustedPage(long pageId, List<Page> trustedPageContainer) {
Page p = null;
- if (trustedPageContainer.isEmpty()) {
+ if (trustedPageContainer.isEmpty()) {
p = pageRepository.get(pageId);
trustedPageContainer.add(p);
} else {
p = trustedPageContainer.get(0);
}
- return p;
- }
-
- // checks to see if the Authentication object principal is the owner of the supplied page object
+ return p;
+ }
+
+ // checks to see if the Authentication object principal is the owner of the supplied page object
// if trustedDomainObject is false, pull the entity from the database first to ensure
// the model object is trusted and hasn't been modified
- private boolean isPageOwner(Authentication authentication, Page page, List<Page> trustedPageContainer, boolean trustedDomainObject) {
+ private boolean isPageOwner(Authentication authentication, Page page, List<Page> trustedPageContainer, boolean trustedDomainObject) {
Page trustedPage = null;
if (trustedDomainObject) {
trustedPage = page;
} else {
- trustedPage = getTrustedPage(page.getEntityId(), trustedPageContainer);
- }
-
+ trustedPage = getTrustedPage(page.getId(), trustedPageContainer);
+ }
+
return isPageOwnerByUsername(authentication, trustedPage.getOwner().getUsername());
- }
+ }
private boolean isPageOwnerByUsername(Authentication authentication, String username) {
return ((User)authentication.getPrincipal()).getUsername().equals(username);
}
-
+
private boolean isPageOwnerById(Authentication authentication, Long userId) {
- return ((User)authentication.getPrincipal()).getEntityId().equals(userId);
- }
-
+ return ((User)authentication.getPrincipal()).getId().equals(userId);
+ }
+
private boolean verifyRaveSecurityContext(Authentication authentication, RaveSecurityContext raveSecurityContext) {
Class<?> clazz = null;
try {
@@ -190,14 +187,14 @@ public class DefaultPagePermissionEvalua
isPageOwner(authentication, page, trustedPageContainer, trustedDomainObject) ||
isPageMember(authentication, page, trustedPageContainer, trustedDomainObject, false);
}
-
+
private boolean isPersonProfilePageOrSubPage(Page page) {
PageType pageType = page.getPageType();
PageType parentPageType = (page.getParentPage() == null) ? null : page.getParentPage().getPageType();
return PageType.PERSON_PROFILE.equals(pageType) || PageType.PERSON_PROFILE.equals(parentPageType);
- }
-
- // checks to see if the Authentication object principal is a member of the supplied page object
+ }
+
+ // checks to see if the Authentication object principal is a member of the supplied page object
// if trustedDomainObject is false, pull the entity from the database first to ensure
// the model object is trusted and hasn't been modified
private boolean isPageMember(Authentication authentication, Page page, List<Page> trustedPageContainer, boolean trustedDomainObject, boolean checkEditorStatus) {
@@ -205,7 +202,7 @@ public class DefaultPagePermissionEvalua
if (trustedDomainObject) {
trustedPage = page;
} else {
- trustedPage = getTrustedPage(page.getEntityId(), trustedPageContainer);
+ trustedPage = getTrustedPage(page.getId(), trustedPageContainer);
}
//
// If the page has no members, there can be no member access
@@ -217,17 +214,20 @@ public class DefaultPagePermissionEvalua
// Check that the viewer is a member
//
String viewer = ((User)authentication.getPrincipal()).getUsername();
- for (PageUser pageUser:trustedPage.getMembers()){
- if (pageUser.getUser().getUsername().equals(viewer)){
- log.info("User "+viewer+" is a member of page "+trustedPage.getEntityId());
- if(checkEditorStatus){
- log.info("checking editor:"+trustedPage.getEntityId()+"@"+viewer+"@"+pageUser.isEditor());
- return pageUser.isEditor();
+ List<PageUser> members = trustedPage.getMembers();
+ if (members != null) {
+ for (PageUser pageUser : members){
+ if (pageUser.getUser().getUsername().equals(viewer)){
+ log.info("User "+viewer+" is a member of page "+trustedPage.getId());
+ if(checkEditorStatus){
+ log.info("checking editor:"+trustedPage.getId()+"@"+viewer+"@"+pageUser.isEditor());
+ return pageUser.isEditor();
+ }
+ return true;
}
- return true;
}
}
- log.info("User "+viewer+" is NOT a member of page "+trustedPage.getEntityId());
+ log.info("User "+viewer+" is NOT a member of page "+trustedPage.getId());
return false;
}
Modified: rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/security/impl/DefaultRegionPermissionEvaluator.java
URL: http://svn.apache.org/viewvc/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/security/impl/DefaultRegionPermissionEvaluator.java?rev=1354148&r1=1354147&r2=1354148&view=diff
==============================================================================
--- rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/security/impl/DefaultRegionPermissionEvaluator.java (original)
+++ rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/security/impl/DefaultRegionPermissionEvaluator.java Tue Jun 26 18:18:57 2012
@@ -18,11 +18,7 @@
*/
package org.apache.rave.portal.security.impl;
-import org.apache.rave.portal.model.Page;
-import org.apache.rave.portal.model.PageUser;
-import org.apache.rave.portal.model.Region;
-import org.apache.rave.portal.model.RegionWidget;
-import org.apache.rave.portal.model.User;
+import org.apache.rave.portal.model.*;
import org.apache.rave.portal.repository.RegionRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -149,7 +145,7 @@ public class DefaultRegionPermissionEval
if (trustedDomainObject) {
trustedRegion = region;
} else {
- trustedRegion = getTrustedRegion(region.getEntityId(), trustedRegionContainer);
+ trustedRegion = getTrustedRegion(region.getId(), trustedRegionContainer);
}
return isRegionOwnerByUsername(authentication, trustedRegion.getPage().getOwner().getUsername());
}
@@ -159,7 +155,7 @@ public class DefaultRegionPermissionEval
}
private boolean isRegionOwnerById(Authentication authentication, Long userId) {
- return ((User)authentication.getPrincipal()).getEntityId().equals(userId);
+ return ((User)authentication.getPrincipal()).getId().equals(userId);
}
private boolean verifyRaveSecurityContext(Authentication authentication, RaveSecurityContext raveSecurityContext) {
@@ -177,18 +173,18 @@ public class DefaultRegionPermissionEval
throw new IllegalArgumentException("unknown RaveSecurityContext type: " + raveSecurityContext.getType());
}
}
-
+
private boolean isRegionMember(Authentication authentication, Region region, List<Region> trustedRegionContainer, boolean trustedDomainObject, boolean checkEditorStatus) {
Region trustedRegion = null;
if (trustedDomainObject) {
trustedRegion = region;
} else {
- trustedRegion = getTrustedRegion(region.getEntityId(), trustedRegionContainer);
+ trustedRegion = getTrustedRegion(region.getId(), trustedRegionContainer);
}
-
+
Page containerPage = trustedRegion.getPage();
-
-
+
+
if (containerPage.getMembers() == null){
return false;
}
@@ -198,7 +194,7 @@ public class DefaultRegionPermissionEval
String viewer = ((User)authentication.getPrincipal()).getUsername();
for (PageUser pageUser:containerPage.getMembers()){
if (pageUser.getUser().getUsername().equals(viewer)){
- log.info("User "+viewer+" is a member of page "+containerPage.getEntityId());
+ log.info("User "+viewer+" is a member of page "+containerPage.getId());
if(checkEditorStatus){
return pageUser.isEditor();
}
Modified: rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/security/impl/DefaultRegionWidgetPermissionEvaluator.java
URL: http://svn.apache.org/viewvc/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/security/impl/DefaultRegionWidgetPermissionEvaluator.java?rev=1354148&r1=1354147&r2=1354148&view=diff
==============================================================================
--- rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/security/impl/DefaultRegionWidgetPermissionEvaluator.java (original)
+++ rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/security/impl/DefaultRegionWidgetPermissionEvaluator.java Tue Jun 26 18:18:57 2012
@@ -18,10 +18,7 @@
*/
package org.apache.rave.portal.security.impl;
-import org.apache.rave.portal.model.Page;
-import org.apache.rave.portal.model.PageUser;
-import org.apache.rave.portal.model.RegionWidget;
-import org.apache.rave.portal.model.User;
+import org.apache.rave.portal.model.*;
import org.apache.rave.portal.repository.RegionWidgetRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -148,7 +145,7 @@ public class DefaultRegionWidgetPermissi
if (trustedDomainObject) {
trustedRegionWidget = regionWidget;
} else {
- trustedRegionWidget = getTrustedRegionWidget(regionWidget.getEntityId(), trustedRegionWidgetContainer);
+ trustedRegionWidget = getTrustedRegionWidget(regionWidget.getId(), trustedRegionWidgetContainer);
}
return isRegionWidgetOwnerByUsername(authentication, getUsernameFromRegionWidget(trustedRegionWidget));
}
@@ -158,7 +155,7 @@ public class DefaultRegionWidgetPermissi
}
private boolean isRegionWidgetOwnerById(Authentication authentication, Long userId) {
- return ((User)authentication.getPrincipal()).getEntityId().equals(userId);
+ return ((User)authentication.getPrincipal()).getId().equals(userId);
}
private boolean verifyRaveSecurityContext(Authentication authentication, RaveSecurityContext raveSecurityContext) {
@@ -176,23 +173,23 @@ public class DefaultRegionWidgetPermissi
throw new IllegalArgumentException("unknown RaveSecurityContext type: " + raveSecurityContext.getType());
}
}
-
+
private String getUsernameFromRegionWidget(RegionWidget regionWidget) {
return regionWidget.getRegion().getPage().getOwner().getUsername();
}
-
- private boolean isRegionWidgetMember(Authentication authentication,
+
+ private boolean isRegionWidgetMember(Authentication authentication,
RegionWidget regionWidget, List<RegionWidget> trustedRegionWidgetContainer, boolean trustedDomainObject, boolean checkEditorStatus) {
RegionWidget trustedRegionWidget = null;
if (trustedDomainObject) {
trustedRegionWidget = regionWidget;
} else {
- trustedRegionWidget = getTrustedRegionWidget(regionWidget.getEntityId(), trustedRegionWidgetContainer);
+ trustedRegionWidget = getTrustedRegionWidget(regionWidget.getId(), trustedRegionWidgetContainer);
}
-
+
Page containerPage = trustedRegionWidget.getRegion().getPage();
-
-
+
+
if (containerPage.getMembers() == null){
return false;
}
@@ -202,7 +199,7 @@ public class DefaultRegionWidgetPermissi
String viewer = ((User)authentication.getPrincipal()).getUsername();
for (PageUser pageUser:containerPage.getMembers()){
if (pageUser.getUser().getUsername().equals(viewer)){
- log.info("User "+viewer+" is a member of page "+containerPage.getEntityId());
+ log.info("User "+viewer+" is a member of page "+containerPage.getId());
if(checkEditorStatus){
return pageUser.isEditor();
}
Modified: rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/security/impl/DefaultWidgetCommentPermissionEvaluator.java
URL: http://svn.apache.org/viewvc/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/security/impl/DefaultWidgetCommentPermissionEvaluator.java?rev=1354148&r1=1354147&r2=1354148&view=diff
==============================================================================
--- rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/security/impl/DefaultWidgetCommentPermissionEvaluator.java (original)
+++ rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/security/impl/DefaultWidgetCommentPermissionEvaluator.java Tue Jun 26 18:18:57 2012
@@ -15,19 +15,19 @@
*/
package org.apache.rave.portal.security.impl;
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
import org.apache.rave.portal.model.User;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.apache.rave.portal.model.WidgetComment;
import org.apache.rave.portal.repository.WidgetCommentRepository;
-import org.apache.rave.portal.security.ModelPermissionEvaluator.Permission;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
import org.springframework.stereotype.Component;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
/**
*/
@Component
@@ -35,12 +35,12 @@ public class DefaultWidgetCommentPermiss
private Logger log = LoggerFactory.getLogger(getClass());
private WidgetCommentRepository widgetCommentRepository;
-
+
@Autowired
public DefaultWidgetCommentPermissionEvaluator(WidgetCommentRepository widgetCommentRepository) {
this.widgetCommentRepository = widgetCommentRepository;
}
-
+
@Override
public Class<WidgetComment> getType() {
return WidgetComment.class;
@@ -50,27 +50,27 @@ public class DefaultWidgetCommentPermiss
* Checks to see if the Authentication object has the supplied Permission
* on the supplied Page object. This method invokes the private hasPermission
* function with the trustedDomainObject parameter set to false since we don't
- * know if the model being passed in was modified in any way from the
+ * know if the model being passed in was modified in any way from the
* actual entity in the database.
- *
+ *
* @param authentication the current Authentication object
* @param widgetComment the WidgetComment model object
* @param permission the Permission to check
* @return true if the Authentication has the proper permission, false otherwise
*/
@Override
- public boolean hasPermission(Authentication authentication, WidgetComment widgetComment, Permission permission) {
+ public boolean hasPermission(Authentication authentication, WidgetComment widgetComment, Permission permission) {
return hasPermission(authentication, widgetComment, permission, false);
- }
+ }
/**
- * Checks to see if the Authentication object has the supplied Permission
+ * Checks to see if the Authentication object has the supplied Permission
* for the Entity represented by the targetId(entityId) and targetType(model class name).
- * This method invokes the private hasPermission function with the
+ * This method invokes the private hasPermission function with the
* trustedDomainObject parameter set to true since we must pull the entity
* from the database and are guaranteed a trusted domain object,
* before performing our permission checks.
- *
+ *
* @param authentication the current Authentication object
* @param targetId the entityId of the model to check, or a RaveSecurityContext object
* @param targetType the class of the model to check
@@ -81,50 +81,50 @@ public class DefaultWidgetCommentPermiss
public boolean hasPermission(Authentication authentication, Serializable targetId, String targetType, Permission permission) {
boolean hasPermission = false;
if (targetId instanceof RaveSecurityContext) {
- hasPermission = verifyRaveSecurityContext(authentication, (RaveSecurityContext)targetId, permission);
+ hasPermission = verifyRaveSecurityContext(authentication, (RaveSecurityContext)targetId, permission);
} else {
hasPermission = hasPermission(authentication, widgetCommentRepository.get((Long)targetId), permission, true);
}
return hasPermission;
- }
-
- private boolean hasPermission(Authentication authentication, WidgetComment widgetComment, Permission permission, boolean trustedDomainObject) {
- // this is our container of trusted page objects that can be re-used
+ }
+
+ private boolean hasPermission(Authentication authentication, WidgetComment widgetComment, Permission permission, boolean trustedDomainObject) {
+ // this is our container of trusted page objects that can be re-used
// in this method so that the same trusted page object doesn't have to
// be looked up in the repository multiple times
- List<WidgetComment> trustedWidgetCommentContainer = new ArrayList<WidgetComment>();
-
+ List<WidgetComment> trustedWidgetCommentContainer = new ArrayList<WidgetComment>();
+
// first execute the AbstractModelPermissionEvaluator's hasPermission function
- // to see if it allows permission via it's "higher authority" logic
+ // to see if it allows permission via it's "higher authority" logic
if (super.hasPermission(authentication, widgetComment, permission)) {
return true;
}
-
+
// perform the security logic depending on the Permission type
- boolean hasPermission = false;
- switch (permission) {
+ boolean hasPermission = false;
+ switch (permission) {
case ADMINISTER:
- // if you are here, you are not an administrator, so you can't administer pages
+ // if you are here, you are not an administrator, so you can't administer pages
break;
case READ:
hasPermission = true;
break;
case CREATE:
- hasPermission = isWidgetCommentOwnerById(authentication, widgetComment.getUser().getEntityId());
+ hasPermission = isWidgetCommentOwnerById(authentication, widgetComment.getUser().getId());
break;
case DELETE:
case UPDATE:
- // anyone can create, delete, read, or update a page that they own
- hasPermission = isWidgetCommentOwner(authentication, widgetComment, trustedWidgetCommentContainer, trustedDomainObject);
- break;
+ // anyone can create, delete, read, or update a page that they own
+ hasPermission = isWidgetCommentOwner(authentication, widgetComment, trustedWidgetCommentContainer, trustedDomainObject);
+ break;
default:
log.warn("unknown permission: " + permission);
break;
}
-
+
return hasPermission;
}
-
+
private boolean verifyRaveSecurityContext(Authentication authentication, RaveSecurityContext raveSecurityContext, Permission permission) {
Class<?> clazz = null;
try {
@@ -135,65 +135,62 @@ public class DefaultWidgetCommentPermiss
// perform the permissions check based on the class supplied to the RaveSecurityContext object
if (WidgetComment.class == clazz) {
-
- // perform the security logic depending on the Permission type
- boolean hasPermission = false;
- switch (permission) {
- case ADMINISTER:
- // if you are here, you are not an administrator, so you can't administer pages
- break;
- case READ:
- hasPermission = true;
- break;
- case CREATE:
- case DELETE:
- case UPDATE:
- // anyone can create, delete, read, or update a page that they own
- hasPermission = isWidgetCommentOwnerById(authentication, (Long)raveSecurityContext.getId());
- break;
- default:
- log.warn("unknown permission: " + permission);
- break;
+ // perform the security logic depending on the Permission type
+ boolean hasPermission = false;
+ switch (permission) {
+ case ADMINISTER:
+ // if you are here, you are not an administrator, so you can't administer pages
+ break;
+ case READ:
+ hasPermission = true;
+ break;
+ case CREATE:
+ case DELETE:
+ case UPDATE:
+ // anyone can create, delete, read, or update a page that they own
+ hasPermission = isWidgetCommentOwnerById(authentication, (Long)raveSecurityContext.getId());
+ break;
+ default:
+ log.warn("unknown permission: " + permission);
+ break;
}
-
return hasPermission;
} else {
throw new IllegalArgumentException("unknown RaveSecurityContext type: " + raveSecurityContext.getType());
}
- }
-
-
- // checks to see if the Authentication object principal is the owner of the supplied widgetComment object
+ }
+
+ // checks to see if the Authentication object principal is the owner of the supplied widgetComment object
// if trustedDomainObject is false, pull the entity from the database first to ensure
// the model object is trusted and hasn't been modified
- private boolean isWidgetCommentOwner(Authentication authentication, WidgetComment widgetComment, List<WidgetComment> trustedPageContainer, boolean trustedDomainObject) {
+ private boolean isWidgetCommentOwner(Authentication authentication, WidgetComment widgetComment, List<WidgetComment> trustedPageContainer, boolean trustedDomainObject) {
WidgetComment trustedWidgetComment = null;
if (trustedDomainObject) {
trustedWidgetComment = widgetComment;
} else {
- trustedWidgetComment = getTrustedWidgetComment(widgetComment.getEntityId(), trustedPageContainer);
- }
-
+ trustedWidgetComment = getTrustedWidgetComment(widgetComment.getId(), trustedPageContainer);
+ }
+
return isWidgetCommentOwnerByUsername(authentication, trustedWidgetComment.getUser().getUsername());
- }
-
+ }
+
// returns a trusted Page object, either from the PageRepository, or the
// cached container list
- private WidgetComment getTrustedWidgetComment(long widgetCommentId, List<WidgetComment> trustedWidgetCommentContainer) {
+ private WidgetComment getTrustedWidgetComment(long widgetCommentId, List<WidgetComment> trustedWidgetCommentContainer) {
WidgetComment p = null;
- if (trustedWidgetCommentContainer.isEmpty()) {
+ if (trustedWidgetCommentContainer.isEmpty()) {
p = widgetCommentRepository.get(widgetCommentId);
trustedWidgetCommentContainer.add(p);
} else {
p = trustedWidgetCommentContainer.get(0);
}
- return p;
- }
+ return p;
+ }
private boolean isWidgetCommentOwnerByUsername(Authentication authentication, String username) {
return ((User)authentication.getPrincipal()).getUsername().equals(username);
}
private boolean isWidgetCommentOwnerById(Authentication authentication, Long userId) {
- return ((User)authentication.getPrincipal()).getEntityId().equals(userId);
+ return ((User)authentication.getPrincipal()).getId().equals(userId);
}
}
Modified: rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/security/impl/DefaultWidgetPermissionEvaluator.java
URL: http://svn.apache.org/viewvc/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/security/impl/DefaultWidgetPermissionEvaluator.java?rev=1354148&r1=1354147&r2=1354148&view=diff
==============================================================================
--- rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/security/impl/DefaultWidgetPermissionEvaluator.java (original)
+++ rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/security/impl/DefaultWidgetPermissionEvaluator.java Tue Jun 26 18:18:57 2012
@@ -151,7 +151,7 @@ public class DefaultWidgetPermissionEval
if (trustedDomainObject) {
trustedWidget = widget;
} else {
- trustedWidget = getTrustedWidget(widget.getEntityId(), trustedWidgetContainer);
+ trustedWidget = getTrustedWidget(widget.getId(), trustedWidgetContainer);
}
return isWidgetOwnerByUsername(authentication, trustedWidget.getOwner().getUsername());
}
@@ -161,7 +161,7 @@ public class DefaultWidgetPermissionEval
}
private boolean isWidgetOwnerById(Authentication authentication, Long userId) {
- return ((User)authentication.getPrincipal()).getEntityId().equals(userId);
+ return ((User)authentication.getPrincipal()).getId().equals(userId);
}
private boolean isPublishedWidget(Widget widget, List<Widget> trustedWidgetContainer, boolean trustedDomainObject) {
@@ -169,7 +169,7 @@ public class DefaultWidgetPermissionEval
if (trustedDomainObject) {
trustedWidget = widget;
} else {
- trustedWidget = getTrustedWidget(widget.getEntityId(), trustedWidgetContainer);
+ trustedWidget = getTrustedWidget(widget.getId(), trustedWidgetContainer);
}
return WidgetStatus.PUBLISHED.equals(trustedWidget.getWidgetStatus());
}
Modified: rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/security/impl/DefaultWidgetRatingPermissionEvaluator.java
URL: http://svn.apache.org/viewvc/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/security/impl/DefaultWidgetRatingPermissionEvaluator.java?rev=1354148&r1=1354147&r2=1354148&view=diff
==============================================================================
--- rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/security/impl/DefaultWidgetRatingPermissionEvaluator.java (original)
+++ rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/security/impl/DefaultWidgetRatingPermissionEvaluator.java Tue Jun 26 18:18:57 2012
@@ -146,7 +146,7 @@ public class DefaultWidgetRatingPermissi
if (trustedDomainObject) {
trustedWidgetRating = widgetRating;
} else {
- trustedWidgetRating = getTrustedWidgetRating(widgetRating.getEntityId(), trustedWidgetRatingContainer);
+ trustedWidgetRating = getTrustedWidgetRating(widgetRating.getId(), trustedWidgetRatingContainer);
}
return isWidgetRatingOwnerById(authentication, trustedWidgetRating.getUserId());
}
@@ -156,7 +156,7 @@ public class DefaultWidgetRatingPermissi
}
private boolean isWidgetRatingOwnerById(Authentication authentication, Long userId) {
- return ((User)authentication.getPrincipal()).getEntityId().equals(userId);
+ return ((User)authentication.getPrincipal()).getId().equals(userId);
}
private boolean verifyRaveSecurityContext(Authentication authentication, RaveSecurityContext raveSecurityContext) {
Modified: rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/security/impl/DefaultWidgetTagPermissionEvaluator.java
URL: http://svn.apache.org/viewvc/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/security/impl/DefaultWidgetTagPermissionEvaluator.java?rev=1354148&r1=1354147&r2=1354148&view=diff
==============================================================================
--- rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/security/impl/DefaultWidgetTagPermissionEvaluator.java (original)
+++ rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/security/impl/DefaultWidgetTagPermissionEvaluator.java Tue Jun 26 18:18:57 2012
@@ -110,7 +110,7 @@ public class DefaultWidgetTagPermissionE
hasPermission = true;
break;
case CREATE:
- hasPermission = isWidgetTagOwnerById(authentication, widgetTag.getUser().getEntityId());
+ hasPermission = isWidgetTagOwnerById(authentication, widgetTag.getUser().getId());
break;
case DELETE:
case UPDATE:
@@ -170,7 +170,7 @@ public class DefaultWidgetTagPermissionE
if (trustedDomainObject) {
trustedWidgetTag = widgetTag;
} else {
- trustedWidgetTag = getTrustedWidgetTag(widgetTag.getEntityId(), trustedWidgetTagContainer);
+ trustedWidgetTag = getTrustedWidgetTag(widgetTag.getWidgetId(), widgetTag.getTag().getKeyword(), trustedWidgetTagContainer);
}
return isWidgetTagOwnerByUsername(authentication, trustedWidgetTag.getUser().getUsername());
@@ -178,10 +178,10 @@ public class DefaultWidgetTagPermissionE
// returns a trusted WidgetTag object, either from the WidgetTagRepository, or the
// cached container list
- private WidgetTag getTrustedWidgetTag(long widgetTagId, List<WidgetTag> trustedWidgetTagContainer) {
+ private WidgetTag getTrustedWidgetTag(long widgetId, String tagKeyword, List<WidgetTag> trustedWidgetTagContainer) {
WidgetTag p = null;
if (trustedWidgetTagContainer.isEmpty()) {
- p = widgetTagRepository.get(widgetTagId);
+ p = widgetTagRepository.getByWidgetIdAndTag(widgetId, tagKeyword);
trustedWidgetTagContainer.add(p);
} else {
p = trustedWidgetTagContainer.get(0);
@@ -193,6 +193,6 @@ public class DefaultWidgetTagPermissionE
return ((User)authentication.getPrincipal()).getUsername().equals(username);
}
private boolean isWidgetTagOwnerById(Authentication authentication, Long userId) {
- return ((User)authentication.getPrincipal()).getEntityId().equals(userId);
+ return ((User)authentication.getPrincipal()).getId().equals(userId);
}
}