Skip to content

Commit

Permalink
Merge branch 'release/3.5.1' into support/3.x
Browse files Browse the repository at this point in the history
* release/3.5.1:
  Updated dependencies for 3.5.1
  TWCCS-602 Switched to weak references for all Project objects to allow garbage collection. #resolve
  Updated version info for 3.5.1
  • Loading branch information
ivan-gomes committed Sep 4, 2018
2 parents 2ecf3ee + 888a8fe commit ad0277a
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 18 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ dependencies {
// Other dependencies we're unable to resolve via standard repositories

if (buildAccess == 'internal') {
preCompile group: 'gov.nasa.jpl.cae.magicdraw', name: 'cae-magicdraw-core', version: '3.5.0', ext: 'zip'
preCompile group: 'gov.nasa.jpl.cae.magicdraw', name: 'cae-magicdraw-core', version: '3.5.1', ext: 'zip'
}
else {
preCompile group: 'com.nomagic', name: 'magicdraw', version: '185sp3', classifier: 'MagicDraw_185_sp3_no_install', ext: 'zip'
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version=3.5.0
version=3.5.1
group=org.openmbee.magicdraw.mdk
descriptorFile=MDR_Plugin_Model_Development_Kit_91110_descriptor.xml
magicdDrawGroupName=gov.nasa.jpl.cae.magicdraw.mdk
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@
import gov.nasa.jpl.mbee.mdk.util.TicketUtils;

import javax.annotation.CheckForNull;
import java.util.Collections;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.WeakHashMap;

/**
* Created by igomes on 6/22/16.
*/
public class CoordinatedSyncProjectEventListenerAdapter extends ProjectEventListenerAdapter implements SaveParticipant {
private static final Map<Project, CoordinatedSyncProjectMapping> projectMappings = new ConcurrentHashMap<>();
private static final Map<Project, CoordinatedSyncProjectMapping> projectMappings = Collections.synchronizedMap(new WeakHashMap<>());
private DeltaSyncRunner deltaSyncRunner;

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
import com.nomagic.magicdraw.core.project.ProjectEventListenerAdapter;
import com.nomagic.magicdraw.uml.transaction.MDTransactionManager;

import java.util.Collections;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.WeakHashMap;

/**
* Created by igomes on 6/28/16.
*/
public class LocalDeltaProjectEventListenerAdapter extends ProjectEventListenerAdapter {
private static final Map<Project, LocalSyncProjectMapping> projectMappings = new ConcurrentHashMap<>();
private static final Map<Project, LocalSyncProjectMapping> projectMappings = Collections.synchronizedMap(new WeakHashMap<>());

@Override
public void projectCreated(Project project) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,12 @@
import java.net.URISyntaxException;
import java.text.NumberFormat;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;

public class MMSDeltaProjectEventListenerAdapter extends ProjectEventListenerAdapter {
private static final Map<Project, MMSDeltaProjectMapping> projectMappings = new ConcurrentHashMap<>();
private static final Map<Project, MMSDeltaProjectMapping> projectMappings = Collections.synchronizedMap(new WeakHashMap<>());

@Override
public void projectOpened(Project project) {
Expand Down
22 changes: 12 additions & 10 deletions src/main/java/gov/nasa/jpl/mbee/mdk/util/TicketUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
import java.awt.event.HierarchyListener;
import java.io.IOException;
import java.net.URISyntaxException;
import java.util.HashMap;
import java.util.Collections;
import java.util.Map;
import java.util.WeakHashMap;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;

Expand All @@ -28,7 +30,7 @@ public class TicketUtils {
private static String username = "";
private static String password = "";
private static final int TICKET_RENEWAL_INTERVAL = 15 * 60; //seconds
private static final HashMap<Project, TicketMapping> ticketMappings = new HashMap<>();
private static final Map<Project, TicketMapping> ticketMappings = Collections.synchronizedMap(new WeakHashMap<>());

/**
* Accessor for stored username.
Expand All @@ -46,16 +48,15 @@ public static String getUsername(Project project) {
* @return ticket exists and is non-empty.
*/
public static boolean isTicketSet(Project project) {
TicketMapping ticketMap = ticketMappings.get(project);
return ticketMap != null && ticketMap.getTicket() != null && !ticketMap.getTicket().isEmpty();
String ticket = getTicket(project);
return ticket != null && !ticket.isEmpty();
}

public static boolean isTicketValid(Project project, ProgressStatus progressStatus) throws ServerException, IOException, URISyntaxException {
if (!isTicketSet(project)) {
return false;
}
String ticket = ticketMappings.get(project).getTicket();
return MMSUtils.validateCredentialsTicket(project, ticket, progressStatus).equals(username);
return MMSUtils.validateCredentialsTicket(project, getTicket(project), progressStatus).equals(username);
}

/**
Expand All @@ -64,10 +65,11 @@ public static boolean isTicketValid(Project project, ProgressStatus progressStat
* @return ticket string
*/
public static String getTicket(Project project) {
if (isTicketSet(project)) {
return ticketMappings.get(project).getTicket();
TicketMapping ticketMapping = ticketMappings.get(project);
if (ticketMapping == null) {
return null;
}
return null;
return ticketMapping.getTicket();
}

/**
Expand Down Expand Up @@ -254,7 +256,7 @@ private static boolean acquireTicket(Project project, String pass) {

// parse response
password = "";
if (ticketMappings.get(project) != null && !ticketMappings.get(project).getTicket().isEmpty()) {
if (isTicketSet(project)) {
return true;
}
Application.getInstance().getGUILog().log("[ERROR] Unable to log in to MMS with the supplied credentials.");
Expand Down

0 comments on commit ad0277a

Please sign in to comment.