Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/release-15.12' into release-16.02
Browse files Browse the repository at this point in the history
  • Loading branch information
avilcu committed Apr 22, 2016
2 parents 5f145f3 + 93ef169 commit 3b34a06
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
10 changes: 5 additions & 5 deletions sipXconfig/bin/sipxconfig_archive.rb.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
Expand All @@ -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();
}

Expand Down Expand Up @@ -105,8 +104,7 @@ public Response deletePhoneLine(String phoneId, Integer lineId) {
Phone phone = getPhoneByIdOrMac(phoneId);
if (phone != null) {
if (line != null) {
Collection<Line> lines = DataCollectionUtil.removeByPrimaryKey(phone.getLines(), lineId);
phone.setLines((List<Line>) lines);
DataCollectionUtil.removeByPrimaryKey(phone.getLines(), line.getId());
m_phoneContext.storePhone(phone);
return Response.ok().build();
}
Expand Down

0 comments on commit 3b34a06

Please sign in to comment.