CPD Results

The following document contains the results of PMD's CPD 5.6.1.

Duplications

File Project Line
org/universAAL/middleware/bus/junit/OntTestCase.java universAAL Middleware Bus JUnit 364
org/universAAL/middleware/container/pojo/layers/OntAutoLoader.java universAAL Middleware Container POJORunner 387
	}

	private void TryLoadingOnts(List<Ontology> toBeLoaded, boolean isInMyProject,
			Map<Ontology, OntologyLoaderTask> pendingOnts, List<OntologyLoaderTask> loadingOrder,
			int totalOntologiesFound) {

		// filter the list of onts to those are isInMyProject
		List<Ontology> ontStep = new ArrayList<Ontology>();
		for (Ontology o : toBeLoaded) {
			if (isInMyProy(o) == isInMyProject)
				ontStep.add(o);
		}

		// System.out.println("-- Try loading the following onts: " +
		// ontStep.size());
		// for (Ontology o : ontStep) {
		// System.out.println(" ---- " + o.getInfo().getURI());
		// }

		while (!ontStep.isEmpty()) {
			Ontology next = ontStep.remove(0);
			OntologyLoaderTask otl = pendingOnts.get(next);

			otl.attempt();
			if ((!otl.allImportsRegistered() || otl.errors > 0) && otl.attempts <= totalOntologiesFound * 2) {
				otl.unregister();
				ontStep.add(next);
				continue;
			}
			loadingOrder.add(otl);
		}
	}

	/**
	 * Recovers the serializer.
	 *
	 * @return the serializer.
	 */
	protected MessageContentSerializer getContentserializer() {
		if (contentSerializer == null) {
			contentSerializer = (MessageContentSerializer) mc.getContainer().fetchSharedObject(mc,
					new Object[] { MessageContentSerializer.class.getName() });
			if (contentSerializer == null) {
				System.out.println("ERROR: no serializer found for serializing the ontology");
			}
		}
		return contentSerializer;
	}

	/**
	 * Uses reflection to locate all {@link ModuleActivator}s in the package
	 * org.universAAL.ontology .
	 *
	 * @return all instances of module activators.
	 */
	private List<Ontology> getOntologies() {
		List<Ontology> onts = new ArrayList<Ontology>();

		Reflections reflections = new Reflections("org.universAAL.ontology");

		try {
			Set<?> subTypes = reflections.getSubTypesOf(Class.forName(Ontology.class.getName()));

			for (Object o : subTypes) {
				if (o instanceof Class<?>) {
					try {
						onts.add((Ontology) ((Class<?>) o).newInstance());
					} catch (Exception e) {
						LogUtils.logError(mc, getClass(), "getOntologies",
								new String[] { "could not instantiate: " + ((Class) o).getName() }, e);
					}
				}
			}
		} catch (ClassNotFoundException e) {
			LogUtils.logError(mc, getClass(), "getOntologyModules", new String[] { "Unexpected error" }, e);
		}

		return onts;
	}

	/**
	 * Write to target/ontologies the serializations (in TTL, and OWL) of a
	 * given ontology.
	 *
	 * @param ont
	 *            the ontology to be serialized.
	 * @return true iif the operation was successful.
	 */
	protected boolean generateOntFiles4Ont(Ontology ont) {
		if (!owlDir.exists() && !owlDir.mkdirs()) {
			return false;
		}
		String name = ontFileName(ont);
		File ttlFile = new File(owlDir, name + ".ttl");
		return writeTTL(ont, ttlFile) && transformTTL2OWL(ttlFile, new File(owlDir, name + ".owl"));
	}

	/**
	 * Write to target/ontologies the serializations (in TTL, and OWL) of all
	 * loaded ontologies for the testcase.
	 *
	 * @return true iif the operation was successful
	 */
	protected boolean generateOntFiles4ALL() {
		boolean out = true;
		String[] onts = OntologyManagement.getInstance().getOntoloyURIs();
		for (int i = 0; i < onts.length; i++) {
			Ontology ont = OntologyManagement.getInstance().getOntology(onts[i]);
			if (!generateOntFiles4Ont(ont)) {
				LogUtils.logError(mc, getClass(), "generateOntFiles4All", "Unable to generate file for: " + onts[i]);
				out = false;
			}
		}
		return out;
	}
File Project Line
org/universAAL/middleware/bus/junit/OntTestCase.java universAAL Middleware Bus JUnit 521
org/universAAL/middleware/container/pojo/layers/OntAutoLoader.java universAAL Middleware Container POJORunner 525
		return false;
	}

	/**
	 * Construct an appropriate filename for a given ontology.
	 *
	 * @param ont
	 *            the ontology to generate the filename
	 * @return the file name corresponding to the filename stated in the URI, if
	 *         not possible to determine a random name is given.
	 */
	private String ontFileName(Ontology ont) {
		String name = ont.getInfo().getFilename();
		if (name.endsWith(".owl")) // remove ".owl" at the end
			name = name.substring(0, name.length() - 4);
		if (name == null) {
			LogUtils.logWarn(mc, getClass(), "ontFileName",
					"unable to get Name for: " + ont.getInfo().getURI() + " , generating random name.");
			name = Integer.toHexString(new Random(System.currentTimeMillis()).nextInt());
		}
		return name;
	}

	/**
	 * Serializes and writes a TTL for a given {@link Ontology}.
	 *
	 * @param ont
	 *            The ontology to be serialized.
	 * @param ttlFile
	 *            The target file.
	 * @return true iif the operation was successful.
	 */
	private boolean writeTTL(Ontology ont, File ttlFile) {
		LogUtils.logInfo(mc, getClass(), "writeTTL", "Writing turtle serialization of ontology: "
				+ ont.getInfo().getURI() + "\n\t to: " + ttlFile.getAbsolutePath());
		String serializedOntology = getContentserializer().serialize(ont);
		try {
			BufferedWriter out = new BufferedWriter(new FileWriter(ttlFile, false));
			out.write(serializedOntology);
			out.flush();
			out.close();
			return true;
		} catch (IOException e) {
			LogUtils.logError(mc, getClass(), "writeTTL", new String[] { "Unexpected Error" }, e);
			return false;
		}
	}

	/**
	 * Transform a given TTL file into an OWL file.
	 *
	 * @param ttlFile
	 *            the source file.
	 * @param owlFile
	 *            the target file
	 * @return true iif the operation was successful.
	 */
	private boolean transformTTL2OWL(File ttlFile, File owlFile) {
		LogUtils.logInfo(mc, getClass(), "transformTTL2OWL",
				"Transforming file: " + ttlFile.getAbsolutePath() + "\n\t to: " + owlFile.getAbsolutePath());
		OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
		IRI documentIRI = IRI.create(ttlFile);
		OWLOntology owlOntology;
		try {
			owlOntology = manager.loadOntologyFromOntologyDocument(documentIRI);
			LogUtils.logInfo(mc, getClass(), "transformTTL2OWL", "   Loaded ontology: " + owlOntology);

			OWLOntologyFormat format = manager.getOntologyFormat(owlOntology);

			RDFXMLOntologyFormat rdfxmlFormat = new RDFXMLOntologyFormat();
			if (format.isPrefixOWLOntologyFormat()) {
				rdfxmlFormat.copyPrefixesFrom(format.asPrefixOWLOntologyFormat());
			}
			manager.saveOntology(owlOntology, rdfxmlFormat, IRI.create(owlFile));
			LogUtils.logInfo(mc, getClass(), "transformTTL2OWL",
					"   Saved ontology " + owlOntology + " in file " + owlFile.getAbsolutePath());
		} catch (OWLOntologyCreationException e1) {
			e1.printStackTrace();
			return false;
		} catch (OWLOntologyStorageException e) {
			e.printStackTrace();
			return false;
		}

		return true;
	}
}
File Project Line
org/universAAL/middleware/bus/junit/OntTestCase.java universAAL Middleware Bus JUnit 284
org/universAAL/middleware/container/pojo/layers/OntAutoLoader.java universAAL Middleware Container POJORunner 301
		List<OntologyLoaderTask> loadingOrder = new ArrayList<OntTestCase.OntologyLoaderTask>();
		for (Ontology ont : toBeLoaded) {
			pendingOnts.put(ont, new OntologyLoaderTask(ont));
		}

		// first add all onts that are not from this project
		TryLoadingOnts(toBeLoaded, false, pendingOnts, loadingOrder, totalOntologiesFound);

		// then add all onts that are from this project
		TryLoadingOnts(toBeLoaded, true, pendingOnts, loadingOrder, totalOntologiesFound);

		// while (!toBeLoaded.isEmpty() ) {
		// Ontology next = toBeLoaded.remove(0);
		// OntologyLoaderTask otl = pendingOnts.get(next);
		//
		// otl.attempt();
		// if ((!otl.allImportsRegistered()
		// || otl.errors > 0)
		// && otl.attempts <= totalOntologiesFound*2){
		// otl.unregister();
		// toBeLoaded.add(next);
		// continue;
		// }
		// loadingOrder.add(otl);
		// }

		// Print Summary
		StringBuffer ls = new StringBuffer();
		ls.append("AUTO LOAD RESULT\n");
		ls.append(" Load Order:\n");
		StringBuffer sb = new StringBuffer();
		sb.append(" Ontology problems found in this project:\n");
		StringBuffer sbo = new StringBuffer(" Problems detected in other Ontologies:\n");
		boolean problems = false;
		boolean otherProblems = false;
		boolean fail = false;
		for (OntologyLoaderTask olt : loadingOrder) {
			ls.append(
					"\t" + (isInMyProy(olt.ont) ? "* " : "  ") + olt.ont.getInfo().getURI() + " " + olt.report() + "\n");
			if (isInMyProy(olt.ont)) {
				if (!olt.logEntries.isEmpty()) {
					sb.append("\t" + olt.ont.getInfo().getURI() + "\n");
					problems = true;
					for (LogEntry le : olt.logEntries) {
						sb.append("\t\t" + le.toString().replaceAll("\n", "\n\t\t") + "\n");
						if (le.logLevel >= LogListener.LOG_LEVEL_WARN)
							fail = true;
					}
				}
			} else {
				if (!olt.logEntries.isEmpty()) {
					sbo.append("\t" + olt.ont.getInfo().getURI() + "\n");
					otherProblems = true;
					for (LogEntry le : olt.logEntries) {
						sbo.append("\t\t" + le.toString().replaceAll("\n", "\n\t\t") + "\n");
					}
				}

			}
		}
		LogUtils.logInfo(mc, getClass(), "autoLoadOntologies", ls.toString());
		if (problems) {
//			System.err.println(sb.toString());
			LogUtils.logError(mc, getClass(), "autoLoadOntologies", sb.toString());
		}
		if (otherProblems) {
//			System.out.print(sbo.toString());
			LogUtils.logWarn(mc, getClass(), "autoLoadOntologies", sbo.toString());
		}

		if (problems) {
			if (fail) {
				LogUtils.logError(mc, getClass(), "autoLoadOntologies", "Severe problems found, failing build.");
File Project Line
org/universAAL/middleware/managers/configuration/core/impl/secondaryManagers/SharedObjectConnector.java universAAL Middleware Manager Configuration (Core) 32
org/universAAL/middleware/managers/distributedmw/impl/SharedObjectConnector.java universAAL Middleware Manager Distributed MW (Core) 32
public class SharedObjectConnector implements SharedObjectListener {

	private ModuleContext context;
	private SpaceManager spaceManager;
	private MessageContentSerializer messageContentSerializer;
	private boolean stopping = false;
	private ControlBroker controlBroker;

	public ModuleContext getContext() {
		return context;
	}

	/**
	 * @return the SpaceManager
	 */
	public synchronized final SpaceManager getSpaceManager() {
		while (!stopping && spaceManager == null) {
			try {
				wait();
			} catch (InterruptedException e) {
			}
		}
		return spaceManager;
	}

	/**
	 * @return the controlBroker
	 */
	public synchronized final ControlBroker getControlBroker() {
		while (!stopping && controlBroker == null) {
			try {
				wait();
			} catch (InterruptedException e) {
			}
		}
		return controlBroker;
	}

	/**
	 * @return the messageContentSerializer
	 */
	public synchronized final MessageContentSerializer getMessageContentSerializer() {
		while (!stopping && messageContentSerializer == null) {
			try {
				wait();
			} catch (InterruptedException e) {
			}
		}
		return messageContentSerializer;
	}

	public SharedObjectConnector(ModuleContext mc) {
		context = mc;
		susbcribeFor(SpaceManager.class.getName());
		susbcribeFor(ControlBroker.class.getName());
		susbcribeFor(MessageContentSerializer.class.getName());
	}

	private synchronized void add(Object shr) {
		if (shr instanceof SpaceManager) {
			spaceManager = (SpaceManager) shr;
			notifyAll();
		} else if (shr instanceof ControlBroker) {
			controlBroker = (ControlBroker) shr;
			notifyAll();
		} else if (shr instanceof MessageContentSerializer) {
			messageContentSerializer = (MessageContentSerializer) shr;
			notifyAll();
		}
	}

	private void susbcribeFor(String clazzName) {
		Object[] ref = context.getContainer().fetchSharedObject(context, new Object[] { clazzName }, this);
		if (ref != null && ref.length > 0) {
			add(ref[0]);
		}
	}

	public void sharedObjectAdded(Object sharedObj, Object removeHook) {
		if (!stopping) {
			add(sharedObj);
		}
	}

	public void sharedObjectRemoved(Object removeHook) {
		if (removeHook instanceof SpaceManager) {
			spaceManager = null;
		} else if (removeHook instanceof ControlBroker) {
			controlBroker = null;
		} else if (removeHook instanceof MessageContentSerializer) {
			messageContentSerializer = null;
		}
	}

	public void stop() {
		stopping = true;
	}
}
File Project Line
org/universAAL/middleware/container/JUnit/JUnitModuleContext.java universAAL Middleware Container JUnit 214
org/universAAL/middleware/container/pojo/POJOModuleContext.java universAAL Middleware Container POJORunner 162
	}

	/** {@inheritDoc} */
	public boolean isLogErrorEnabled() {
		return Level.ERROR.isGreaterOrEqual(logger.getEffectiveLevel());
	}

	/** {@inheritDoc} */
	public boolean isLogWarnEnabled() {
		return Level.WARN.isGreaterOrEqual(logger.getEffectiveLevel());
	}

	/** {@inheritDoc} */
	public boolean isLogInfoEnabled() {
		return logger.isInfoEnabled();
	}

	/** {@inheritDoc} */
	public boolean isLogDebugEnabled() {
		return logger.isDebugEnabled();
	}

	/** {@inheritDoc} */
	public boolean isLogTraceEnabled() {
		return logger.isTraceEnabled();
	}

	/** {@inheritDoc} */
	public void registerConfigFile(Object[] configFileParams) {
		configFiles.add((File) configFileParams[0]);
	}

	/** {@inheritDoc} */
	public void setAttribute(String attrName, Object attrValue) {
		attributeMap.put(attrName, attrValue);
	}

	/** {@inheritDoc} */
	public boolean start(ModuleContext requester) {
		if (canBeStarted(requester)) {
			try {
				activator.start(this);
				return true;
			} catch (Exception e) {
				logger.error("Unable to start: "
						+ activator.getClass().getPackage().getName(), e);
			}
		}
		return false;
	}

	/** {@inheritDoc} */
	public boolean stop(ModuleContext requester) {
		if (canBeStopped(requester)) {
			try {
				activator.stop(this);
				return true;
			} catch (Exception e) {
				logger.error("Unable to stop: "
						+ activator.getClass().getPackage().getName(), e);
			}
		}
		return false;
	}

	/** {@inheritDoc} */
	public boolean uninstall(ModuleContext requester) {
		return false;
	}

	/** {@inheritDoc} */
	public Object getProperty(String name) {

		Object value = getAttribute(name);
		if (value != null)
			return value;

		value = System.getProperty(name);
		if (value != null)
			return value;

		value = System.getenv(name);
		if (value != null)
			return value;

		return null;
	}

	/** {@inheritDoc} */
	public Object getProperty(String name, Object def) {
		Object value = getProperty(name);
		if (value == null)
			return def;
		return value;
	}

	public String getManifestEntry(String name) {
		return null;
File Project Line
org/universAAL/middleware/bus/junit/OntTestCase.java universAAL Middleware Bus JUnit 69
org/universAAL/middleware/container/pojo/layers/OntAutoLoader.java universAAL Middleware Container POJORunner 66
	private class LogEntry {
		int logLevel;
		String module;
		String pkg;
		String cls;
		String method;
		Object[] msgPart;
		Throwable t;

		public LogEntry(int logLevel, String module, String pkg, String cls, String method, Object[] msgPart,
				Throwable t) {
			super();
			this.logLevel = logLevel;
			this.module = module;
			this.pkg = pkg;
			this.cls = cls;
			this.method = method;
			this.msgPart = msgPart;
			this.t = t;
		}

		/**
		 * Internal method to create a single String from a list of objects.
		 *
		 * @param msgPart
		 *            The message of this log entry. All elements of this array
		 *            are converted to a string object and concatenated.
		 * @return The String.
		 */
		private String buildMsg(Object[] msgPart) {
			StringBuffer sb = new StringBuffer(256);
			if (msgPart != null)
				for (int i = 0; i < msgPart.length; i++)
					sb.append(msgPart[i]);
			return sb.toString();
		}

		public String toString() {
			StringBuffer sb = new StringBuffer();
			sb.append("[");
			switch (logLevel) {
			case LogListener.LOG_LEVEL_TRACE:
				sb.append("TRACE");
				break;
			case LogListener.LOG_LEVEL_DEBUG:
				sb.append("DEBUG");
				break;
			case LogListener.LOG_LEVEL_INFO:
				sb.append("INFO");
				break;
			case LogListener.LOG_LEVEL_WARN:
				sb.append("WARN");
				break;
			case LogListener.LOG_LEVEL_ERROR:
				sb.append("ERROR");
				break;
			}

			sb.append("] -> ");
			sb.append(buildMsg(msgPart));
			if (t != null) {
				StringWriter sw = new StringWriter();
				PrintWriter pw = new PrintWriter(sw);
				t.printStackTrace(pw);
				sw.toString();
				sb.append("\n" + t.toString() + "\n");
				sb.append(sw.getBuffer());
			}
			return sb.toString();
		}
	}

	private class OntologyLoaderTask implements LogListener {
		Ontology ont;
		int attempts = 0;
		int warnings = 0;
		int errors = 0;
		List<LogEntry> logEntries = new ArrayList<OntTestCase.LogEntry>();
File Project Line
org/universAAL/middleware/bus/junit/OntTestCase.java universAAL Middleware Bus JUnit 203
org/universAAL/middleware/container/pojo/layers/OntAutoLoader.java universAAL Middleware Container POJORunner 196
			((JUnitModuleContext) mc).enableLog();
			// refresh ont instance
			try {
				ont = (Ontology) ont.getClass().newInstance();
			} catch (Exception e) {
				LogUtils.logError(mc, getClass(), "unregister",
						new String[] { "could not instantiate: " + ont.getClass().getName() }, e);
			}
		}

		public void log(int logLevel, String module, String pkg, String cls, String method, Object[] msgPart,
				Throwable t) {
			LogEntry le = new LogEntry(logLevel, module, pkg, cls, method, msgPart, t);
			if (msgPart.length > 0 && !((String) msgPart[0]).contains("Unregistering ontology")
					&& !((String) msgPart[0]).contains("Registering ontology"))
				logEntries.add(le);
			if (logLevel == LOG_LEVEL_ERROR)
				errors++;
			if (logLevel == LOG_LEVEL_WARN)
				warnings++;
		}

		public boolean allImportsRegistered() {
			Object imports = ont.getInfo().getProperty(Ontology.PROP_OWL_IMPORT);
			if (imports == null) {
				return true;
			}
			if (!(imports instanceof List)) {
				List a = new ArrayList();
				a.add(imports);
				imports = a;
			}
			String[] registeredA = OntologyManagement.getInstance().getOntoloyURIs();
			for (int i = 0; i < registeredA.length; i++) {
				((List) imports).remove(new Resource(registeredA[i]));
			}
			return ((List) imports).isEmpty();
		}
File Project Line
org/universAAL/middleware/bus/junit/BusTestCase.java universAAL Middleware Bus JUnit 174
org/universAAL/middleware/container/pojo/dummyManagers/DummyCommunicationModule.java universAAL Middleware Container POJORunner 32
		CommunicationModule com = new CommunicationModule() {
			public void dispose() {
			}

			public String getDescription() {
				return null;
			}

			public String getName() {
				return null;
			}

			public String getProvider() {
				return null;
			}

			public String getVersion() {
				return null;
			}

			public boolean init() {
				return false;
			}

			public void loadConfigurations(Dictionary arg0) {
			}

			public void addMessageListener(MessageListener arg0, String arg1) {
			}

			public MessageListener getListenerByNameAndType(String arg0, Class arg1) {
				return null;
			}

			public boolean hasChannel(String arg0) {
				return true;
			}

			public void messageReceived(ChannelMessage arg0) {
			}

			public void removeMessageListener(MessageListener arg0, String arg1) {
			}

			public void send(ChannelMessage arg0, PeerCard arg1) throws CommunicationModuleException {
			}

			public void send(ChannelMessage arg0, MessageListener arg1, PeerCard arg2)
					throws CommunicationModuleException {
			}

			public void sendAll(ChannelMessage arg0) throws CommunicationModuleException {
			}

			public void sendAll(ChannelMessage arg0, List<PeerCard> arg1) throws CommunicationModuleException {
			}

			public void sendAll(ChannelMessage arg0, MessageListener arg1) throws CommunicationModuleException {
			}

			public void sendAll(ChannelMessage arg0, List<PeerCard> arg1, MessageListener arg2)
					throws CommunicationModuleException {
			}
		};
File Project Line
org/universAAL/middleware/bus/junit/BusTestCase.java universAAL Middleware Bus JUnit 113
org/universAAL/middleware/container/pojo/dummyManagers/DummySpaceManager.java universAAL Middleware Container POJORunner 50
			public void dispose() {
			}

			public boolean init() {
				return false;
			}

			public void loadConfigurations(Dictionary arg0) {
			}

			public void addSpaceListener(SpaceListener arg0) {
			}

			public SpaceDescriptor getSpaceDescriptor() {
				return new SpaceDescriptor() {
					private static final long serialVersionUID = -7504183020450042989L;

					public SpaceCard getSpaceCard() {
						SpaceCard sc = new SpaceCard();
						sc.setSpaceID("TestSpaceID");
						return sc;
					}
				};
			}

			public Set<SpaceCard> getSpaces() {
				return null;
			}

			public Map<String, SpaceDescriptor> getManagedSpaces() {
				return null;
			}

			public MatchingResult getMatchingPeers(Map<String, Serializable> arg0) {
				return null;
			}

			public PeerCard getMyPeerCard() {
				return myCard;
			}

			public Map<String, Serializable> getPeerAttributes(List<String> arg0, PeerCard arg1) {
				return null;
			}

			public Map<String, PeerCard> getPeers() {
				HashMap map = new HashMap();
				map.put(myCard.getPeerID(), myCard);
				return map;
			}

			public void join(SpaceCard arg0) {
			}

			public void leaveSpace(SpaceDescriptor arg0) {
			}

			public void removeSpaceListener(SpaceListener arg0) {
			}
		};
File Project Line
org/universAAL/middleware/managers/configuration/core/impl/LocalConfigurationParameterEditor.java universAAL Middleware Manager Configuration (Core) 37
org/universAAL/middleware/managers/configuration/core/impl/RemoteConfigurationParamaterEditor.java universAAL Middleware Manager Configuration (Core) 41
		super(configurationManagerImpl, uri);
	}

	/** {@ inheritDoc} */
	public Object getDefaultValue() {
		Entity e = getEntity();
		if (e instanceof ConfigurationParameter) {
			return ((ConfigurationParameter) e).getDefaultValue();
		}
		return null;
	}

	/** {@ inheritDoc} */
	public MergedRestriction getType() {
		Entity e = getEntity();
		if (e instanceof ConfigurationParameter) {
			return ((ConfigurationParameter) e).getValueRestriction();
		}
		return null;
	}

	/** {@ inheritDoc} */
	public boolean isDefaultValue() {
		Entity e = getEntity();
		if (e instanceof ConfigurationParameter) {
			Object dVal = ((ConfigurationParameter) e).getDefaultValue();
			return ((ConfigurationParameter) e).getValue().equals(dVal);
		}
		return false;
	}

	/** {@ inheritDoc} */
	public boolean setDefaultValue() {
		Entity e = getEntity();
		if (e instanceof ConfigurationParameter) {
			Object dVal = ((ConfigurationParameter) e).getDefaultValue();
			return setValue((ConfigurationParameter) e, dVal);
		}
		return false;
	}

	/**
	 * @param e
	 * @param dVal
	 * @return
	 */
	boolean setValue(ConfigurationParameter e, Object val) {
		if (e.setValue(val)) {
			e.incrementVersion();
File Project Line
org/universAAL/middleware/service/impl/ServiceStrategy.java universAAL Middleware Service Bus (Core) 751
org/universAAL/middleware/service/impl/ServiceStrategy.java universAAL Middleware Service Bus (Core) 1448
										Object ok = getOutputValue(goods.get(k), af);
										if (oj instanceof AbsLocation)
											if (ok == null)
												points[k]++;
											else {
												float dj = ((AbsLocation) oj)
														.getDistanceTo((AbsLocation) params.get(1));
												float dk = ((AbsLocation) ok)
														.getDistanceTo((AbsLocation) params.get(1));
												if (dj > dk)
													points[k]++;
												else if (dk > dj)
													points[j]++;
											}
										else {
											points[j]++;
											if (!(ok instanceof AbsLocation))
												points[k]++;
										}
									}
								}
								break;
							}
						}
						int ind = 0, min = points[0];
						for (int i = 1; i < size; i++)
							if (points[i] < min) {
								ind = i;
								min = points[i];
							}
						for (int j = 0; j < ind; j++, size--)
File Project Line
org/universAAL/middleware/shell/universAAL/osgi/ConfigPullCommand.java universAAL Middleware Karaf Shell Commands for configuring stuff 42
org/universAAL/middleware/shell/universAAL/osgi/ConfigPushCommand.java universAAL Middleware Karaf Shell Commands for configuring stuff 42
    @Argument(index = 1, name = "path", description = "Local Path to copy the file to", required = true, multiValued = false)
    String path = null;
    
    @Override
    protected Object doExecute() throws Exception {

	List<EntityPattern> pattern = new ArrayList<EntityPattern>();
	// only for File configuration.
	pattern.add(new ConfigurationFileTypePattern());

	if (parameter != null && !parameter.isEmpty()){
	    pattern.add(new IdPattern(parameter));
	}
	else {
	    System.out.println("no parameter selected");
	}
	String locale = "en";
	List<ConfigurableEntityEditor> ents = getConfigurationEditor().getMatchingConfigurationEditors(pattern, new Locale(locale));

	if (ents.size() == 0){
	    System.out.println("No Entity found by the given Id");
	    return null;
	}

	ConfigurationFileEditor selected = null;

	if (ents.size() > 1){
	    //TODO select menu
	}
	else {
	    selected = (ConfigurationFileEditor) ents.get(0);
	}
	
	File dest = new File(path);
File Project Line
ch/ethz/iks/slp/impl/AttributeReply.java universAAL Thirdparty jslp library (Core) 187
ch/ethz/iks/slp/impl/ServiceRegistration.java universAAL Thirdparty jslp library (Core) 231
	List spiList = stringToList(spiStr, ",");
	authBlocks = new AuthenticationBlock[spiList.size()];
	for (int k = 0; k < spiList.size(); k++) {
	    int timestamp = SLPUtils.getTimestamp();

	    String spi = (String) spiList.get(k);
	    byte[] data = getAuthData(spi, timestamp);
	    authBlocks[k] = new AuthenticationBlock(
		    AuthenticationBlock.BSD_DSA, spi, timestamp, data, null);
	}
    }

    /**
     * verify this AttributeReply.
     *
     * @return true if verification suceeds.
     * @throws ServiceLocationException
     *             in case of IO errors.
     */
    boolean verify() throws ServiceLocationException {
	for (int i = 0; i < authBlocks.length; i++) {
	    if (authBlocks[i].verify(getAuthData(authBlocks[i].getSPI(),
		    authBlocks[i].getTimestamp()))) {
		return true;
	    }
	}
	return false;
    }

    /**
     * get the authentication data.
     *
     * @param spiStr
     *            the SPI.
     * @param timestamp
     *            the timestamp.
     * @return the auth data.
     * @throws ServiceLocationException
     *             in case of IO errors.
     */
    private byte[] getAuthData(final String spiStr, final int timestamp)
File Project Line
org/universAAL/middleware/container/pojo/POJOModuleContext.java universAAL Middleware Container POJORunner 137
org/universAAL/middleware/container/osgi/OSGiModuleContext.java universAAL Middleware Container (OSGi) 243
	}

	/** {@inheritDoc} */
	public void logDebug(String tag, String message, Throwable t) {
		logger.debug(tag + ": " + message, t);
	}

	/** {@inheritDoc} */
	public void logError(String tag, String message, Throwable t) {
		logger.error(tag + ": " + message, t);
	}

	/** {@inheritDoc} */
	public void logInfo(String tag, String message, Throwable t) {
		logger.info(tag + ": " + message, t);
	}

	/** {@inheritDoc} */
	public void logWarn(String tag, String message, Throwable t) {
		logger.warn(tag + ": " + message, t);
	}

	/** {@inheritDoc} */
	public void logTrace(String tag, String message, Throwable t) {
		logger.trace(tag + ": " + message, t);
	}

	/** {@inheritDoc} */
	public boolean isLogErrorEnabled() {
File Project Line
org/universAAL/middleware/service/impl/ServiceStrategy.java universAAL Middleware Service Bus (Core) 725
org/universAAL/middleware/service/impl/ServiceStrategy.java universAAL Middleware Service Bus (Core) 1422
										Object ok = getOutputValue(goods.get(k), af);
										if (oj instanceof AbsLocation)
											if (ok == null)
												points[k]++;
											else {
												float dj = ((AbsLocation) oj)
														.getDistanceTo((AbsLocation) params.get(1));
												float dk = ((AbsLocation) ok)
														.getDistanceTo((AbsLocation) params.get(1));
												if (dj < dk)
													points[k]++;
												else if (dk < dj)
													points[j]++;
											}
										else {
											points[j]++;
											if (!(ok instanceof AbsLocation))
												points[k]++;
										}
									}
								}
								break;
							case AggregationFunction.MAX_DISTANCE_TO_REF_LOC:
								for (int j = 0; j < size; j++) {
									Object oj = getOutputValue(goods.get(j), af);
File Project Line
org/universAAL/middleware/service/impl/ServiceStrategy.java universAAL Middleware Service Bus (Core) 1418
org/universAAL/middleware/service/impl/ServiceStrategy.java universAAL Middleware Service Bus (Core) 1444
								case AggregationFunction.MIN_DISTANCE_TO_REF_LOC:
									for (int j = 0; j < size; j++) {
										Object oj = getProfileParameter(matches.get(j), pp[1]);
										for (int k = j + 1; k < size; k++) {
											Object ok = getProfileParameter(matches.get(k), pp[1]);
											if (oj instanceof AbsLocation)
												if (ok == null)
													points[k]++;
												else {
													float dj = ((AbsLocation) oj)
															.getDistanceTo((AbsLocation) params.get(1));
													float dk = ((AbsLocation) ok)
															.getDistanceTo((AbsLocation) params.get(1));
													if (dj < dk)
File Project Line
org/universAAL/middleware/bus/junit/OntTestCase.java universAAL Middleware Bus JUnit 146
org/universAAL/middleware/container/pojo/layers/OntAutoLoader.java universAAL Middleware Container POJORunner 143
		List<LogEntry> logEntries = new ArrayList<OntTestCase.LogEntry>();

		public OntologyLoaderTask(Ontology ont) {
			super();
			this.ont = ont;
		}

		String report() {
			if (warnings == 0 && errors == 0) {
				return "";
			}
			String ret = "(";
			if (warnings > 0) {
				ret += "warnings: " + Integer.toString(warnings) + " ";
			}
			if (errors > 0) {
				ret += "errors: " + Integer.toString(errors) + " ";
			}
			ret += ")";
			return ret;
		}

		void attempt() {
			if (ont.getInfo() != null && OntologyManagement.getInstance().isRegisteredOntology(ont.getInfo().getURI()))
				return;
			attempts++;
File Project Line
org/universAAL/middleware/api/impl/SimplifiedApiService.java universAAL Middleware Service Annotated API (Core) 91
org/universAAL/middleware/api/impl/SimplifiedApiService.java universAAL Middleware Service Annotated API (Core) 143
	public void createInputWrapper(String baseURI, Class<?> clazz, Cardinality card, String[] propertyPaths)
			throws SimplifiedRegistrationException {
		int minCard, maxCard;
		switch (card) {
		case ONE_TO_ONE:
			minCard = maxCard = 1;
			break;
		case MANY_TO_MANY:
			minCard = maxCard = 0;
			break;
		default:
			throw new IllegalArgumentException();
		}
		// this will return uri if this is one of the predefined types
		// otherwise check for MY_URI field
		String myUri = TypeMapper.getDatatypeURI(clazz);
		if (myUri == null || myUri.endsWith("anyURI")) {
			try {
				Object value = clazz.getField("MY_URI").get(null);
				myUri = (String) value;
			} catch (Exception e) {
				e.printStackTrace();
				throw new SimplifiedRegistrationException("Exception during resolving MY_URI field:" + e.getMessage());
			}
		}
File Project Line
org/universAAL/middleware/owl/ExactCardinalityRestriction.java universAAL Middleware Data Representation (Core) 124
org/universAAL/middleware/owl/MaxCardinalityRestriction.java universAAL Middleware Data Representation (Core) 120
			return getValue() == ((List) value).size();
	}

	@Override
	public boolean isDisjointWith(TypeExpression other, HashMap context, int ttl, List<MatchLogEntry> log) {
		ttl = checkTTL(ttl);
		if (!(other instanceof PropertyRestriction))
			return other.isDisjointWith(this, context, ttl, log);

		PropertyRestriction r = (PropertyRestriction) other;
		Object o = getOnProperty();
		if (o == null || !o.equals(r.getOnProperty()))
			return false;

		if (r instanceof MinCardinalityRestriction) {
			if (getValue() < ((MinCardinalityRestriction) r).getValue())
				return true;
		} else if (r instanceof MaxCardinalityRestriction) {
File Project Line
org/universAAL/middleware/service/impl/ServiceStrategy.java universAAL Middleware Service Bus (Core) 721
org/universAAL/middleware/service/impl/ServiceStrategy.java universAAL Middleware Service Bus (Core) 747
							case AggregationFunction.MIN_DISTANCE_TO_REF_LOC:
								for (int j = 0; j < size; j++) {
									Object oj = getOutputValue(goods.get(j), af);
									for (int k = j + 1; k < size; k++) {
										Object ok = getOutputValue(goods.get(k), af);
										if (oj instanceof AbsLocation)
											if (ok == null)
												points[k]++;
											else {
												float dj = ((AbsLocation) oj)
														.getDistanceTo((AbsLocation) params.get(1));
												float dk = ((AbsLocation) ok)
														.getDistanceTo((AbsLocation) params.get(1));
												if (dj < dk)
File Project Line
org/universAAL/middleware/service/owls/profile/NumberOfSamples.java universAAL Middleware Service Bus (Core) 55
org/universAAL/middleware/service/owls/profile/ResponseTimeInMilliseconds.java universAAL Middleware Service Bus (Core) 55
	public int getNumberOfSamples() {
		Object o = props.get(PROP_PARAMETER_VALUE_DATA);
		return (o instanceof Integer) ? ((Integer) o).intValue() : -1;
	}

	/**
	 * This method sets the property of <propURI> with <value>.
	 */
	public boolean setProperty(String propURI, Object value) {
		if (propURI != null && value != null && !props.containsKey(propURI))
			if (propURI.equals(PROP_OWLS_PROFILE_SERVICE_PARAMETER_NAME)) {
				if (value instanceof String) {
					props.put(propURI, value);
					return true;
				}
			} else if (propURI.equals(PROP_OWLS_PROFILE_S_PARAMETER)) {
				if (value instanceof Integer && ((Integer) value).intValue() > -1) {
File Project Line
org/universAAL/middleware/container/JUnit/JUnitContainer.java universAAL Middleware Container JUnit 56
org/universAAL/middleware/container/pojo/POJOContainer.java universAAL Middleware Container POJORunner 81
	}

	/** {@inheritDoc} */
	public Object fetchSharedObject(ModuleContext requester, Object[] fetchParams) {
		return sharedObjectMap.get(fetchParams[0]);
	}

	/** {@inheritDoc} */
	public Object[] fetchSharedObject(ModuleContext requester, Object[] fetchParams, SharedObjectListener listener) {
		synchronized (listeners) {
			listeners.add(listener);
		}
		return new Object[] { fetchSharedObject(requester, fetchParams) };
	}

	/** {@inheritDoc} */
	public void removeSharedObjectListener(SharedObjectListener listener) {
		if (listener != null) {
			synchronized (listeners) {
				listeners.remove(listener);
			}
		}
	}

	/** {@inheritDoc} */
	public ModuleContext installModule(ModuleContext requester, Object[] installParams) {
		// no installing.
		return null;
	}

	/** Register a LogListener */
	public void registerLogListener(LogListener listener) {
File Project Line
org/universAAL/middleware/managers/configuration/core/impl/LocalConfigurationFileEditor.java universAAL Middleware Manager Configuration (Core) 46
org/universAAL/middleware/managers/configuration/core/impl/RemoteConfigurationFileEditor.java universAAL Middleware Manager Configuration (Core) 42
		super(configurationManagerImpl, uri);
	}

	/** {@ inheritDoc} */
	public URL getDefaultFileRef() {
		Entity e = getEntity();
		if (e instanceof ConfigurationFile) {
			try {
				return new URL(((ConfigurationFile) e).getDefaultURL());
			} catch (MalformedURLException e1) {
				e1.printStackTrace();
			}
		}
		return null;
	}

	/** {@ inheritDoc} */
	public String getExtensionfilter() {
		Entity e = getEntity();
		if (e instanceof ConfigurationFile) {
			return ((ConfigurationFile) e).getExtensionFilter();
		}
		return null;
	}

	/** {@ inheritDoc} */
	public boolean isDefaultValue() {
		Entity e = getEntity();
		if (e instanceof ConfigurationFile) {
			ConfigurationFile cf = (ConfigurationFile) e;
File Project Line
org/universAAL/middleware/owl/AllValuesFromRestriction.java universAAL Middleware Data Representation (Core) 144
org/universAAL/middleware/owl/SomeValuesFromRestriction.java universAAL Middleware Data Representation (Core) 112
		return true;
	}

	@Override
	public boolean isDisjointWith(TypeExpression other, HashMap context, int ttl, List<MatchLogEntry> log) {
		ttl = checkTTL(ttl);
		if (!(other instanceof PropertyRestriction))
			return other.isDisjointWith(this, context, ttl, log);

		PropertyRestriction r = (PropertyRestriction) other;
		Object o = getOnProperty();
		if (o == null || !o.equals(r.getOnProperty()))
			return false;

		HashMap cloned = (context == null) ? null : (HashMap) context.clone();

		TypeExpression myValues = (TypeExpression) getProperty(PROP_OWL_ALL_VALUES_FROM);
File Project Line
org/universAAL/middleware/managers/deploy/uapp/model/AalUapp.java universAAL Middleware XSD Schemas 1129
org/universAAL/middleware/managers/deploy/uapp/model/Part.java universAAL Middleware XSD Schemas 333
	public static class ApplicationCapabilities implements Serializable {

		private final static long serialVersionUID = 12343L;
		@XmlElement(required = true)
		protected List<CapabilityType> capability;

		/**
		 * Gets the value of the capability property.
		 *
		 * <p>
		 * This accessor method returns a reference to the live list, not a
		 * snapshot. Therefore any modification you make to the returned list
		 * will be present inside the JAXB object. This is why there is not a
		 * <CODE>set</CODE> method for the capability property.
		 *
		 * <p>
		 * For example, to add a new item, do as follows:
		 *
		 * <pre>
		 * getCapability().add(newItem);
		 * </pre>
		 *
		 *
		 * <p>
		 * Objects of the following type(s) are allowed in the list
		 * {@link CapabilityType }
		 *
		 *
		 */
		public List<CapabilityType> getCapability() {
			if (capability == null) {
				capability = new ArrayList<CapabilityType>();
			}
			return this.capability;
		}

		public boolean isSetCapability() {
			return ((this.capability != null) && (!this.capability.isEmpty()));
		}

		public void unsetCapability() {
			this.capability = null;
		}

	}

	/**
	 * <p>
	 * Java class for anonymous complex type.
	 *
	 * <p>
	 * The following schema fragment specifies the expected content contained
	 * within this class.
	 *
	 * <pre>
	 * &lt;complexType>
	 *   &lt;complexContent>
	 *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
	 *       &lt;sequence>
	 *         &lt;element name="contactPoint" type="{http://www.w3.org/2001/XMLSchema}string"/>
	 *         &lt;element name="remoteManagement" minOccurs="0">
	 *           &lt;complexType>
	 *             &lt;complexContent>
	 *               &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
	 *                 &lt;sequence>
	 *                   &lt;element name="protocols" type="{http://www.w3.org/2001/XMLSchema}string" maxOccurs="unbounded"/>
	 *                   &lt;element name="software" type="{http://www.universaal.org/aal-uapp/v1.0.2}artifactType"/>
	 *                 &lt;/sequence>
	 *               &lt;/restriction>
	 *             &lt;/complexContent>
	 *           &lt;/complexType>
	 *         &lt;/element>
	 *       &lt;/sequence>
	 *     &lt;/restriction>
	 *   &lt;/complexContent>
	 * &lt;/complexType>
	 * </pre>
	 *
	 *
	 */
	@XmlAccessorType(XmlAccessType.FIELD)
	@XmlType(name = "", propOrder = { "contactPoint", "remoteManagement" })
File Project Line
org/universAAL/middleware/owl/AllValuesFromRestriction.java universAAL Middleware Data Representation (Core) 117
org/universAAL/middleware/owl/SomeValuesFromRestriction.java universAAL Middleware Data Representation (Core) 83
		return copyTo(new AllValuesFromRestriction());
	}

	@Override
	public boolean hasMember(Object member, HashMap context, int ttl, List<MatchLogEntry> log) {
		ttl = checkTTL(ttl);
		if (!(member instanceof Resource))
			return member == null;

		Object o = ((Resource) member).getProperty(getOnProperty());
		if (o == null)
			return true;
		if (!(o instanceof List)) {
			List aux = new ArrayList(1);
			aux.add(o);
			o = aux;
		}
		int size = ((List) o).size();
File Project Line
org/universAAL/middleware/connectors/communication/jgroups/JGroupsCommunicationConnector.java universAAL Middleware Connector Communication JGroups (Core) 583
org/universAAL/middleware/connectors/deploy/karaf/KarafDeployConnector.java universAAL Middleware Deploy Connector Karaf (OSGi) 127
					"JGroups Connector properties are null");
			return;
		}
		try {
			this.name = (String) configurations.get(org.universAAL.middleware.connectors.util.Consts.CONNECTOR_NAME);
			this.version = (String) configurations
					.get(org.universAAL.middleware.connectors.util.Consts.CONNECTOR_VERSION);
			this.description = (String) configurations
					.get(org.universAAL.middleware.connectors.util.Consts.CONNECTOR_DESCRIPTION);
			this.provider = (String) configurations
					.get(org.universAAL.middleware.connectors.util.Consts.CONNECTOR_PROVIDER);
File Project Line
org/universAAL/middleware/service/impl/ServiceStrategy.java universAAL Middleware Service Bus (Core) 679
org/universAAL/middleware/service/impl/ServiceStrategy.java universAAL Middleware Service Bus (Core) 1376
										Object ok = getOutputValue(goods.get(k), af);
										if (oj instanceof Comparable)
											if (ok == null)
												points[k]++;
											else {
												int l = ((Comparable) oj).compareTo(ok);
												if (l < 0)
													points[k]++;
												else if (l > 0)
													points[j]++;
											}
										else {
											points[j]++;
											if (!(ok instanceof Comparable))
												points[k]++;
										}
									}
								}
								break;
							case AggregationFunction.MAX_OF:
								for (int j = 0; j < size; j++) {
									Object oj = getOutputValue(goods.get(j), af);
File Project Line
org/universAAL/middleware/service/impl/ServiceStrategy.java universAAL Middleware Service Bus (Core) 702
org/universAAL/middleware/service/impl/ServiceStrategy.java universAAL Middleware Service Bus (Core) 1399
										Object ok = getOutputValue(goods.get(k), af);
										if (oj instanceof Comparable)
											if (ok == null)
												points[k]++;
											else {
												int l = ((Comparable) oj).compareTo(ok);
												if (l > 0)
													points[k]++;
												else if (l < 0)
													points[j]++;
											}
										else {
											points[j]++;
											if (!(ok instanceof Comparable))
												points[k]++;
										}
									}
								}
								break;
							case AggregationFunction.MIN_DISTANCE_TO_REF_LOC:
								for (int j = 0; j < size; j++) {
									Object oj = getOutputValue(goods.get(j), af);
File Project Line
ch/ethz/iks/slp/impl/AttributeReply.java universAAL Thirdparty jslp library (Core) 197
ch/ethz/iks/slp/impl/DAAdvertisement.java universAAL Thirdparty jslp library (Core) 210
    }

    /**
     * verify this AttributeReply.
     *
     * @return true if verification suceeds.
     * @throws ServiceLocationException
     *             in case of IO errors.
     */
    boolean verify() throws ServiceLocationException {
	for (int i = 0; i < authBlocks.length; i++) {
	    if (authBlocks[i].verify(getAuthData(authBlocks[i].getSPI(),
		    authBlocks[i].getTimestamp()))) {
		return true;
	    }
	}
	return false;
    }

    /**
     * get the authentication data.
     *
     * @param spiStr
     *            the SPI.
     * @param timestamp
     *            the timestamp.
     * @return the auth data.
     * @throws ServiceLocationException
     *             in case of IO errors.
     */
    private byte[] getAuthData(final String spiStr, final int timestamp)
	    throws ServiceLocationException {
	try {
	    ByteArrayOutputStream bos = new ByteArrayOutputStream();
	    DataOutputStream dos = new DataOutputStream(bos);
	    dos.writeUTF(spiStr);
	    dos.writeUTF(listToString(attributes, ","));
File Project Line
org/universAAL/middleware/owl/Intersection.java universAAL Middleware Data Representation (Core) 223
org/universAAL/middleware/owl/Union.java universAAL Middleware Data Representation (Core) 209
					Object tmp = TypeURI.asTypeURI(o);
					if (tmp != null)
						o = tmp;
					if (o instanceof TypeExpression)
						retVal = addType((TypeExpression) o) || retVal;
					else {
						types.clear();
						break;
					}
				}
				return retVal;
			} else {
				Object tmp = TypeURI.asTypeURI(o);
				if (tmp != null)
					o = tmp;
				if (o instanceof TypeExpression)
					return addType((TypeExpression) o);
			}
		}
		return false;
	}

	/**
	 * Get an iterator for the child type expressions.
	 *
	 * @return an iterator for the child type expressions.
	 */
	public Iterator<TypeExpression> types() {
		return types.iterator();
	}