Skip to content
This repository was archived by the owner on Nov 21, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 83 additions & 0 deletions src/com/mcplusa/google/feeder/GSAACLItem.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
package com.mcplusa.google.feeder;

import com.mcplusa.google.feeder.enums.ACLCaseSensitivityType;
import com.mcplusa.google.feeder.enums.ACLInheritanceType;
import com.mcplusa.google.feeder.enums.ACLPrincipalAccess;
import com.mcplusa.google.feeder.enums.ACLPrincipalScope;
import java.util.ArrayList;
import java.util.List;

public class GSAACLItem {
private String url;
private ACLInheritanceType inheritanceType;
private String inheritFrom;
private List<GSAACLPrincipal> principals;

public GSAACLItem() {
this.principals = new ArrayList<GSAACLPrincipal>();
}

public String getUrl() {
return url;
}

public void setUrl(String url) {
this.url = url;
}

public ACLInheritanceType getInheritanceType() {
return inheritanceType;
}

public void setInheritanceType(ACLInheritanceType inheritanceType) {
this.inheritanceType = inheritanceType;
}

public String getInheritFrom() {
return inheritFrom;
}

public void setInheritFrom(String inheritFrom) {
this.inheritFrom = inheritFrom;
}

public List<GSAACLPrincipal> getPrincipals() {
return principals;
}

public void addUserPrincipal(String username, ACLPrincipalAccess access) {
this.addUserPrincipal(username, access,
ACLCaseSensitivityType.ACL_PRINCIPAL_CASE_INSENSITIVE,
"Default");
}

public void addUserPrincipal(String username, ACLPrincipalAccess access,
ACLCaseSensitivityType caseSensitivity, String namespace) {
this.addPrincipal(username, access, caseSensitivity,
namespace, ACLPrincipalScope.ACL_PRINCIPAL_SCOPE_USER);
}

public void addGroupPrincipal(String groupName, ACLPrincipalAccess access) {
this.addGroupPrincipal(groupName, access,
ACLCaseSensitivityType.ACL_PRINCIPAL_CASE_INSENSITIVE,
"Default");
}

public void addGroupPrincipal(String groupName, ACLPrincipalAccess access,
ACLCaseSensitivityType caseSensitivity, String namespace) {
this.addPrincipal(groupName, access, caseSensitivity,
namespace, ACLPrincipalScope.ACL_PRINCIPAL_SCOPE_GROUP);
}

private void addPrincipal(String name, ACLPrincipalAccess access,
ACLCaseSensitivityType caseSensitivity, String namespace,
ACLPrincipalScope scope) {
GSAACLPrincipal principal = new GSAACLPrincipal();
principal.setAccess(access);
principal.setCaseSensitivityType(caseSensitivity);
principal.setContent(name);
principal.setNamespace(namespace);
principal.setScope(scope);
this.principals.add(principal);
}
}
53 changes: 53 additions & 0 deletions src/com/mcplusa/google/feeder/GSAACLPrincipal.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package com.mcplusa.google.feeder;

import com.mcplusa.google.feeder.enums.ACLCaseSensitivityType;
import com.mcplusa.google.feeder.enums.ACLPrincipalAccess;
import com.mcplusa.google.feeder.enums.ACLPrincipalScope;

public class GSAACLPrincipal {
private String namespace;
private ACLCaseSensitivityType caseSensitivityType;
private ACLPrincipalScope scope;
private ACLPrincipalAccess access;
private String content;

public String getNamespace() {
return namespace;
}

public void setNamespace(String namespace) {
this.namespace = namespace;
}

public ACLCaseSensitivityType getCaseSensitivityType() {
return caseSensitivityType;
}

public void setCaseSensitivityType(ACLCaseSensitivityType caseSensitivityType) {
this.caseSensitivityType = caseSensitivityType;
}

public ACLPrincipalScope getScope() {
return scope;
}

public void setScope(ACLPrincipalScope scope) {
this.scope = scope;
}

public ACLPrincipalAccess getAccess() {
return access;
}

public void setAccess(ACLPrincipalAccess access) {
this.access = access;
}

public String getContent() {
return content;
}

public void setContent(String content) {
this.content = content;
}
}
9 changes: 9 additions & 0 deletions src/com/mcplusa/google/feeder/GSAContentItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class GSAContentItem {
protected Date lastModified;
protected ArrayList metaData;
protected String authMethod = GSAAuthMethodTypes.AUTH_METHOD_NONE;
protected GSAACLItem acl;

public GSAContentItem()
{
Expand Down Expand Up @@ -110,6 +111,14 @@ public void setAuthmethod(String newAuthMethod)
{
authMethod = newAuthMethod;
}

public void setAcl(GSAACLItem acl) {
this.acl = acl;
}

public GSAACLItem getAcl() {
return this.acl;
}

public void addMetaData(String name, String content)
{
Expand Down
37 changes: 37 additions & 0 deletions src/com/mcplusa/google/feeder/GSAFeed.java
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ public void AddRecord(GSAContentItem item) {
}

recordNode.setAttribute("authmethod", item.getAuthMethod());
if (item.getAcl() != null) {
this.AddACL(item.getAcl(), recordNode, true);
}
if (item.metaData.size() > 0) {
Element metaData = doc.createElement("metadata");
GSAMetaDataItem metaItem;
Expand All @@ -183,8 +186,42 @@ public void AddRecord(GSAContentItem item) {
content.setTextContent(item.getContent());
recordNode.appendChild(content);
}

groupNode.appendChild(recordNode);
count++;

}

public void AddACL(GSAACLItem item) {
this.AddACL(item, groupNode, false);
}

private void AddACL(GSAACLItem item, Node aclContainer, boolean aclInsideRecord) {
Element aclNode = doc.createElement("acl");
if (!aclInsideRecord) {
aclNode.setAttribute("url", item.getUrl());
}

if (item.getInheritanceType() != null) {
aclNode.setAttribute("inheritance-type", item.getInheritanceType().getValue());
}

if (item.getInheritFrom() != null && item.getInheritFrom().trim().length() != 0) {
aclNode.setAttribute("inherit-from", item.getInheritFrom());
}

if (item.getPrincipals().size() > 0) {
for (GSAACLPrincipal principalItem : item.getPrincipals()) {
Element principal = doc.createElement("principal");
principal.setAttribute("namespace", principalItem.getNamespace());
principal.setAttribute("case-sensitivity-type", principalItem.getCaseSensitivityType().getValue());
principal.setAttribute("scope", principalItem.getScope().getValue());
principal.setAttribute("access", principalItem.getAccess().getValue());
principal.appendChild(doc.createTextNode(principalItem.getContent()));
aclNode.appendChild(principal);
}
}

aclContainer.appendChild(aclNode);
}
}
16 changes: 16 additions & 0 deletions src/com/mcplusa/google/feeder/enums/ACLCaseSensitivityType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.mcplusa.google.feeder.enums;

public enum ACLCaseSensitivityType {
ACL_PRINCIPAL_CASE_SENSITIVE("everything-case-sensitive"),
ACL_PRINCIPAL_CASE_INSENSITIVE("everything-case-insensitive");

private final String aclCaseSensitiveType;

ACLCaseSensitivityType(String aclCaseSensitiveType) {
this.aclCaseSensitiveType = aclCaseSensitiveType;
}

public String getValue() {
return this.aclCaseSensitiveType;
}
}
18 changes: 18 additions & 0 deletions src/com/mcplusa/google/feeder/enums/ACLInheritanceType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.mcplusa.google.feeder.enums;

public enum ACLInheritanceType {
ACL_INHERITANCE_TYPE_PARENT_OVERRIDES("parent-overrides"),
ACL_INHERITANCE_TYPE_CHILD_OVERRIDES("child-overrides"),
ACL_INHERITANCE_TYPE_AND_BOTH_PERMIT("and-both-permit"),
ACL_INHERITANCE_TYPE_LEAF_NODE("leaf-node");

private final String aclInheritanceType;

ACLInheritanceType(String aclInheritanceType) {
this.aclInheritanceType = aclInheritanceType;
}

public String getValue() {
return this.aclInheritanceType;
}
}
16 changes: 16 additions & 0 deletions src/com/mcplusa/google/feeder/enums/ACLPrincipalAccess.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.mcplusa.google.feeder.enums;

public enum ACLPrincipalAccess {
ACL_PRINCIPAL_ACCESS_PERMIT("permit"),
ACL_PRINCIPAL_ACCESS_DENY("deny");

private final String aclPrincipalAccess;

ACLPrincipalAccess(String aclPrincipalAccess) {
this.aclPrincipalAccess = aclPrincipalAccess;
}

public String getValue() {
return this.aclPrincipalAccess;
}
}
16 changes: 16 additions & 0 deletions src/com/mcplusa/google/feeder/enums/ACLPrincipalScope.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.mcplusa.google.feeder.enums;

public enum ACLPrincipalScope {
ACL_PRINCIPAL_SCOPE_USER("user"),
ACL_PRINCIPAL_SCOPE_GROUP("group");

private final String aclPrincipalScope;

ACLPrincipalScope(String aclPrincipalScope) {
this.aclPrincipalScope = aclPrincipalScope;
}

public String getValue() {
return this.aclPrincipalScope;
}
}