Example usage for java.util.logging Level FINER

List of usage examples for java.util.logging Level FINER

Introduction

In this page you can find the example usage for java.util.logging Level FINER.

Prototype

Level FINER

To view the source code for java.util.logging Level FINER.

Click Source Link

Document

FINER indicates a fairly detailed tracing message.

Usage

From source file:org.cloudifysource.rest.controllers.DeploymentsController.java

/**
 * Retrieves service level attributes.//from  ww  w .  ja v a 2 s . c o m
 * 
 * @param appName
 *            The application name.
 * @param serviceName
 *            The service name.
 * @return An instance of {@link GetServiceAttributesResponse} containing all the service attributes names and
 *         values.
 * @throws ResourceNotFoundException
 *             Thrown in case the service does not exist.
 */
@RequestMapping(value = "/{appName}/service/{serviceName}/attributes", method = RequestMethod.GET)
public GetServiceAttributesResponse getServiceAttributes(@PathVariable final String appName,
        @PathVariable final String serviceName) throws ResourceNotFoundException {

    // valid exist service
    controllerHelper.getService(appName, serviceName);

    // logger - request to get all attributes
    if (logger.isLoggable(Level.FINER)) {
        logger.finer("received request to get all attributes of service "
                + ServiceUtils.getAbsolutePUName(appName, serviceName) + " of application " + appName);
    }

    // get attributes
    final Map<String, Object> attributes = controllerHelper.getAttributes(appName, serviceName, null);

    // create response object
    final GetServiceAttributesResponse sar = new GetServiceAttributesResponse();
    // set attributes
    sar.setAttributes(attributes);
    // return response object
    return sar;

}

From source file:org.fornax.cartridges.sculptor.smartclient.server.ScServlet.java

private void sendResponse(PrintWriter output, int startRow, int endRow, Collection<? extends Object> inputData)
        throws IllegalArgumentException {
    inputData = inputData == null ? new ArrayList<Object>() : inputData;
    int showEndRow = endRow < 1 ? 0 : endRow - 1;
    log.log(Level.FINE, "Sending JSON response from {0} to {1} of size {2}",
            new Object[] { startRow, showEndRow, inputData.size() });
    output.write("{response: { status:0, startRow:" + startRow + ", endRow:" + showEndRow + ", totalRows:"
            + inputData.size() + ", data:[");

    // If inputData is Set convert to array
    Object[] setData = null;/*w  w w .  j  a  v a  2s  . c o m*/
    if (inputData instanceof Set) {
        setData = inputData.toArray();
    } else if (!(inputData instanceof List)) {
        throw new IllegalArgumentException("Datatype " + inputData.getClass().getName()
                + " is not supported (only implementations of java.util.Set and java.util.List)");
    }
    for (int i = startRow; i < endRow; i++) {
        // Get object from collection
        Object obj;
        if (inputData instanceof Set) {
            obj = setData[i];
        } else {
            obj = ((List<? extends Object>) inputData).get(i);
        }

        // Write out separator except first
        if (i != startRow) {
            output.write(", ");
        }

        // Prepare string representation and write out
        String objString = mapObjToOutput(obj, DEF_DEPTH, new Stack(), false, false);
        log.log(Level.FINER, "    >>>>>>>>>>> {0}", objString);
        output.write(objString);
    }
    output.write(" ] } }");
}

From source file:org.fornax.cartridges.sculptor.smartclient.server.ScServlet.java

private String mapObjToOutput(Object obj, int maxDepth, Stack<Object> serStack, boolean useGwtArray,
        boolean translateValue) {
    if (serStack.size() == 0) {
        log.log(Level.FINER, "Serializing START {0}", obj);
    }/* w w w. j  a v a2  s.  c  om*/

    // Avoid recursion
    if (serStack.size() == maxDepth && !(obj instanceof Date || obj instanceof Number || obj instanceof Boolean
            || obj instanceof CharSequence || obj instanceof Enum)) {
        String objId = getIdFromObj(obj);
        return objId == null ? Q + Q : objId;
    }
    if (serStack.contains(obj)) {
        return getIdFromObj(obj);
        // return Q+"ref: "+obj.getClass().getName()+"@"+obj.hashCode()+Q;
    }
    serStack.push(obj);

    String startArray = useGwtArray ? "$wnd.Array.create([" : "[";
    String endArray = useGwtArray ? "])" : "]";

    StringBuilder recordData = new StringBuilder();
    if (obj == null) {
        recordData.append("null");
    } else if (obj instanceof Map) {
        recordData.append("{");
        Map objMap = (Map) obj;
        String delim = "";
        for (Object objKey : objMap.keySet()) {
            recordData.append(delim).append(objKey).append(":")
                    .append(mapObjToOutput(objMap.get(objKey), maxDepth, serStack, useGwtArray, false));
            delim = " , ";
        }
        recordData.append("}");
    } else if (obj instanceof Collection) {
        recordData.append(startArray);
        Collection objSet = (Collection) obj;
        String delim = "";
        for (Object objVal : objSet) {
            recordData.append(delim).append(mapObjToOutput(objVal, maxDepth, serStack, useGwtArray, false));
            delim = " , ";
        }
        recordData.append(endArray);
    } else if (obj instanceof List) {
        recordData.append(startArray);
        List objList = (List) obj;
        String delim = "";
        for (Object objVal : objList) {
            recordData.append(delim).append(mapObjToOutput(objVal, maxDepth, serStack, useGwtArray, false));
            delim = " , ";
        }
        recordData.append(endArray);
    } else if (obj instanceof Object[]) {
        recordData.append(startArray);
        Object[] objArr = (Object[]) obj;
        String delim = "";
        for (Object objVal : objArr) {
            recordData.append(delim).append(mapObjToOutput(objVal, maxDepth, serStack, useGwtArray, false));
            delim = " , ";
        }
        recordData.append(endArray);
    } else if (obj instanceof Date) {
        Date objDate = (Date) obj;
        // recordData.append(Q+dateTimeFormat.format(objDate)+Q);
        recordData.append("new Date(" + objDate.getTime() + ")");
    } else if (obj instanceof Boolean) {
        recordData.append(obj);
    } else if (obj instanceof Number) {
        recordData.append(obj);
    } else if (obj instanceof CharSequence) {
        String strObj = obj.toString();
        if (strObj.startsWith(Main.JAVASCRIPT_PREFIX) && useGwtArray) {
            recordData.append(" ").append(strObj.substring(Main.JAVASCRIPT_PREFIX.length()));
        } else if (strObj.startsWith("function") && useGwtArray) {
            recordData.append(" ").append(strObj);
        } else {
            strObj = translateValue ? translate(strObj) : strObj;
            String escapeString = strObj.replaceAll("\\\\", "\\\\\\\\").replaceAll("\"", "\\\\\"")
                    .replaceAll("\\r", "\\\\r").replaceAll("\\n", "\\\\n");
            recordData.append(Q + escapeString + Q);
        }
    } else if (obj instanceof Enum) {
        String val = ((Enum) obj).name();
        if (useGwtArray) {
            try {
                Method getValMethod = obj.getClass().getMethod("getValue", (Class[]) null);
                val = (String) getValMethod.invoke(obj, (Object[]) null);
            } catch (Exception e) {
                // no method getValue
            }
        }
        recordData.append(Q + val + Q);
    } else {
        String className = obj.getClass().getName();
        ServiceDescription serviceForClass = findServiceByClassName(className);
        log.log(Level.FINER, "Serializing class {0}", className);
        if (serStack.size() > 2 && serviceForClass != null) {
            recordData.append(getIdFromObj(obj));
        } else {
            // Use reflection
            recordData.append("{");
            String delim = "";
            String jsonPostfix = null;
            Method[] methods = obj.getClass().getMethods();
            for (Method m : methods) {
                boolean translateThisValue = false;
                String mName;
                if (m.getName().startsWith(GET_TRANSLATE)) {
                    translateThisValue = true;
                    mName = m.getName().substring(GET_TRANSLATE_LENGTH);
                } else if (m.getName().startsWith("is")) {
                    mName = m.getName().substring(2);
                } else {
                    mName = m.getName().substring(3);
                }

                if (mName.length() > 1 && Character.isLowerCase(mName.charAt(1))) {
                    mName = mName.substring(0, 1).toLowerCase() + mName.substring(1);
                }

                if (m.getName().startsWith("getJsonPostfix") && m.getParameterTypes().length == 0
                        && String.class.equals(m.getReturnType())) {
                    try {
                        jsonPostfix = (String) m.invoke(obj, new Object[] {});
                    } catch (Throwable e) {
                        log.log(Level.FINE, "Mapping error", e);
                    }
                } else if (!m.getDeclaringClass().getName().startsWith("org.hibernate")
                        && m.getDeclaringClass() != Object.class && m.getDeclaringClass() != Class.class
                        && (m.getName().startsWith("get") || m.getName().startsWith("is"))
                        && m.getParameterTypes().length == 0 && m.getReturnType() != null
                        && !isHiddenField(m.getDeclaringClass().getName(), mName)) {
                    log.log(Level.FINEST, "Reflection invoking name={0} declaringClass={1} on {2}[{3}]",
                            new Object[] { m.getName(), m.getDeclaringClass(), obj, obj.getClass() });
                    try {
                        Object result = m.invoke(obj, new Object[] {});
                        if (result != null) {
                            mName = mName.startsWith("xxx") ? mName.substring(3) : mName;
                            String resultClassName = AopUtils.getTargetClass(result).getName();
                            String idVal = getIdFromObj(result);
                            String valStr;
                            if (findServiceByClassName(resultClassName) != null && idVal != null) {
                                recordData.append(delim).append(mName).append(":").append(idVal);
                                String refField = ds2Ref.get(resultClassName);
                                if (refField != null) {
                                    Object realVal = getValFromObj(refField, result);
                                    valStr = realVal == null ? Q + Q : Q + realVal + Q;
                                } else {
                                    valStr = Q + "UNKNOWN" + Q;
                                }
                                mName = mName + "_VAL";
                                delim = ", ";
                            } else {
                                valStr = mapObjToOutput(result, maxDepth, serStack, useGwtArray,
                                        translateThisValue);
                            }
                            recordData.append(delim).append(mName).append(":").append(valStr);
                            delim = ", ";
                        }
                    } catch (Throwable e) {
                        log.log(Level.FINE, "Mapping error", e);
                    }
                }
            }

            if (jsonPostfix != null) {
                recordData.append(delim).append(jsonPostfix).append("}");
            } else {
                recordData.append("}");
            }
        }
    }
    serStack.pop();
    return recordData.toString();
}

From source file:foodsimulationmodel.pathmapping.Route.java

/**
 * Used to create a new BuildingsOnRoadCache object. This function is used instead of the constructor directly so
 * that the class can check if there is a serialised version on disk already. If not then a new one is created and
 * returned.//from  w  w w. ja v a 2  s  .co m
 * 
 * @param buildingEnv
 * @param buildingsFile
 * @param roadEnv
 * @param roadsFile
 * @param serialisedLoc
 * @param geomFac
 * @return
 * @throws Exception
 */
public synchronized static BuildingsOnRoadCache getInstance(Geography<IAgent> buildingEnv, File buildingsFile,
        Geography<Road> roadEnv, File roadsFile, File serialisedLoc, GeometryFactory geomFac) throws Exception {
    double time = System.nanoTime();
    // See if there is a cache object on disk.
    if (serialisedLoc.exists()) {
        FileInputStream fis = null;
        ObjectInputStream in = null;
        BuildingsOnRoadCache bc = null;
        try {
            fis = new FileInputStream(serialisedLoc);
            in = new ObjectInputStream(fis);
            bc = (BuildingsOnRoadCache) in.readObject();
            in.close();

            // Check that the cache is representing the correct data and the
            // modification dates are ok
            // (WARNING, if this class is re-compiled the serialised object
            // will still be read in).
            if (!buildingsFile.getAbsolutePath().equals(bc.buildingsFile.getAbsolutePath())
                    || !roadsFile.getAbsolutePath().equals(bc.roadsFile.getAbsolutePath())
                    || buildingsFile.lastModified() > bc.createdTime
                    || roadsFile.lastModified() > bc.createdTime) {
                LOGGER.log(Level.FINER,
                        "BuildingsOnRoadCache, found serialised object but it doesn't match the "
                                + "data (or could have different modification dates), will create a new cache.");
            } else {
                // Have found a useable serialised cache. Now use the cached
                // list of id's to construct a
                // new cache of buildings and roads.
                // First need to buld list of existing roads and buildings
                Hashtable<String, Road> allRoads = new Hashtable<String, Road>();
                for (Road r : roadEnv.getAllObjects())
                    allRoads.put(r.getIdentifier(), r);
                Hashtable<String, IAgent> allBuildings = new Hashtable<String, IAgent>();
                for (IAgent b : buildingEnv.getAllObjects())
                    allBuildings.put(b.getIdentifier(), b);

                // Now create the new cache
                theCache = new Hashtable<Road, ArrayList<IAgent>>();

                for (String roadId : bc.referenceCache.keySet()) {
                    ArrayList<IAgent> buildings = new ArrayList<IAgent>();
                    for (String buildingId : bc.referenceCache.get(roadId)) {
                        buildings.add(allBuildings.get(buildingId));
                    }
                    theCache.put(allRoads.get(roadId), buildings);
                }
                LOGGER.log(Level.FINER, "BuildingsOnRoadCache, found serialised cache, returning it (in "
                        + 0.000001 * (System.nanoTime() - time) + "ms)");
                return bc;
            }
        } catch (IOException ex) {
            if (serialisedLoc.exists())
                serialisedLoc.delete(); // delete to stop problems loading incomplete file next tinme
            throw ex;
        } catch (ClassNotFoundException ex) {
            if (serialisedLoc.exists())
                serialisedLoc.delete();
            throw ex;
        }

    }

    // No serialised object, or got an error when opening it, just create a
    // new one
    return new BuildingsOnRoadCache(buildingEnv, buildingsFile, roadEnv, roadsFile, serialisedLoc, geomFac);
}

From source file:org.cloudifysource.rest.controllers.DeploymentsController.java

/**
 * Sets service level attributes for the given application.
 * //from   ww  w .j a  v a 2 s .  c o  m
 * @param appName
 *            The application name.
 * @param serviceName
 *            The service name.
 * @param request
 *            Request body, specifying the attributes names and values.
 * @throws RestErrorException
 *             Thrown in case the request body is empty.
 * @throws ResourceNotFoundException
 *             Thrown in case the service does not exist.
 */
@RequestMapping(value = "/{appName}/service/{serviceName}/attributes", method = RequestMethod.POST)
public void setServiceAttribute(@PathVariable final String appName, @PathVariable final String serviceName,
        @RequestBody final SetServiceAttributesRequest request)
        throws ResourceNotFoundException, RestErrorException {

    // valid service
    controllerHelper.getService(appName, serviceName);

    // validate request object
    if (request == null || request.getAttributes() == null) {
        throw new RestErrorException(CloudifyMessageKeys.EMPTY_REQUEST_BODY_ERROR.getName());
    }

    if (logger.isLoggable(Level.FINER)) {
        logger.finer("received request to set attributes " + request.getAttributes().keySet() + " of service "
                + ServiceUtils.getAbsolutePUName(appName, serviceName) + " of application " + appName + " to: "
                + request.getAttributes().values());

    }

    // set attributes
    controllerHelper.setAttributes(appName, serviceName, null, request.getAttributes());

}

From source file:org.cloudifysource.rest.controllers.DeploymentsController.java

/**
 * Deletes a service level attribute./*from   w w  w.j av a  2  s. c o m*/
 * 
 * @param appName
 *            The application name.
 * @param serviceName
 *            The service name.
 * @param attributeName
 *            The attribute name.
 * @return The previous value of the attribute.
 * @throws ResourceNotFoundException
 *             Thrown in case the service does not exist.
 * @throws RestErrorException
 *             Thrown in case the attribute name is empty.
 */
@RequestMapping(value = "/{appName}/service/{serviceName}/attributes/{attributeName}", method = RequestMethod.DELETE)
public DeleteServiceAttributeResponse deleteServiceAttribute(@PathVariable final String appName,
        @PathVariable final String serviceName, @PathVariable final String attributeName)
        throws ResourceNotFoundException, RestErrorException {

    // valid service
    controllerHelper.getService(appName, serviceName);

    // logger - request to delete attributes
    if (logger.isLoggable(Level.FINER)) {
        logger.finer("received request to delete attribute " + attributeName + " of service "
                + ServiceUtils.getAbsolutePUName(appName, serviceName) + " of application " + appName);
    }

    // get delete attribute returned previous value
    final Object previous = controllerHelper.deleteAttribute(appName, serviceName, null, attributeName);

    // create response object
    final DeleteServiceAttributeResponse sar = new DeleteServiceAttributeResponse();
    // set previous value
    sar.setPreviousValue(previous);
    // return response object
    return sar;

}

From source file:org.cloudifysource.rest.controllers.DeploymentsController.java

/**
 * Retrieves service instance level attributes.
 * //from  w  ww .  j  av a 2  s .c o  m
 * @param appName
 *            The application name.
 * @param serviceName
 *            The service name.
 * @param instanceId
 *            The instance id.
 * @return An instance of {@link GetServiceInstanceAttributesResponse} containing all the service instance
 *         attributes names and values.
 * @throws ResourceNotFoundException
 *             Thrown in case the service instance does not exist.
 */
@RequestMapping(value = "/{appName}/service/{serviceName}/instances/{instanceId}/attributes", method = RequestMethod.GET)
public GetServiceInstanceAttributesResponse getServiceInstanceAttributes(@PathVariable final String appName,
        @PathVariable final String serviceName, @PathVariable final Integer instanceId)
        throws ResourceNotFoundException {

    // valid service
    controllerHelper.getService(appName, serviceName);

    // logger - request to get all attributes
    if (logger.isLoggable(Level.FINER)) {
        logger.finer("received request to get all attributes of instance number " + instanceId + " of service "
                + ServiceUtils.getAbsolutePUName(appName, serviceName) + " of application " + appName);
    }

    // get attributes
    final Map<String, Object> attributes = controllerHelper.getAttributes(appName, serviceName, instanceId);
    // create response object
    final GetServiceInstanceAttributesResponse siar = new GetServiceInstanceAttributesResponse();
    // set attributes
    siar.setAttributes(attributes);
    // return response object
    return siar;

}

From source file:edu.harvard.iq.dvn.ingest.statdataio.impl.plugins.dta.DTAFileReader.java

private DecodedDateTime decodeDateTimeData(String storageType, String FormatType, String rawDatum)
        throws IOException {

    if (dbgLog.isLoggable(Level.FINER))
        dbgLog.finer("(storageType, FormatType, rawDatum)=(" + storageType + ", " + FormatType + ", " + rawDatum
                + ")");
    /*//w w w  . ja  v  a2s.  co  m
     *         Historical note:
           pseudofunctions,  td(), tw(), tm(), tq(), and th()
        used to be called     d(),  w(),  m(),  q(), and  h().
        Those names still work but are considered anachronisms.
            
    */

    long milliSeconds;
    String decodedDateTime = null;
    String format = null;

    if (FormatType.matches("^%tc.*")) {
        // tc is a relatively new format
        // datum is millisecond-wise

        milliSeconds = Long.parseLong(rawDatum) + STATA_BIAS_TO_EPOCH;
        decodedDateTime = sdf_ymdhmsS.format(new Date(milliSeconds));
        format = sdf_ymdhmsS.toPattern();
        if (dbgLog.isLoggable(Level.FINER))
            dbgLog.finer("tc: result=" + decodedDateTime + ", format = " + format);

    } else if (FormatType.matches("^%t?d.*")) {
        milliSeconds = Long.parseLong(rawDatum) * SECONDS_PER_YEAR + STATA_BIAS_TO_EPOCH;
        if (dbgLog.isLoggable(Level.FINER))
            dbgLog.finer("milliSeconds=" + milliSeconds);

        decodedDateTime = sdf_ymd.format(new Date(milliSeconds));
        format = sdf_ymd.toPattern();
        if (dbgLog.isLoggable(Level.FINER))
            dbgLog.finer("td:" + decodedDateTime + ", format = " + format);

    } else if (FormatType.matches("^%t?w.*")) {

        long weekYears = Long.parseLong(rawDatum);
        long left = Math.abs(weekYears) % 52L;
        long years;
        if (weekYears < 0L) {
            left = 52L - left;
            if (left == 52L) {
                left = 0L;
            }
            //out.println("left="+left);
            years = (Math.abs(weekYears) - 1) / 52L + 1L;
            years *= -1L;
        } else {
            years = weekYears / 52L;
        }

        String yearString = Long.valueOf(1960L + years).toString();
        String dayInYearString = new DecimalFormat("000").format((left * 7) + 1).toString();
        String yearDayInYearString = yearString + "-" + dayInYearString;

        Date tempDate = null;
        try {
            tempDate = new SimpleDateFormat("yyyy-DDD").parse(yearDayInYearString);
        } catch (ParseException ex) {
            throw new IOException(ex);
        }

        decodedDateTime = sdf_ymd.format(tempDate.getTime());
        format = sdf_ymd.toPattern();

    } else if (FormatType.matches("^%t?m.*")) {
        // month 
        long monthYears = Long.parseLong(rawDatum);
        long left = Math.abs(monthYears) % 12L;
        long years;
        if (monthYears < 0L) {
            left = 12L - left;
            //out.println("left="+left);
            years = (Math.abs(monthYears) - 1) / 12L + 1L;
            years *= -1L;
        } else {
            years = monthYears / 12L;
        }

        String month = null;
        if (left == 12L) {
            left = 0L;
        }
        Long monthdata = (left + 1);
        month = "-" + twoDigitFormatter.format(monthdata).toString() + "-01";
        long year = 1960L + years;
        String monthYear = Long.valueOf(year).toString() + month;
        if (dbgLog.isLoggable(Level.FINER))
            dbgLog.finer("rawDatum=" + rawDatum + ": monthYear=" + monthYear);

        decodedDateTime = monthYear;
        format = "yyyy-MM-dd";
        if (dbgLog.isLoggable(Level.FINER))
            dbgLog.finer("tm:" + decodedDateTime + ", format:" + format);

    } else if (FormatType.matches("^%t?q.*")) {
        // quater
        long quaterYears = Long.parseLong(rawDatum);
        long left = Math.abs(quaterYears) % 4L;
        long years;
        if (quaterYears < 0L) {
            left = 4L - left;
            //out.println("left="+left);
            years = (Math.abs(quaterYears) - 1) / 4L + 1L;
            years *= -1L;
        } else {
            years = quaterYears / 4L;
        }

        String quater = null;

        if ((left == 0L) || (left == 4L)) {
            //quater ="q1"; //
            quater = "-01-01";
        } else if (left == 1L) {
            //quater = "q2"; //
            quater = "-04-01";
        } else if (left == 2L) {
            //quater = "q3"; //
            quater = "-07-01";
        } else if (left == 3L) {
            //quater = "q4"; //
            quater = "-11-01";
        }

        long year = 1960L + years;
        String quaterYear = Long.valueOf(year).toString() + quater;
        if (dbgLog.isLoggable(Level.FINER))
            dbgLog.finer("rawDatum=" + rawDatum + ": quaterYear=" + quaterYear);

        decodedDateTime = quaterYear;
        format = "yyyy-MM-dd";
        if (dbgLog.isLoggable(Level.FINER))
            dbgLog.finer("tq:" + decodedDateTime + ", format:" + format);

    } else if (FormatType.matches("^%t?h.*")) {
        // half year
        // odd number:2nd half
        // even number: 1st half

        long halvesYears = Long.parseLong(rawDatum);
        long left = Math.abs(halvesYears) % 2L;
        long years;
        if (halvesYears < 0L) {
            years = (Math.abs(halvesYears) - 1) / 2L + 1L;
            years *= -1L;
        } else {
            years = halvesYears / 2L;
        }

        String half = null;
        if (left != 0L) {
            // odd number => 2nd half: "h2"
            //half ="h2"; //
            half = "-07-01";
        } else {
            // even number => 1st half: "h1"
            //half = "h1"; //
            half = "-01-01";
        }
        long year = 1960L + years;
        String halfYear = Long.valueOf(year).toString() + half;
        if (dbgLog.isLoggable(Level.FINER))
            dbgLog.finer("rawDatum=" + rawDatum + ": halfYear=" + halfYear);

        decodedDateTime = halfYear;
        format = "yyyy-MM-dd";
        if (dbgLog.isLoggable(Level.FINER))
            dbgLog.finer("th:" + decodedDateTime + ", format:" + format);

    } else if (FormatType.matches("^%t?y.*")) {
        // year type's origin is 0 AD
        decodedDateTime = rawDatum;
        format = "yyyy";
        if (dbgLog.isLoggable(Level.FINER))
            dbgLog.finer("th:" + decodedDateTime);
    } else {
        decodedDateTime = rawDatum;
        format = null;
    }
    DecodedDateTime retValue = new DecodedDateTime();
    retValue.decodedDateTime = decodedDateTime;
    retValue.format = format;
    return retValue;
}

From source file:org.cloudifysource.rest.controllers.DeploymentsController.java

/**
 * Sets service instance level attributes for the given application.
 * //www. j a va  2s  .  c o m
 * @param appName
 *            The application name.
 * @param serviceName
 *            The service name.
 * @param instanceId
 *            The instance id.
 * @param request
 *            Request body, specifying the attributes names and values.
 * @throws RestErrorException
 *             Thrown in case the request body is empty.
 * @throws ResourceNotFoundException
 *             Thrown in case the service instance does not exist.
 */
@RequestMapping(value = "/{appName}/service/{serviceName}/instances/{instanceId}/attributes", method = RequestMethod.POST)
public void setServiceInstanceAttributes(@PathVariable final String appName,
        @PathVariable final String serviceName, @PathVariable final Integer instanceId,
        @RequestBody final SetServiceInstanceAttributesRequest request)
        throws ResourceNotFoundException, RestErrorException {

    // valid service
    controllerHelper.getService(appName, serviceName);

    // validate request object
    if (request == null || request.getAttributes() == null) {
        throw new RestErrorException(CloudifyMessageKeys.EMPTY_REQUEST_BODY_ERROR.getName());
    }

    if (logger.isLoggable(Level.FINER)) {
        logger.finer(
                "received request to set attribute " + request.getAttributes().keySet() + " of instance number "
                        + instanceId + " of service " + ServiceUtils.getAbsolutePUName(appName, serviceName)
                        + " of application " + appName + " to: " + request.getAttributes().values());
    }

    // set attributes
    controllerHelper.setAttributes(appName, serviceName, instanceId, request.getAttributes());
}

From source file:foodsimulationmodel.pathmapping.Route.java

private void populateCache(Geography<IAgent> buildingEnvironment, Geography<Road> roadEnvironment)
        throws Exception {
    double time = System.nanoTime();
    theCache = new Hashtable<Coordinate, Coordinate>();
    // Iterate over every building and find the nearest road point
    for (IAgent b : buildingEnvironment.getAllObjects()) {
        List<Coordinate> nearestCoords = new ArrayList<Coordinate>();
        Route.findNearestObject(b.getCoords(), roadEnvironment, nearestCoords,
                GlobalVars.GEOGRAPHY_PARAMS.BUFFER_DISTANCE.LARGE);
        // Two coordinates returned by closestPoints(), need to find the one
        // which isn't the building coord
        Coordinate nearestPoint = null;/*from w  w  w.  j a  v  a  2  s .  c om*/
        for (Coordinate c : nearestCoords) {
            if (!c.equals(b.getCoords())) {
                nearestPoint = c;
                break;
            }
        } // for nearestCoords
        if (nearestPoint == null) {
            throw new Exception("Route.getNearestRoadCoord() error: couldn't find a road coordinate which "
                    + "is close to building " + b.toString());
        }
        theCache.put(b.getCoords(), nearestPoint);
    } // for Buildings
    LOGGER.log(Level.FINER,
            "Finished caching nearest roads (" + (0.000001 * (System.nanoTime() - time)) + "ms)");
}