Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 160031
Collapse All | Expand All

(-)cbe.import/org/eclipse/tptp/platform/common/internal/repository/TraceModelFactoryImpl.java (-3 / +18 lines)
Lines 20-26 Link Here
20
import org.eclipse.emf.common.util.EList;
20
import org.eclipse.emf.common.util.EList;
21
import org.eclipse.emf.common.util.URI;
21
import org.eclipse.emf.common.util.URI;
22
import org.eclipse.emf.ecore.resource.Resource;
22
import org.eclipse.emf.ecore.resource.Resource;
23
import org.eclipse.emf.ecore.resource.Resource.Factory;
24
import org.eclipse.emf.ecore.util.EcoreUtil;
23
import org.eclipse.emf.ecore.util.EcoreUtil;
25
import org.eclipse.hyades.internal.execution.local.control.Node;
24
import org.eclipse.hyades.internal.execution.local.control.Node;
26
import org.eclipse.hyades.internal.execution.local.control.NodeFactory;
25
import org.eclipse.hyades.internal.execution.local.control.NodeFactory;
Lines 39-45 Link Here
39
38
40
import com.ibm.icu.text.DateFormat;
39
import com.ibm.icu.text.DateFormat;
41
40
42
public class TraceModelFactoryImpl implements ITraceModelFactory {
41
public class TraceModelFactoryImpl implements ITraceModelFactory 
42
{
43
	/**
44
	 * This static counter is used to reduce the chance of agent URIs colliding when
45
	 * multiple agents are created repeatedly
46
	 */
47
	private static int uriCounter = 0; 
48
	
43
	
49
	
44
	public TRCAgentProxy findAgent(TRCProcessProxy process, ILogFileElement logFile, IRepositoryContainer repositoryContainer) {
50
	public TRCAgentProxy findAgent(TRCProcessProxy process, ILogFileElement logFile, IRepositoryContainer repositoryContainer) {
45
		TRCAgentProxy agent = null;
51
		TRCAgentProxy agent = null;
Lines 110-118 Link Here
110
			tempURI = tempURI.appendSegment(segments[x]);
116
			tempURI = tempURI.appendSegment(segments[x]);
111
		}
117
		}
112
		String pPath = tempURI.appendSegment(fileName).toString();
118
		String pPath = tempURI.appendSegment(fileName).toString();
119
		
120
		/* Ali M.: defect 160031 - a static counter is used to reduce the chance of
121
		 * URI colliding */
122
		if (uriCounter >= Integer.MAX_VALUE)
123
			uriCounter = 0;
124
		int counterInx = pPath.lastIndexOf('_');
125
		counterInx = counterInx < 0 ? pPath.lastIndexOf('.') : counterInx;
126
		counterInx = counterInx < 0 ? pPath.length() : counterInx;
127
		pPath = pPath.substring(0, counterInx) + uriCounter++ + pPath.substring(counterInx);
113
128
114
		URI uri = URI.createURI(pPath);
129
		URI uri = URI.createURI(pPath);
115
130
		
116
		Resource agDoc = Resource.Factory.Registry.INSTANCE.getFactory(uri)
131
		Resource agDoc = Resource.Factory.Registry.INSTANCE.getFactory(uri)
117
				.createResource(uri);
132
				.createResource(uri);
118
		agDoc.setModified(true);
133
		agDoc.setModified(true);

Return to bug 160031