Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…or-java-pr into dev
  • Loading branch information
Albert Cheng committed Jun 25, 2013
2 parents 2f76b2d + 9fd2c2b commit 3413c7d
Show file tree
Hide file tree
Showing 15 changed files with 674 additions and 64 deletions.
8 changes: 5 additions & 3 deletions microsoft-azure-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.8.0</version>
<version>0.8.3</version>
<executions>
<execution>
<phase>generate-sources</phase>
Expand All @@ -154,16 +154,18 @@
</executions>
<configuration>
<extension>true</extension>
<debug>true</debug>
<verbose>true</verbose>
<plugins>
<plugin>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics</artifactId>
<version>0.6.0</version>
<version>0.6.4</version>
</plugin>
<plugin>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics-annotate</artifactId>
<version>0.6.0</version>
<version>0.6.4</version>
</plugin>
</plugins>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,13 @@ ReceiveSubscriptionMessageResult receiveSubscriptionMessage(String topicPath, St
/**
* Creates a queue.
*
* @param queue
* A <code>Queue</code> object that represents the queue to create.
* @param queueInfo
* A <code>QueueInfo</code> object that represents the queue to create.
* @return A <code>CreateQueueResult</code> object that represents the result.
* @throws ServiceException
* If a service exception is encountered.
*/
CreateQueueResult createQueue(QueueInfo queue) throws ServiceException;
CreateQueueResult createQueue(QueueInfo queueInfo) throws ServiceException;

/**
* Deletes a queue.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
* Copyright Microsoft Corporation
*
* 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
* 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.
* 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 com.microsoft.windowsazure.services.serviceBus.implementation;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,9 +267,13 @@ public void deleteMessage(BrokeredMessage message) throws ServiceException {
}

@Override
public CreateQueueResult createQueue(QueueInfo entry) throws ServiceException {
return new CreateQueueResult(getResource().path(entry.getPath())
.type("application/atom+xml;type=entry;charset=utf-8").put(QueueInfo.class, entry));
public CreateQueueResult createQueue(QueueInfo queueInfo) throws ServiceException {
Builder webResourceBuilder = getResource().path(queueInfo.getPath()).type(
"application/atom+xml;type=entry;charset=utf-8");
if ((queueInfo.getForwardTo() != null) && !queueInfo.getForwardTo().isEmpty()) {
webResourceBuilder.header("ServiceBusSupplementaryAuthorization", queueInfo.getForwardTo());
}
return new CreateQueueResult(webResourceBuilder.put(QueueInfo.class, queueInfo));
}

@Override
Expand All @@ -296,8 +300,12 @@ public ListQueuesResult listQueues(ListQueuesOptions options) throws ServiceExce

@Override
public QueueInfo updateQueue(QueueInfo queueInfo) throws ServiceException {
return getResource().path(queueInfo.getPath()).type("application/atom+xml;type=entry;charset=utf-8")
.header("If-Match", "*").put(QueueInfo.class, queueInfo);
Builder webResourceBuilder = getResource().path(queueInfo.getPath())
.type("application/atom+xml;type=entry;charset=utf-8").header("If-Match", "*");
if ((queueInfo.getForwardTo() != null) && !queueInfo.getForwardTo().isEmpty()) {
webResourceBuilder.header("ServiceBusSupplementaryAuthorization", queueInfo.getForwardTo());
}
return webResourceBuilder.put(QueueInfo.class, queueInfo);
}

private WebResource listOptions(AbstractListOptions<?> options, WebResource path) {
Expand All @@ -307,6 +315,9 @@ private WebResource listOptions(AbstractListOptions<?> options, WebResource path
if (options.getSkip() != null) {
path = path.queryParam("$skip", options.getSkip().toString());
}
if (options.getFilter() != null) {
path = path.queryParam("$filter", options.getFilter());
}
return path;
}

Expand Down Expand Up @@ -345,10 +356,14 @@ public TopicInfo updateTopic(TopicInfo topicInfo) throws ServiceException {
}

@Override
public CreateSubscriptionResult createSubscription(String topicPath, SubscriptionInfo subscription) {
return new CreateSubscriptionResult(getResource().path(topicPath).path("subscriptions")
.path(subscription.getName()).type("application/atom+xml;type=entry;charset=utf-8")
.put(SubscriptionInfo.class, subscription));
public CreateSubscriptionResult createSubscription(String topicPath, SubscriptionInfo subscriptionInfo) {
Builder webResourceBuilder = getResource().path(topicPath).path("subscriptions")
.path(subscriptionInfo.getName()).type("application/atom+xml;type=entry;charset=utf-8");
if ((subscriptionInfo.getForwardTo() != null) && (!subscriptionInfo.getForwardTo().isEmpty())) {
webResourceBuilder.header("ServiceBusSupplementaryAuthorization", subscriptionInfo.getForwardTo());

}
return new CreateSubscriptionResult(webResourceBuilder.put(SubscriptionInfo.class, subscriptionInfo));
}

@Override
Expand Down Expand Up @@ -377,9 +392,13 @@ public ListSubscriptionsResult listSubscriptions(String topicPath, ListSubscript
@Override
public SubscriptionInfo updateSubscription(String topicName, SubscriptionInfo subscriptionInfo)
throws ServiceException {
return getResource().path(topicName).path("subscriptions").path(subscriptionInfo.getName())
.type("application/atom+xml;type=entry;charset=utf-8").header("If-Match", "*")
.put(SubscriptionInfo.class, subscriptionInfo);
Builder webResourceBuilder = getResource().path(topicName).path("subscriptions")
.path(subscriptionInfo.getName()).type("application/atom+xml;type=entry;charset=utf-8")
.header("If-Match", "*");
if ((subscriptionInfo.getForwardTo() != null) && !subscriptionInfo.getForwardTo().isEmpty()) {
webResourceBuilder.header("ServiceBusSupplementaryAuthorization", subscriptionInfo.getForwardTo());
}
return webResourceBuilder.put(SubscriptionInfo.class, subscriptionInfo);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@
* Copyright Microsoft Corporation
*
* 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
* 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.
* 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 com.microsoft.windowsazure.services.serviceBus.implementation;

import java.net.URI;
import java.net.URISyntaxException;

import com.microsoft.windowsazure.services.core.ServiceException;
Expand All @@ -31,10 +32,23 @@ public WrapFilter(WrapTokenManager tokenManager) {

@Override
public ClientResponse handle(ClientRequest cr) throws ClientHandlerException {
String accessToken = getWrapToken(cr.getURI());
cr.getHeaders().add("Authorization", accessToken);

String accessToken;
String secondaryAuthorizationUri = (String) cr.getHeaders().getFirst("ServiceBusSupplementaryAuthorization");
if ((secondaryAuthorizationUri != null) && (!secondaryAuthorizationUri.isEmpty())) {
String secondaryAccessToken = getWrapToken(URI.create(secondaryAuthorizationUri));
cr.getHeaders().remove("ServiceBusSupplementaryAuthorization");
cr.getHeaders().add("ServiceBusSupplementaryAuthorization", secondaryAccessToken);
}

return this.getNext().handle(cr);
}

private String getWrapToken(URI uri) {
String result;
try {
accessToken = tokenManager.getAccessToken(cr.getURI());
result = tokenManager.getAccessToken(uri);
}
catch (ServiceException e) {
// must wrap exception because of base class signature
Expand All @@ -45,8 +59,6 @@ public ClientResponse handle(ClientRequest cr) throws ClientHandlerException {
throw new ClientHandlerException(e);
}

cr.getHeaders().add("Authorization", "WRAP access_token=\"" + accessToken + "\"");

return this.getNext().handle(cr);
return "WRAP access_token=\"" + result + "\"";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,22 @@
* Copyright Microsoft Corporation
*
* 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
* 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.
* 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 com.microsoft.windowsazure.services.serviceBus.models;

public abstract class AbstractListOptions<T> {
Integer skip;
Integer top;
String filter;

public Integer getSkip() {
return skip;
Expand All @@ -37,4 +38,13 @@ public T setTop(Integer top) {
this.top = top;
return (T) this;
}

public String getFilter() {
return filter;
}

public T setFilter(String filter) {
this.filter = filter;
return (T) this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*/
package com.microsoft.windowsazure.services.serviceBus.models;

import java.net.URI;
import java.util.Calendar;

import javax.ws.rs.core.MediaType;
Expand All @@ -24,6 +25,7 @@
import com.microsoft.windowsazure.services.serviceBus.implementation.EntityStatus;
import com.microsoft.windowsazure.services.serviceBus.implementation.Entry;
import com.microsoft.windowsazure.services.serviceBus.implementation.EntryModel;
import com.microsoft.windowsazure.services.serviceBus.implementation.MessageCountDetails;
import com.microsoft.windowsazure.services.serviceBus.implementation.PartitioningPolicy;
import com.microsoft.windowsazure.services.serviceBus.implementation.QueueDescription;

Expand Down Expand Up @@ -538,4 +540,68 @@ public QueueInfo setUserMetadata(String userMetadata) {
getModel().setUserMetadata(userMetadata);
return this;
}

/**
* Gets the message count details.
*
* @return A <code>MessageCountDetails</code> instance that represents the details of the message count.
*/
public MessageCountDetails getCountDetails() {
return getModel().getCountDetails();
}

/**
* Sets the URI of the <code>QueueInfo</code> instance.
*
* @param uri
* the URI of the <code>QueueInfo</code>
*
* @return A <code>QueueInfo</code> object that represents the updated queue.
*/
public QueueInfo setUri(URI uri) {
getEntry().setId(uri.toString());
return this;
}

/**
* Gets the URI of the <code>QueueInfo</code> instance.
*
* @return A <code>URI</code> representing the <code>QueueInfo</code>.
*/
public URI getUri() {
return URI.create(removeQueryString(getEntry().getId()));
}

/**
* Removes the query string of the URI.
*
* @param uri
* A raw string representing the URI of queue.
* @return the string
*/
private String removeQueryString(String uri) {
String[] result = uri.split("\\?");
return result[0];
}

/**
* Sets the URI of the entity to forward to.
*
* @param forwardTo
* A <code>String</code> instance representing the URI of the entity to forward message to.
* @return A <code>QueueInfo</code> instance representing the updated queue information.
*/
public QueueInfo setForwardTo(String forwardTo) {
getModel().setForwardTo(forwardTo);
return this;
}

/**
* Gets a <code>String</code> instance representing entity to forward to.
*
* @return A <code>String</code> instance representing the URI of the instance to forward to.
*/
public String getForwardTo() {
return getModel().getForwardTo();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.microsoft.windowsazure.services.serviceBus.implementation.EntityStatus;
import com.microsoft.windowsazure.services.serviceBus.implementation.Entry;
import com.microsoft.windowsazure.services.serviceBus.implementation.EntryModel;
import com.microsoft.windowsazure.services.serviceBus.implementation.MessageCountDetails;
import com.microsoft.windowsazure.services.serviceBus.implementation.RuleDescription;
import com.microsoft.windowsazure.services.serviceBus.implementation.SubscriptionDescription;

Expand Down Expand Up @@ -430,4 +431,34 @@ public EntityAvailabilityStatus getEntityAvailabilityStatus() {
return getModel().getEntityAvailabilityStatus();
}

/**
* Gets the message count details.
*
* @return A <code>MessageCountDetails</code> instance representing the details of the message count.
*/
public MessageCountDetails getCountDetails() {
return getModel().getCountDetails();
}

/**
* Sets the forward to.
*
* @param forwardTo
* A <code>String</code> representing the string to forward to.
* @return the subscription info
*/
public SubscriptionInfo setForwardTo(String forwardTo) {
getModel().setForwardTo(forwardTo);
return this;
}

/**
* Gets a <code>String</code> representing the URI of the entity to forward to.
*
* @return A <code>String</code> representing the URI of the entity to forward to.
*/
public String getForwardTo() {
return getModel().getForwardTo();
}

}
Loading

0 comments on commit 3413c7d

Please sign in to comment.