Skip to content

Commit

Permalink
Fixes for issue #784
Browse files Browse the repository at this point in the history
  • Loading branch information
gvagenas committed May 27, 2016
1 parent 165a1ba commit a541f62
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
Expand Up @@ -21,6 +21,7 @@

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.sun.jersey.core.util.MultivaluedMapImpl;
import com.thoughtworks.xstream.XStream;

import java.net.URI;
Expand All @@ -44,8 +45,11 @@
import org.apache.shiro.authz.AuthorizationException;
import org.apache.shiro.crypto.hash.Md5Hash;
import org.joda.time.DateTime;
import org.mobicents.servlet.restcomm.dao.ClientsDao;
import org.mobicents.servlet.restcomm.dao.DaoManager;
import org.mobicents.servlet.restcomm.entities.Account;
import org.mobicents.servlet.restcomm.entities.AccountList;
import org.mobicents.servlet.restcomm.entities.Client;
import org.mobicents.servlet.restcomm.entities.RestCommResponse;
import org.mobicents.servlet.restcomm.entities.Sid;
import org.mobicents.servlet.restcomm.http.converter.AccountConverter;
Expand All @@ -62,6 +66,7 @@ public abstract class AccountsEndpoint extends SecuredEndpoint {
protected Configuration configuration;
protected Gson gson;
protected XStream xstream;
protected ClientsDao clientDao;

public AccountsEndpoint() {
super();
Expand All @@ -72,6 +77,7 @@ private void init() {
configuration = (Configuration) context.getAttribute(Configuration.class.getName());
configuration = configuration.subset("runtime-settings");
super.init(configuration);
clientDao = ((DaoManager) context.getAttribute(DaoManager.class.getName())).getClientsDao();
final AccountConverter converter = new AccountConverter(configuration);
final GsonBuilder builder = new GsonBuilder();
builder.registerTypeAdapter(Account.class, converter);
Expand Down Expand Up @@ -184,7 +190,7 @@ protected Response deleteAccount(final String operatedSid) {
accountsDao.removeAccount(sidToBeRemoved);

// Remove its SIP client account
clientDao.removeClients(sidToBeRemoved)
clientDao.removeClients(sidToBeRemoved);

return ok().build();
}
Expand Down Expand Up @@ -359,9 +365,6 @@ protected Response updateAccount(final String accountSid, final MultivaluedMap<S
clientDao.updateClient(client);
}
}
} else {
return status(UNAUTHORIZED).build();
}
} catch (final AuthorizationException exception) {
return status(UNAUTHORIZED).build();
}
Expand Down
@@ -1,14 +1,21 @@
package org.mobicents.servlet.restcomm.http;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;

import java.io.IOException;
import java.net.URL;
import java.text.ParseException;

import com.sun.jersey.api.client.ClientResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.log4j.Logger;
import org.apache.shiro.crypto.hash.Md5Hash;
import org.cafesip.sipunit.SipPhone;
import org.cafesip.sipunit.SipStack;
import org.jboss.arquillian.container.mss.extension.SipStackTool;
import org.jboss.arquillian.container.test.api.Deployer;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
Expand All @@ -19,12 +26,15 @@
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;

import com.google.gson.JsonObject;
import com.sun.jersey.api.client.UniformInterfaceException;

import javax.sip.address.SipURI;

/**
* @author <a href="mailto:gvagenas@gmail.com">gvagenas</a>
* @author <a href="mailto:jean.deruelle@telestax.com">Jean Deruelle</a>
Expand Down

0 comments on commit a541f62

Please sign in to comment.