Skip to content

Commit

Permalink
Add models for GitHub users and repos; update intent-filter service p…
Browse files Browse the repository at this point in the history
…olicy (issue #2)
  • Loading branch information
sahan committed Jul 25, 2013
1 parent 87f896c commit 86cf2fb
Show file tree
Hide file tree
Showing 9 changed files with 617 additions and 111 deletions.
1 change: 1 addition & 0 deletions travisjr/res/values/errors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@
<string name="err_no_repos_found">No Repositories Found</string>
<string name="err_fetching_repos">Failed to fetch repositories.</string>
<string name="err_fetching_build_info">Failed to fetch info...</string>
<string name="err_github_msg_not_found">Not Found</string>

</resources>
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
package com.lonepulse.travisjr.model;

/*
* #%L
* Travis Jr. App
* %%
* Copyright (C) 2013 Lonepulse
* %%
* 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
*
* 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.
* #L%
*/


import java.io.Serializable;

/**
* <p>This model represents a GitHub repository.</p>
*
* <p><b>Note</b> that this is a partial representation of the complete Repository model (available
* via the service {@code https://api.github.com/repos}) which is used for authentication and
* for retrieving the repository slug in its proper case.
*
* @since 1.1.0
* <br><br>
* @version 1.1.0
* <br><br>
* @author <a href="mailto:sahan@lonepulse.com">Lahiru Sahan Jayasinghe</a>
*/
public class GitHubRepository implements Serializable {


private static final long serialVersionUID = -957338228041395159L;

/**
* <p>Identifies this GitHub repository uniquely.
*/
private String id;

/**
* <p>The name of this GitHub repository <b>in its proper case</b>.
*/
private String name;

/**
* <p>The complete </i>slug</i> for this GitHub repository <b>in its proper case</b>.
*/
private String full_name;

/**
* <p>A message which describes an API request failure.
*/
private String message;


/**
* <p>Accessor for id.
*
* @return the id
*/
public String getId() {
return id;
}

/**
* <p>Mutator for id.
*
* @param id
* the id to set
*/
public void setId(String id) {
this.id = id;
}

/**
* <p>Accessor for name.
*
* @return the name
*/
public String getName() {
return name;
}

/**
* <p>Mutator for name.
*
* @param name
* the name to set
*/
public void setName(String name) {
this.name = name;
}

/**
* <p>Accessor for full_name.
*
* @return the full_name
*/
public String getFull_name() {
return full_name;
}

/**
* <p>Mutator for full_name.
*
* @param full_name
* the full_name to set
*/
public void setFull_name(String full_name) {
this.full_name = full_name;
}

/**
* <p>Accessor for message.
*
* @return the message
*/
public String getMessage() {
return message;
}

/**
* <p>Mutator for message.
*
* @param message
* the message to set
*/
public void setMessage(String message) {
this.message = message;
}

@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((id == null) ? 0 : id.hashCode());
return result;
}

@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
GitHubRepository other = (GitHubRepository) obj;
if (id == null) {
if (other.id != null)
return false;
} else if (!id.equals(other.id))
return false;
return true;
}

@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("GitHubRepository [id=");
builder.append(id);
builder.append(", name=");
builder.append(name);
builder.append(", full_name=");
builder.append(full_name);
builder.append("]");
return builder.toString();
}
}
149 changes: 149 additions & 0 deletions travisjr/src/main/java/com/lonepulse/travisjr/model/GitHubUser.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
package com.lonepulse.travisjr.model;

/*
* #%L
* Travis Jr. App
* %%
* Copyright (C) 2013 Lonepulse
* %%
* 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
*
* 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.
* #L%
*/


import java.io.Serializable;

/**
* <p>This model represents a GitHub user. This could be an individual or an organization.</p>
*
* <p><b>Note</b> that this is a partial representation of the complete User model (available
* via the service {@code https://api.github.com/users}) which is used for authentication and
* for retrieving the login name in its proper case.
*
* @since 1.1.0
* <br><br>
* @version 1.1.0
* <br><br>
* @author <a href="mailto:sahan@lonepulse.com">Lahiru Sahan Jayasinghe</a>
*/
public class GitHubUser implements Serializable {


private static final long serialVersionUID = 5687172223807519601L;

/**
* <p>Identifies this GitHub user uniquely.
*/
private String id;

/**
* <p>The login name of this GitHub user <b>in its proper case</b>.
*/
private String login;

/**
* <p>A message which describes an API request failure.
*/
private String message;


/**
* <p>Accessor for id.
*
* @return the id
*/
public String getId() {
return id;
}
/**
* <p>Mutator for id.
*
* @param id
* the id to set
*/
public void setId(String id) {
this.id = id;
}
/**
* <p>Accessor for login.
*
* @return the login
*/
public String getLogin() {
return login;
}
/**
* <p>Mutator for login.
*
* @param login
* the login to set
*/
public void setLogin(String login) {
this.login = login;
}
/**
* <p>Accessor for message.
*
* @return the message
*/
public String getMessage() {
return message;
}
/**
* <p>Mutator for message.
*
* @param message
* the message to set
*/
public void setMessage(String message) {
this.message = message;
}

@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((id == null) ? 0 : id.hashCode());
return result;
}

@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
GitHubUser other = (GitHubUser) obj;
if (id == null) {
if (other.id != null)
return false;
} else if (!id.equals(other.id))
return false;
return true;
}

@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("GitHubUser [id=");
builder.append(id);
builder.append(", login=");
builder.append(login);
builder.append(", message=");
builder.append(message);
builder.append("]");
return builder.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import com.lonepulse.robozombie.core.annotation.Parser;
import com.lonepulse.robozombie.rest.annotation.PathParam;
import com.lonepulse.robozombie.rest.annotation.Rest;
import com.lonepulse.travisjr.model.GitHubRepository;
import com.lonepulse.travisjr.model.GitHubUser;

/**
/**
Expand All @@ -36,6 +38,7 @@
* <br><br>
* @author <a href="mailto:sahan@lonepulse.com">Lahiru Sahan Jayasinghe</a>
*/
@Parser(Parser.PARSER_TYPE.JSON)
@Endpoint(scheme = "https", value = "api.github.com")
public interface GitHubEndpoint {

Expand All @@ -51,8 +54,7 @@ public interface GitHubEndpoint {
* @since 1.1.0
*/
@Rest(path = "/users/:user")
@Parser(type = GitHubValidationParser.class)
Boolean isValidUser(@PathParam("user") String user);
GitHubUser getUser(@PathParam("user") String user);

/**
* <p>A simple call to the <i>/users</i> service at <b>api.github.com</b>
Expand All @@ -68,7 +70,6 @@ public interface GitHubEndpoint {
*
* @since 1.1.0
*/
@Rest(path = "/users/:user")
@Parser(type = GitHubValidationParser.class)
Boolean isValidRepository(@PathParam("user") String user, @PathParam("repo") String repo);
@Rest(path = "/repos/:user/:repo")
GitHubRepository getRepository(@PathParam("user") String user, @PathParam("repo") String repo);
}
Loading

0 comments on commit 86cf2fb

Please sign in to comment.