Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added various OpenACD REST APIs and a few SipXecs user and permission APIs #6

Open
wants to merge 99 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
99 commits
Select commit Hold shift + click to select a range
fb3de1f
Added OpenACD Groups REST service that allows GET, includes sorting a…
danchang Mar 13, 2012
a2d9c9a
Add GET, PUT, DELETE to retrieve, update and delete single OpenACD gr…
danchang Mar 15, 2012
294845e
Added OpenACD Skills REST API, cleaned up formatting in other OpenACD…
danchang Mar 16, 2012
58ae0c7
Removed incomplete and accidentally pushed REST api file (was suppose…
danchang Mar 16, 2012
12fc6be
Correct syntax error
danchang Mar 16, 2012
b091c26
Added OpenACD Skill Groups REST API, some other cleanup
danchang Mar 16, 2012
38c2d8b
Add Skills Group REST API, also do some cleanup and bug fix
danchang Mar 20, 2012
84a5c86
Minor code format corrections
danchang Mar 20, 2012
372cfa3
Correct update of existing Agent Group to replace skills, not just ad…
danchang Mar 20, 2012
61596e7
Move code around for better organization and consistency with other R…
danchang Mar 20, 2012
2031327
Add OpenACD Clients REST API
danchang Mar 20, 2012
da816d6
Add OpenACD Client REST API
danchang Mar 20, 2012
126a55a
Change order of fields in Client RestInfo
danchang Mar 20, 2012
102803e
Add OpenACD Queue Groups REST API
danchang Mar 20, 2012
7b838b2
Add OpenACD Queue Group REST API
danchang Mar 20, 2012
bec0b68
Change order of fields in Client REST Info
danchang Mar 20, 2012
b6ab4a8
Include list of Queues with "Skills" list
danchang Mar 21, 2012
04e5307
Merge two functions to improve code structure
danchang Mar 21, 2012
ee8a536
Add Agent Groups to list of "Skills"
danchang Mar 22, 2012
04752b7
Code cleanup
danchang Mar 22, 2012
ec048ef
Add OpenACD Release Codes API
danchang Mar 23, 2012
cb64530
Add OpenACD Release Codes REST API
danchang Mar 23, 2012
4a3049c
Remove extra resource definitions
danchang Mar 23, 2012
a92f0f4
Add OpenACD Queues REST API
danchang Mar 25, 2012
e9ee71e
Add OpenACD Queues REST API
danchang Mar 25, 2012
43f23b3
Add response data for create, update, delete, errors
danchang Mar 25, 2012
72345f9
Add response values for create, update, delete
danchang Mar 25, 2012
ac2feba
Refactor response values for create, update, delete
danchang Mar 25, 2012
b263e82
Add success or error status to response codes
danchang Mar 25, 2012
c1c7212
Extract RestInfo objects into OpenAcdUtilities for reuse among APIs
danchang Mar 25, 2012
ab59586
Add Lines of GET
danchang Mar 27, 2012
fe59471
Finish responses for errors
danchang Mar 27, 2012
055eab7
Implement Response data for updates, deletes. Refactor some objects …
danchang Mar 28, 2012
c3c07fe
Cleanup
danchang Mar 28, 2012
eb5b7c2
Add OpenACD Agent REST API
danchang Mar 29, 2012
8020029
Add saving of OpenACD agent password as pinToken
danchang Mar 29, 2012
15790e1
Add tracking of Client in "skills"
danchang Mar 29, 2012
ca93ec4
Correct password update to ignore if password empty
danchang Mar 29, 2012
6673796
Add sorting on Atom
danchang Mar 29, 2012
d7e20bd
Add OpenACD Lines REST API
danchang Mar 30, 2012
be647bc
Remove legacy code line
danchang Mar 30, 2012
e03f519
Update Lines to conform with behavior of normal OpenACD objects
danchang Mar 30, 2012
d794cbf
Add validation of submitted REST info for create and update
danchang Apr 1, 2012
be3781a
Add extension and regex support
danchang Apr 1, 2012
e4ac783
Support validation of REST information provided
danchang Apr 2, 2012
5fbd3ba
Implement creation, still needs queue and actions
danchang Apr 2, 2012
e2bba8a
Add Queue, Client, AllowVoicemail and custom actions
danchang Apr 3, 2012
af4c761
Added validation of initial REST info to conform with SipXconfig UI r…
danchang Apr 3, 2012
1e9ca6a
Add OpenACD Settings REST API
danchang Apr 3, 2012
f8037f9
Add AnswerSupervisionType, WelcomeMessage
danchang Apr 4, 2012
171fde7
Add reporting of exception message in some errors
danchang Apr 5, 2012
1d28d6d
Add read of Recipes (Todo: create and update of entire Queue and reci…
danchang Apr 5, 2012
cb3c083
Add more detailed error checking in GET
danchang Apr 6, 2012
fe36adb
Add creation and update of Recipe Step conditions and action
danchang Apr 6, 2012
df131b0
Made representation xml element names consistent
danchang Apr 6, 2012
de45b69
Complete create, update of recipes
danchang Apr 6, 2012
f133a8a
Correct return of error xml on GET
danchang Apr 9, 2012
93dc1d4
Add beginnings of Permissions REST API
danchang Apr 10, 2012
fcdf2c6
Add Recipes to Queue Groups
danchang Apr 10, 2012
b89a00b
Add validation
danchang Apr 10, 2012
6d3cd4c
Add Permissions REST API
danchang Apr 10, 2012
2140102
Change OpenAcdUtilities class to generic RestUtilities
danchang Apr 10, 2012
7e0ee1e
Change OpenAcdUtilities to be generic RestUtilities
danchang Apr 10, 2012
17ac2f4
Clean up sort enum
danchang Apr 10, 2012
f674a68
Add Branch REST API, start User and User Group REST API
danchang Apr 10, 2012
26ea93a
Fix OpenACD settings to only allow update, remove extraneous function…
danchang Apr 12, 2012
d4749c7
Add save of setting
danchang Apr 12, 2012
cd62601
Remove delete permission
danchang Apr 12, 2012
b380b59
Add User Groups REST API
danchang Apr 12, 2012
6674161
Add User Group Permissions REST API
danchang Apr 13, 2012
a2b1124
Add basic input validation
danchang Apr 13, 2012
707b04b
Correct return code for update
danchang Apr 13, 2012
5b065fd
Add validation
danchang Apr 13, 2012
623e332
Correct response value on delete
danchang Apr 13, 2012
d042a6e
Add OpenACD Dial Strings REST API
danchang Apr 13, 2012
38769ef
User Group Permissions development in progress
danchang Apr 13, 2012
dec689a
Finish read in User Group Permissions, need update
danchang Apr 17, 2012
fa3ec46
Remove delete
danchang Apr 17, 2012
9d7bd45
Change REST xml naming of groups for consistency
danchang Apr 17, 2012
6d4eb10
Delete checks for skills pointing to group and fails if any exist
danchang Apr 17, 2012
c0df1fb
Correct naming of REST elements
danchang Apr 17, 2012
69568e0
Add update of Permissions
danchang Apr 17, 2012
5fc7662
Complete update of permissions, change REST element names
danchang Apr 18, 2012
c302f25
Add User Permissions REST API
danchang Apr 19, 2012
e5fd6c0
Finish User Permissions for all users, need filtering by branch, ids
danchang Apr 19, 2012
32ea367
Correct limit on User page size
danchang Apr 19, 2012
c9bf263
Add filter by Branch
danchang Apr 19, 2012
9eb73e4
Add Users REST API, still need aliases and GET single
danchang Apr 20, 2012
e1b5437
Add GET using list of User IDs
danchang Apr 20, 2012
38efb8a
Finish Creation of Dial String
danchang Apr 20, 2012
957d9a9
Correct comments
danchang Apr 20, 2012
74651e8
Add email field
danchang Apr 27, 2012
14fe401
Save phone and fax numbers when creating/updating
danchang May 12, 2012
451db7e
Clean up leftover debug code
danchang May 12, 2012
142de04
Add sorting on various fields
danchang May 16, 2012
7fcee1d
Add sort by numberskills
danchang May 18, 2012
d0c9d96
Correct error in create and update due to bad ValidationInfo checking
danchang May 21, 2012
e1ec77d
Change sort on builtIn to sort on defaultValue
danchang May 21, 2012
113455c
remove "password" field from OpenACDAgent (does not actually exist, w…
danchang May 22, 2012
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

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
/*
*
* OpenAcdSettingsResource.java - A Restlet to read Skill data from OpenACD within SipXecs
* Copyright (C) 2012 PATLive, D. Waseem
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.

* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

package org.sipfoundry.sipxconfig.rest;

import static org.restlet.data.MediaType.APPLICATION_JSON;
import static org.restlet.data.MediaType.TEXT_XML;

import org.restlet.Context;
import org.restlet.data.MediaType;
import org.restlet.data.Request;
import org.restlet.data.Response;
import org.restlet.resource.Representation;
import org.restlet.resource.ResourceException;
import org.restlet.resource.Variant;
import org.sipfoundry.sipxconfig.openacd.OpenAcdContext;
import org.sipfoundry.sipxconfig.openacd.OpenAcdSettings;
import org.springframework.beans.factory.annotation.Required;

import com.thoughtworks.xstream.XStream;

public class OpenAcdSettingsResource extends UserResource {

private OpenAcdContext m_openAcdContext;

@Override
public void init(Context context, Request request, Response response) {
super.init(context, request, response);
getVariants().add(new Variant(TEXT_XML));
getVariants().add(new Variant(APPLICATION_JSON));
}


// Allowed REST operations
// -----------------------

@Override
public boolean allowGet() {
return true;
}

@Override
public boolean allowPut() {
return true;
}


// GET - Retrieve all and single Client
// -----------------------------------

@Override
public Representation represent(Variant variant) throws ResourceException {
// if not single, process request for list
OpenAcdSettings settings = m_openAcdContext.getSettings();
OpenAcdSettingRestInfo settingsRestInfo = new OpenAcdSettingRestInfo(settings);

return new OpenAcdSettingRepresentation(variant.getMediaType(), settingsRestInfo);
}


// PUT - Update single Setting
// ---------------------------

@Override
public void storeRepresentation(Representation entity) throws ResourceException {
// get from request body
OpenAcdSettingRepresentation representation = new OpenAcdSettingRepresentation(entity);
OpenAcdSettingRestInfo settingRestInfo = representation.getObject();
OpenAcdSettings settings;

// assign new setting
try {
settings = m_openAcdContext.getSettings();
updateSettings(settings, settingRestInfo);
m_openAcdContext.saveSettings(settings);
}
catch (Exception exception) {
RestUtilities.setResponseError(getResponse(), RestUtilities.ResponseCode.ERROR_WRITE_FAILED, "Assign Setting failed", exception.getLocalizedMessage());
return;
}

RestUtilities.setResponse(getResponse(), RestUtilities.ResponseCode.SUCCESS_UPDATED, "Assigned Setting", settings.getId());
}


// Helper functions
// ----------------

private void updateSettings(OpenAcdSettings settings, OpenAcdSettingRestInfo settingRestInfo) throws ResourceException {
settings.setSettingValue("openacd-config/log_level", settingRestInfo.getLogLevel());
}


// REST Representations
// --------------------

static class OpenAcdSettingRepresentation extends XStreamRepresentation<OpenAcdSettingRestInfo> {

public OpenAcdSettingRepresentation(MediaType mediaType, OpenAcdSettingRestInfo object) {
super(mediaType, object);
}

public OpenAcdSettingRepresentation(Representation representation) {
super(representation);
}

@Override
protected void configureXStream(XStream xstream) {
xstream.alias("setting", OpenAcdSettingRestInfo.class);
}
}


// REST info objects
// -----------------

static class OpenAcdSettingRestInfo {
private final int m_id;
private final String m_logLevel;

public OpenAcdSettingRestInfo(OpenAcdSettings setting) {
m_id = setting.getId();
m_logLevel = setting.getLogLevel();
}

public int getId() {
return m_id;
}

public String getLogLevel() {
return m_logLevel;
}
}


// Injected objects
// ----------------

@Required
public void setOpenAcdContext(OpenAcdContext openAcdContext) {
m_openAcdContext = openAcdContext;
}
}
Loading