diff --git a/sipXconfig/bin/sipxconfig_archive.rb.in b/sipXconfig/bin/sipxconfig_archive.rb.in index 8d64c4aa41..a2980254f0 100644 --- a/sipXconfig/bin/sipxconfig_archive.rb.in +++ b/sipXconfig/bin/sipxconfig_archive.rb.in @@ -131,7 +131,7 @@ class Restore < ArchiveBase v = File.read("#{@tmpdir}/version").split(".") dev = (v[0].to_i == '0'.to_i and v[1].to_i == '0'.to_i) pre_mongo = !(dev or (v[0].to_i == '4'.to_i and v[1].to_i > '4'.to_i) or v[0].to_i > '4'.to_i or v[0].to_i >= '14'.to_i) - pre_elasticsearch = !(dev or (v[0].to_i >= '15'.to_i and v[1].to_i >= '10'.to_i)) + pre_elasticsearch = !(dev or (v[0].to_i >= '15'.to_i and v[1].to_i >= '10'.to_i) or (v[0].to_i >= '16'.to_i)) else raise "Not a known archive, version file is missing." end @@ -179,13 +179,13 @@ class Restore < ArchiveBase elasticsearch_started = cmd "service elasticsearch status" if (!pre_elasticsearch and elasticsearch_started) cmd "tar -zxvf #{params[:file]} -C / elasticsearch_backup" or - raise "Failed to extract elasticsearch backup from archive" + cmd "echo Failed to extract elasticsearch backup from archive" cmd "curl -XPUT 'http://localhost:9200/_snapshot/sipXcom_backup?wait_for_completion=true' -d '{ \"type\": \"fs\", \"settings\": { \"location\": \"#{@tmpdir}/elasticsearch_backup/\", \"compress\": true }}'" or - raise "Could not create elasticsearch snapshot repository" + cmd "echo Could not create elasticsearch snapshot repository" cmd "curl -XDELETE 'http://localhost:9200/audit?wait_for_completion=true'" or - raise "Failed to remove old audit index" + cmd "echo Failed to remove old audit index" cmd "curl -XPOST 'http://localhost:9200/_snapshot/sipXcom_backup/elasticsearch_backup/_restore?wait_for_completion=true'" or - raise "Failed to restore elasticsearch snapshot" + cmd "echo Failed to restore elasticsearch snapshot" end if params.has_key?(:reset_password) diff --git a/sipXconfig/neoconf/src/org/sipfoundry/sipxconfig/api/impl/PhoneLineApiImpl.java b/sipXconfig/neoconf/src/org/sipfoundry/sipxconfig/api/impl/PhoneLineApiImpl.java index bb21594f93..55a7aae30f 100644 --- a/sipXconfig/neoconf/src/org/sipfoundry/sipxconfig/api/impl/PhoneLineApiImpl.java +++ b/sipXconfig/neoconf/src/org/sipfoundry/sipxconfig/api/impl/PhoneLineApiImpl.java @@ -14,8 +14,7 @@ */ package org.sipfoundry.sipxconfig.api.impl; -import java.util.Collection; -import java.util.List; +import java.util.Collections; import javax.servlet.http.HttpServletRequest; import javax.ws.rs.core.Response; @@ -58,14 +57,14 @@ public Response newLine(String phoneId, LineBean lineBean) { if (phone == null) { return Response.status(Status.NOT_FOUND).entity(PHONE_NOT_FOUND).build(); } - Line line = phone.createLine(); if (lineBean.getUser() != null) { User user = m_coreContext.loadUserByUserNameOrAlias(lineBean.getUser()); if (user == null) { return Response.status(Status.NOT_FOUND).entity("User not found").build(); } - line.setUser(user); + m_phoneContext.addUsersToPhone(phone.getId(), Collections.singleton(user.getId())); } else { + Line line = phone.createLine(); LineInfo lineInfo = new LineInfo(); lineInfo.setUserId(lineBean.getUserId()); lineInfo.setDisplayName(lineBean.getDisplayName()); @@ -75,9 +74,9 @@ public Response newLine(String phoneId, LineBean lineBean) { lineInfo.setRegistrationServerPort(lineBean.getRegistrationServerPort()); lineInfo.setVoiceMail(lineBean.getVoicemail()); line.setLineInfo(lineInfo); + phone.addLine(line); + m_phoneContext.storePhone(phone); } - phone.addLine(line); - m_phoneContext.storePhone(phone); return Response.ok().build(); } @@ -105,8 +104,7 @@ public Response deletePhoneLine(String phoneId, Integer lineId) { Phone phone = getPhoneByIdOrMac(phoneId); if (phone != null) { if (line != null) { - Collection lines = DataCollectionUtil.removeByPrimaryKey(phone.getLines(), lineId); - phone.setLines((List) lines); + DataCollectionUtil.removeByPrimaryKey(phone.getLines(), line.getId()); m_phoneContext.storePhone(phone); return Response.ok().build(); }