Skip to content

Commit

Permalink
Fix dcm4che#1858 : Restful service to update Study Access Control ID
Browse files Browse the repository at this point in the history
  • Loading branch information
vrindanayak committed Feb 27, 2019
1 parent f8cddc5 commit 66fc4b4
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,11 @@
@NamedQuery(
name = Study.SET_STORAGE_IDS,
query = "update Study st set st.storageIDs = ?2 " +
"where st.pk = ?1")
"where st.pk = ?1"),
@NamedQuery(
name = Study.UPDATE_ACCESS_CONTROL_ID,
query = "update Study st set st.accessControlID = ?2 " +
"where st.studyInstanceUID = ?1")
})
@Entity
@Table(name = "study",
Expand Down Expand Up @@ -179,6 +183,7 @@ public class Study {
public static final String FIND_PK_BY_STUDY_UID = "Study.findPkByStudyUID";
public static final String STORAGE_IDS_BY_STUDY_UID = "Study.storageIDsByStudyUID";
public static final String SET_STORAGE_IDS = "Study.setStorageIDs";
public static final String UPDATE_ACCESS_CONTROL_ID = "Study.updateAccessControlID";

public static class PKUID {
public final Long pk;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ public Response updateStudyAccessControlID(
ctx.setStudyInstanceUID(studyUID);
ctx.setAccessControlID("null".equals(accessControlID) ? "*" : accessControlID);
ctx.setEventActionCode(AuditMessages.EventActionCode.Update);
if (!studyService.updateAccessControlID(ctx))
if (studyService.updateAccessControlID(ctx) == 0)
return errResponse("Study not found. " + studyUID, Response.Status.NOT_FOUND);

rsForward.forward(RSOperation.UpdateStudyAccessControlID, arcAE, null, request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,5 @@ public interface StudyService {

void updateExpirationDate(StudyMgtContext ctx) throws Exception;

boolean updateAccessControlID(StudyMgtContext ctx) throws Exception;
int updateAccessControlID(StudyMgtContext ctx) throws Exception;
}
Original file line number Diff line number Diff line change
Expand Up @@ -257,17 +257,11 @@ public void updateExpirationDate(StudyMgtContext ctx) {
updateStudyExpirationDate(ctx);
}

public boolean updateAccessControlID(StudyMgtContext ctx) {
try {
Study study = em.createNamedQuery(Study.FIND_BY_STUDY_IUID, Study.class)
public int updateAccessControlID(StudyMgtContext ctx) {
return em.createNamedQuery(Study.UPDATE_ACCESS_CONTROL_ID)
.setParameter(1, ctx.getStudyInstanceUID())
.getSingleResult();
study.setAccessControlID(ctx.getAccessControlID());
ctx.setStudy(study);
} catch (NoResultException e) {
return false;
}
return true;
.setParameter(2, ctx.getAccessControlID())
.executeUpdate();
}

private void setCodes(Collection<CodeEntity> codes, Sequence seq) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,12 @@ public void updateExpirationDate(StudyMgtContext ctx) {
}

@Override
public boolean updateAccessControlID(StudyMgtContext ctx) {
public int updateAccessControlID(StudyMgtContext ctx) {
try {
return ejb.updateAccessControlID(ctx);
} catch (Exception e) {
ctx.setException(e);
throw e;
} finally {
if (ctx.getStudy() != null)
updateStudyEvent.fire(ctx);
}
}

Expand Down

0 comments on commit 66fc4b4

Please sign in to comment.