Example usage for java.util.logging Level FINEST

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

Introduction

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

Prototype

Level FINEST

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

Click Source Link

Document

FINEST indicates a highly detailed tracing message.

Usage

From source file:edu.umass.cs.gigapaxos.SQLPaxosLogger.java

@Deprecated
private boolean log(String paxosID, int version, int slot, int ballotnum, int coordinator, PaxosPacketType type,
        String message) {/*w  w  w.j  av a2  s. co  m*/
    if (isClosed())
        return false;
    if (!isLoggingEnabled())
        return true;

    boolean logged = false;

    String cmd = "insert into " + getMTable() + " values (?, ?, ?, ?, ?, ?, ?)";
    PreparedStatement localLogMsgStmt = null;
    Connection conn = null;
    try {
        conn = this.getDefaultConn();
        localLogMsgStmt = conn.prepareStatement(cmd); // no re-use option

        localLogMsgStmt.setString(1, paxosID);
        localLogMsgStmt.setInt(2, version);
        localLogMsgStmt.setInt(3, slot);
        localLogMsgStmt.setInt(4, ballotnum);
        localLogMsgStmt.setInt(5, coordinator);
        localLogMsgStmt.setInt(6, type.getInt());
        if (getLogMessageBlobOption()) {
            // localLogMsgStmt.setBlob(7, new StringReader(message));
            Blob blob = conn.createBlob();
            blob.setBytes(1, message.getBytes(CHARSET));
            localLogMsgStmt.setBlob(7, blob);
        } else
            localLogMsgStmt.setString(7, message);

        int rowcount = localLogMsgStmt.executeUpdate();
        assert (rowcount == 1);
        logged = true;
        log.log(Level.FINEST, "{0} inserted {1}, {2}, {3}, {4}, {5}",
                new Object[] { this, paxosID, slot, ballotnum, coordinator, message });
    } catch (SQLException sqle) {
        if (SQL.DUPLICATE_KEY.contains(sqle.getSQLState())) {
            log.log(Level.FINE, "{0} log message {1} previously logged", new Object[] { this, message });
            logged = true;
        } else {
            log.severe("SQLException while logging as " + cmd + " : " + sqle);
            sqle.printStackTrace();
        }
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    } finally {
        cleanup(localLogMsgStmt);
        cleanup(conn);
    } // no cleanup if statement is re-used
    return logged;
}

From source file:com.npower.dm.server.session.ManagementSessionHandler.java

/**
 * Calculates how many Status can be sent
 *///ww w  . j ava2 s.  co m
private void howManyStatus(List allStatus) {
    addStatus = new ArrayList();
    addStatus.add(sessionState.getStatusSyncHdr());

    //
    // Number of Status to insert into response
    //
    int x = 0;
    Status status = null;
    long size = 0;
    for (int i = 0; allStatus != null && i < allStatus.size(); i++) {
        status = (Status) allStatus.get(i);
        //
        // Calculate size Status
        //
        size = 0;
        if (Constants.MIMETYPE_SYNCMLDM_WBXML.equals(mimeType)
                || Constants.MIMETYPE_SYNCMLDS_WBXML.equals(mimeType)) {
            size = SizeCalculator.getWBXMLSize(status);
        } else if (Constants.MIMETYPE_SYNCMLDM_XML.equals(mimeType)
                || Constants.MIMETYPE_SYNCMLDS_XML.equals(mimeType)) {
            size = SizeCalculator.getXMLSize(status);
        }

        // If there is space, we add the state
        if (maxSizeAvailable - size >= 0) {
            addStatus.add((Status) allStatus.get(i));
            maxSizeAvailable -= size;
            x++;
        } else {
            break;
        }
    }

    if (log.isLoggable(Level.FINEST)) {
        log.finest("Number of Status inserted: " + x);
    }
}

From source file:edu.umass.cs.gigapaxos.PaxosManager.java

private synchronized void initiateRecovery() {
    boolean found = false;
    int groupCount = 0, freq = 1;
    log.log(Level.INFO, "{0} beginning to recover checkpoints", new Object[] { this });
    while (this.paxosLogger.initiateReadCheckpoints(true))
        ; // acquires lock
    RecoveryInfo pri = null;//from  ww w . j  a  va2  s .  c  o m
    while ((pri = this.paxosLogger.readNextCheckpoint(true)) != null) {
        found = true;
        assert (pri.getPaxosID() != null);
        // start paxos instance, restore app state from checkpoint if any
        // and roll forward
        try {
            this.recover(pri.getPaxosID(), pri.getVersion(), this.myID, getNodesFromStringSet(pri.getMembers()),
                    myApp, pri.getState());
        } catch (PaxosInstanceCreationException pice) {
            // should we remove this checkpoint?
            pice.printStackTrace();
            log.severe(this + " unable to create paxos instance " + pri.getPaxosID());
        }
        if ((++groupCount) % freq == 0) {
            freq *= 2;
        }
    }
    this.paxosLogger.closeReadAll(); // releases lock
    log.log(Level.INFO, "{0} has recovered checkpoints for {1} paxos groups",
            new Object[] { this, groupCount });
    if (!found) {
        log.warning("No checkpoint state found for node " + this.myID + ". This can only happen if\n"
                + "(1) the node is newly joining the system, or\n(2) the node previously crashed before "
                + "completing even a single checkpoint, or\n(3) the node's checkpoint was manually deleted.");
    }
    int logCount = 0;
    freq = 1;
    // roll forward all logged messages in a single pass
    log.log(Level.INFO, "{0} beginning to roll forward logged messages", new Object[] { this });
    while (this.paxosLogger.initiateReadMessages())
        ; // acquires lock
    String paxosPacketString = null;
    PaxosPacket paxosPacket = null;
    /**
     * Set packetizer for logger. We need this in order to have the benefits
     * of caching the original string form of received accepts to reduce
     * serialization overhead. Without a packetizer, the logger doesn't know
     * how to convert original string node IDs (that came over the network)
     * in the logged messages to integer IDs. The alternative would be to
     * just store integer IDs in logged messages (trusting that we will
     * always be able to have IntegerMap be able to convert back to the
     * original node IDs because checkpoint recovery happens before rolling
     * forward logs), but that means we wouldn't have the stringified
     * caching optimization.
     */
    this.paxosLogger.setPacketizer(new AbstractPaxosLogger.PaxosPacketizer() {

        @Override
        protected PaxosPacket stringToPaxosPacket(String str) {
            try {
                PaxosPacket pp = PaxosPacket
                        .getPaxosPacket(PaxosManager.this.fixNodeStringToInt(new JSONObject(str)));
                assert (pp != null) : str;
                return pp;
            } catch (JSONException e) {
                e.printStackTrace();
                try {
                    log.severe(PaxosManager.this + " unable to decode string of byte length "
                            + str.getBytes("ISO-8859-1").length);
                } catch (UnsupportedEncodingException e1) {
                    e1.printStackTrace();
                }
            }
            return null;
        }

        @Override
        protected PaxosPacket stringToPaxosPacket(byte[] bytes) {
            PaxosPacketType type = PaxosPacket.getType(bytes);
            try {
                if (type == PaxosPacketType.ACCEPT) {
                    return new AcceptPacket(bytes);
                }
                // else
                return this.stringToPaxosPacket(MessageExtractor.decode(bytes));
            } catch (UnsupportedEncodingException | UnknownHostException e) {
                // likely an undecodeable accept
                e.printStackTrace();
                return null;
            }
        }
    });

    /**
     * We need this for {@link SQLPaxosLogger} for logging messages with int
     * IDs converted back to the original string IDs. The logger will invoke
     * stringToPaxosPacket(String) above while reading logged messages from
     * disk. Disk I/O is no different from network I/O in that integer IDs
     * have meaning outside of PaxosInstanceStateMachine soft state.
     * 
     * We don't always have to convert int to string IDs because if we have
     * {@code stringified} already stored, it is already in a
     * network-friendly form.
     */
    this.paxosLogger.setPaxosPacketStringifier(new AbstractPaxosLogger.PaxosPacketStringifier() {

        @Override
        protected String paxosPacketToString(PaxosPacket paxosPacket) {
            PaxosPacket.PaxosPacketType type = paxosPacket.getType();
            String stringified = null;
            // three loggable types
            if (type == PaxosPacket.PaxosPacketType.ACCEPT || type == PaxosPacket.PaxosPacketType.PREPARE
                    || type == PaxosPacket.PaxosPacketType.DECISION) {
                if (paxosPacket instanceof RequestPacket
                        && (stringified = ((RequestPacket) paxosPacket).getStringifiedSelf()) != null)
                    return stringified;
                else
                    try {
                        net.minidev.json.JSONObject jsonSmart = paxosPacket.toJSONSmart();
                        stringified = jsonSmart != null
                                ? PaxosManager.this.messenger.fixNodeIntToString(jsonSmart).toString()
                                :
                        // prepares don't have toJSONSmartImpl()
                        paxosPacket.toString();
                    } catch (JSONException je) {
                        // exception will never be thrown
                        assert (false);
                        // at least use default toString in any case
                        stringified = paxosPacket.toString();
                    }
            }
            return stringified;
        }
    });

    try {
        while ((paxosPacket = this.paxosLogger.readNextMessage()) != null) {
            paxosPacket = PaxosPacket.markRecovered(paxosPacket);
            Level level = Level.FINEST;
            log.log(level, "{0} rolling forward logged message {1}",
                    new Object[] { this, paxosPacket.getSummary(log.isLoggable(level)) });
            this.handlePaxosPacket((paxosPacket));
            if ((++logCount) % freq == 0) {
                freq *= 2;
            }
        }
    } catch (NumberFormatException e) {
        Util.suicide(log, this + " recovery interrupted while parsing " + paxosPacketString
                + ";\n Exiting because it is unsafe to continue recovery.");
        e.printStackTrace();
    }
    this.paxosLogger.closeReadAll(); // releases lock
    log.log(Level.INFO, "{0} rolled forward {1} messages total across {2} paxos groups",
            new Object[] { this, logCount, groupCount });

    // need to make another pass to mark all instances as active
    while (this.paxosLogger.initiateReadCheckpoints(true))
        ; // acquires lock
    while ((pri = this.paxosLogger.readNextCheckpoint(true)) != null) {
        found = true;
        assert (pri.getPaxosID() != null);
        PaxosInstanceStateMachine pism = getInstance(pri.getPaxosID());
        if (pism != null)
            pism.setActive();
        Boolean isActive = pism != null ? pism.isActive() : null;
        log.log(Level.INFO, "{0} recovered paxos instance {1}; isActive = {2} ",
                new Object[] { this, pism != null ? pism.toStringLong() : null, isActive });
    }
    this.paxosLogger.closeReadAll(); // releases lock

    this.hasRecovered = true;
    this.notifyRecovered();
    log.log(Level.INFO, "------------------{0} recovery complete-------------------", new Object[] { this });
}

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 a 2s.c o  m

    // 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:com.npower.dm.server.session.ManagementSessionHandler.java

/**
 * Calculates how many AbstractCommand can be sent.
 *//* w w  w  . jav  a 2 s . c  om*/
private void howManyAbstractCommand() {
    addAbsCmd = new ArrayList();
    boolean isCmdWithLargeObject = false;

    //
    // Number of AbstractCommand to insert into response
    //
    int x = 0;
    List allCmd = sessionState.getCmdOut();

    if (maxSizeAvailable > 0 && sessionState.getStatusCmdOut().size() == 0
            && sessionState.getAlertCmdOut().size() == 0) {

        long size = 0;
        AbstractCommand cmd = null;
        for (int i = 0; allCmd != null && i < allCmd.size(); i++) {
            size = 0;
            cmd = (AbstractCommand) allCmd.get(i);

            if (Constants.MIMETYPE_SYNCMLDM_WBXML.equals(mimeType)
                    || Constants.MIMETYPE_SYNCMLDS_WBXML.equals(mimeType)) {
                size = SizeCalculator.getCommandWBXMLSize(cmd);
            } else if (Constants.MIMETYPE_SYNCMLDM_XML.equals(mimeType)
                    || Constants.MIMETYPE_SYNCMLDS_XML.equals(mimeType)) {
                size = SizeCalculator.getCommandXMLSize(cmd);
            }

            // If there is space, we add the abstract command
            if (maxSizeAvailable - size >= 0) {
                addAbsCmd.add(cmd);
                maxSizeAvailable -= size;
                if (cmd == sessionState.getSplittedCommand()) {
                    //
                    // I have added a previous splitted cmd.
                    //
                    sessionState.setSplittedCommand(null);
                    sessionState.setNextDataToSend(null);
                }
                x++;
            } else {

                isCmdWithLargeObject = checkForSplitData(cmd, maxSizeAvailable);

                //
                // If cmd is the first command that we try to add and there isn't
                // sufficiently space then we try to split the data in more message (large object).
                // If large object isn't permitted (because the dimension is greater of the maxObjectSize)
                // we log the info and remove the command from the list
                // because this command not will be never in the list
                //
                if (i == 0) {

                    if (!isCmdWithLargeObject) {
                        if (log.isLoggable(Level.INFO)) {
                            log.info("The command " + cmd + " is too large (" + size + " bytes)");
                        }
                        sessionState.removeCmdOut(cmd);
                    } else {
                        addAbsCmd.add(cmd);
                        x++;
                        if (sessionState.getNextDataToSend() == null) {
                            //
                            // All data is sent. Try to add more commands
                            //
                            continue;
                        } else {
                            break;
                        }
                    }
                } else {
                    if (!isCmdWithLargeObject) {
                        //
                        // This isn't first command and isn't a command with
                        // large object, then break the process
                        //
                        break;
                    } else {
                        //
                        // This isn't first command but is a command with
                        // large object, then add the command and break the process
                        //
                        addAbsCmd.add(cmd);
                        x++;
                        if (sessionState.getNextDataToSend() == null) {
                            //
                            // All data is sent. Try to add more commands
                            //
                            continue;
                        } else {
                            break;
                        }
                    }
                }
                break;
            }
        }
    }
    if (log.isLoggable(Level.FINEST)) {
        log.finest("Number of AbstractCommand inserted: " + x);
    }

}

From source file:edu.umass.cs.gigapaxos.SQLPaxosLogger.java

@Override
public/* synchronized */HotRestoreInfo unpause(String paxosID) {
    if (isClosed() /* || !isLoggingEnabled() */)
        return null;

    HotRestoreInfo hri = null;/*from  w w  w.jav a 2  s.  c o  m*/
    PreparedStatement pstmt = null;
    ResultSet rset = null;
    Connection conn = null;
    String logIndexString = null;
    try {
        conn = this.getDefaultConn();
        pstmt = this.getPreparedStatement(conn, (USE_CHECKPOINTS_AS_PAUSE_TABLE ? getCTable() : getPTable()),
                paxosID, "serialized, logindex");
        rset = pstmt.executeQuery();
        while (rset.next()) {

            assert (hri == null); // exactly onece
            String serialized = rset.getString(1); // no clob option
            if (serialized != null)
                hri = new HotRestoreInfo(serialized);

            Blob logIndexBlob = rset.getBlob(2);
            logIndexString = lobToString(logIndexBlob);
            if (logIndexBlob != null) {
                this.messageLog.restore(new LogIndex(new JSONArray(logIndexString)));
            }
        }
    } catch (SQLException | JSONException | IOException e) {
        log.severe(this + " failed to unpause instance " + paxosID + "; logIndex = " + logIndexString);
        e.printStackTrace();
    } finally {
        cleanup(pstmt, rset);
        cleanup(conn);
    }
    ;
    if (hri != null) {
        log.log(Level.FINEST, "{0} unpaused {1} and about to delete pause state",
                new Object[] { this, paxosID });
        this.deletePaused(paxosID); // unpause will also delete paused state
    }
    return hri;
}

From source file:fr.ortolang.diffusion.core.CoreServiceBean.java

@Override
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public Collection moveCollection(String wskey, String source, String destination)
        throws CoreServiceException, KeyNotFoundException, InvalidPathException, AccessDeniedException,
        PathNotFoundException, PathAlreadyExistsException, WorkspaceReadOnlyException {
    LOGGER.log(Level.FINE, "moving collection into workspace [" + wskey + "] from path [" + source
            + "] to path [" + destination + "]");
    try {/*from   w ww.ja  va2 s .  c o  m*/
        PathBuilder spath = PathBuilder.fromPath(source);
        if (spath.isRoot()) {
            throw new InvalidPathException("unable to move the root collection");
        }
        PathBuilder sppath = spath.clone().parent();

        PathBuilder dpath = PathBuilder.fromPath(destination);
        if (dpath.isRoot()) {
            throw new InvalidPathException("unable to move to the root collection");
        }
        PathBuilder dppath = dpath.clone().parent();

        if (dpath.equals(spath)) {
            throw new InvalidPathException("unable to move into the same path");
        }
        if (spath.isParent(dpath)) {
            throw new InvalidPathException("unable to move into a children of this path");
        }

        String caller = membership.getProfileKeyForConnectedIdentifier();
        List<String> subjects = membership.getConnectedIdentifierSubjects();
        authorisation.checkAuthentified(subjects);
        LOGGER.log(Level.FINEST, "user [" + caller + "] is authentified");

        OrtolangObjectIdentifier wsidentifier = registry.lookup(wskey);
        checkObjectType(wsidentifier, Workspace.OBJECT_TYPE);
        LOGGER.log(Level.FINEST, "workspace with key [" + wskey + "] exists");

        Workspace ws = em.find(Workspace.class, wsidentifier.getId());
        if (ws == null) {
            throw new CoreServiceException(
                    "unable to load workspace with id [" + wsidentifier.getId() + "] from storage");
        }
        if (applyReadOnly(caller, subjects, ws)) {
            throw new WorkspaceReadOnlyException(
                    "unable to move collection in workspace with key [" + wskey + "] because it is read only");
        }
        ws.setKey(wskey);
        LOGGER.log(Level.FINEST, "workspace loaded");

        authorisation.checkPermission(ws.getHead(), subjects, "update");
        LOGGER.log(Level.FINEST,
                "user [" + caller + "] has 'update' permission on the head collection of this workspace");

        Collection sparent = loadCollectionAtPath(ws.getHead(), sppath, ws.getClock());
        CollectionElement selement = sparent.findElementByName(spath.part());
        if (selement == null) {
            throw new PathNotFoundException(spath.build());
        }
        LOGGER.log(Level.FINEST,
                "source collection element found for path " + spath.build() + ", key: " + selement.getKey());

        OrtolangObjectIdentifier scidentifier = registry.lookup(selement.getKey());
        checkObjectType(scidentifier, Collection.OBJECT_TYPE);
        Collection scollection = em.find(Collection.class, scidentifier.getId());
        if (scollection == null) {
            throw new CoreServiceException(
                    "unable to load source collection with id [" + scidentifier.getId() + "] from storage");
        }
        scollection.setKey(selement.getKey());
        LOGGER.log(Level.FINEST, "source collection exists and loaded from storage");

        Collection dparent = loadCollectionAtPath(ws.getHead(), dppath, ws.getClock());
        if (dparent.containsElementName(dpath.part())) {
            throw new PathAlreadyExistsException(dpath.build());
        }

        sparent.removeElement(selement);
        em.merge(sparent);
        registry.update(sparent.getKey());
        LOGGER.log(Level.FINEST, "parent [" + sparent.getKey() + "] has been updated");

        LOGGER.log(Level.FINEST, "destination element does not exists, ok for creating it");
        if (!dpath.part().equals(spath.part())) {
            if (scollection.getClock() < ws.getClock()) {
                scollection = cloneCollection(ws.getHead(), scollection, ws.getClock());
            }
            scollection.setName(dpath.part());
            em.merge(scollection);
            registry.update(scollection.getKey());
        }
        dparent.addElement(new CollectionElement(Collection.OBJECT_TYPE, scollection.getName(),
                System.currentTimeMillis(), 0, Collection.MIME_TYPE, scollection.getKey()));
        em.merge(dparent);
        registry.update(dparent.getKey());
        LOGGER.log(Level.FINEST, "collection [" + scollection.getKey() + "] added to destination parent ["
                + dparent.getKey() + "]");

        ws.setChanged(true);
        em.merge(ws);
        registry.update(ws.getKey());
        LOGGER.log(Level.FINEST, "workspace set changed");

        ArgumentsBuilder argsBuilder = new ArgumentsBuilder(5).addArgument("ws-alias", ws.getAlias())
                .addArgument("key", scollection.getKey()).addArgument("okey", selement.getKey())
                .addArgument("src-path", spath.build()).addArgument("dest-path", dpath.build());
        notification.throwEvent(wskey, caller, Workspace.OBJECT_TYPE,
                OrtolangEvent.buildEventType(CoreService.SERVICE_NAME, Collection.OBJECT_TYPE, "move"),
                argsBuilder.build());

        return scollection;
    } catch (KeyLockedException | NotificationServiceException | RegistryServiceException
            | MembershipServiceException | AuthorisationServiceException | CloneException e) {
        ctx.setRollbackOnly();
        LOGGER.log(Level.SEVERE, "unexpected error while moving collection", e);
        throw new CoreServiceException("unable to move collection into workspace [" + wskey + "] from path ["
                + source + "] to path [" + destination + "]", e);
    }
}

From source file:hudson.scm.BlameSubversionSCM.java

/**
 * Enables trace logging of Ganymed SSH library.
 * <p>//from w w w. j a v a  2s.com
 * Intended to be invoked from Groovy console.
 */
public static void enableSshDebug(Level level) {
    if (level == null)
        level = Level.FINEST; // default

    final Level lv = level;

    com.trilead.ssh2.log.Logger.enabled = true;
    com.trilead.ssh2.log.Logger.logger = new DebugLogger() {
        private final Logger LOGGER = Logger.getLogger(SCPClient.class.getPackage().getName());

        public void log(int level, String className, String message) {
            LOGGER.log(lv, className + ' ' + message);
        }
    };
}

From source file:com.npower.dm.server.session.ManagementSessionHandler.java

private void checkMaxMsgSize(SyncML response) {
    if (log.isLoggable(Level.FINEST)) {
        log.finest("Check if the MaxMsgSize is larger of the minimal " + "size of the messages of the server");
    }//w  w  w .  j  a va 2s . c  om
    long minMsgSize = 0;
    if (sessionState.getMaxMsgSize() != 0) {
        if (Constants.MIMETYPE_SYNCMLDS_WBXML.equals(mimeType)
                || Constants.MIMETYPE_SYNCMLDM_WBXML.equals(mimeType)) {
            minMsgSize = Long.parseLong(
                    engine.getConfiguration().getStringValue(DMManagementEngine.CFG_MIN_MSGSIZE_WBXML));
        } else if (Constants.MIMETYPE_SYNCMLDS_XML.equals(mimeType)
                || Constants.MIMETYPE_SYNCMLDM_XML.equals(mimeType)) {
            minMsgSize = Long.parseLong(
                    engine.getConfiguration().getStringValue(DMManagementEngine.CFG_MIN_MSGSIZE_XML));
        }
        if (sessionState.getMaxMsgSize() < minMsgSize) {
            Status statusHdr = (Status) response.getSyncBody().getCommands().get(0);
            statusHdr.setData(new Data(StatusCode.COMMAND_FAILED));

            if (log.isLoggable(Level.INFO)) {
                log.info("The MaxMsgSize is smaller than minimum size "
                        + "that the server response could have!");
                log.info("The server will not answer to some message " + "of the client.");
            }
        }
    }
}

From source file:fr.ortolang.diffusion.core.CoreServiceBean.java

@Override
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public void deleteCollection(String wskey, String path, boolean force)
        throws CoreServiceException, KeyNotFoundException, InvalidPathException, AccessDeniedException,
        CollectionNotEmptyException, PathNotFoundException, WorkspaceReadOnlyException {
    LOGGER.log(Level.FINE, "deleting collection into workspace [" + wskey + "] at path [" + path + "]");
    try {/*from   w w  w  .j  a v a  2 s.c  om*/
        PathBuilder npath = PathBuilder.fromPath(path);
        if (npath.isRoot()) {
            throw new InvalidPathException("unable to delete the root collection");
        }
        PathBuilder ppath = npath.clone().parent();

        String caller = membership.getProfileKeyForConnectedIdentifier();
        List<String> subjects = membership.getConnectedIdentifierSubjects();
        authorisation.checkAuthentified(subjects);
        LOGGER.log(Level.FINEST, "user [" + caller + "] is authentified");

        OrtolangObjectIdentifier wsidentifier = registry.lookup(wskey);
        checkObjectType(wsidentifier, Workspace.OBJECT_TYPE);
        LOGGER.log(Level.FINEST, "workspace with key [" + wskey + "] exists");

        Workspace ws = em.find(Workspace.class, wsidentifier.getId());
        if (ws == null) {
            throw new CoreServiceException(
                    "unable to load workspace with id [" + wsidentifier.getId() + "] from storage");
        }
        if (applyReadOnly(caller, subjects, ws)) {
            throw new WorkspaceReadOnlyException("unable to delete collection in workspace with key [" + wskey
                    + "] because it is read only");
        }
        ws.setKey(wskey);
        LOGGER.log(Level.FINEST, "workspace loaded");

        authorisation.checkPermission(ws.getHead(), subjects, "delete");
        LOGGER.log(Level.FINEST,
                "user [" + caller + "] has 'delete' permission on the head collection of this workspace");

        Collection parent = loadCollectionAtPath(ws.getHead(), ppath, ws.getClock());
        CollectionElement element = parent.findElementByName(npath.part());
        if (element == null) {
            throw new PathNotFoundException(npath.build());
        }
        LOGGER.log(Level.FINEST,
                "collection element found for path " + npath.build() + ", key: " + element.getKey());

        OrtolangObjectIdentifier cidentifier = registry.lookup(element.getKey());
        checkObjectType(cidentifier, Collection.OBJECT_TYPE);
        Collection leaf = em.find(Collection.class, cidentifier.getId());
        if (leaf == null) {
            throw new CoreServiceException(
                    "unable to load collection with id [" + cidentifier.getId() + "] from storage");
        }
        leaf.setKey(element.getKey());
        LOGGER.log(Level.FINEST, "collection exists and loaded from storage");

        if (!leaf.isEmpty() && !force) {
            throw new CollectionNotEmptyException(path);
        }

        parent.removeElement(element);
        em.merge(parent);
        registry.update(parent.getKey());

        LOGGER.log(Level.FINEST, "parent [" + parent.getKey() + "] has been updated");

        ws.setChanged(true);
        em.merge(ws);
        registry.update(ws.getKey());
        LOGGER.log(Level.FINEST, "workspace set changed");

        if (leaf.getClock() == ws.getClock()) {
            LOGGER.log(Level.FINEST, "leaf clock [" + leaf.getClock()
                    + "] is the same than workspace, key can be deleted and unindexed");
            for (MetadataElement mde : leaf.getMetadatas()) {
                registry.delete(mde.getKey());
            }
            registry.delete(leaf.getKey());
            indexing.remove(leaf.getKey());
        }
        deleteCollectionContent(leaf, ws.getClock());

        ArgumentsBuilder argsBuilder = new ArgumentsBuilder(3).addArgument("ws-alias", ws.getAlias())
                .addArgument("key", leaf.getKey()).addArgument("path", npath.build());
        notification.throwEvent(wskey, caller, Workspace.OBJECT_TYPE,
                OrtolangEvent.buildEventType(CoreService.SERVICE_NAME, Collection.OBJECT_TYPE, "delete"),
                argsBuilder.build());
    } catch (KeyLockedException | NotificationServiceException | RegistryServiceException
            | MembershipServiceException | AuthorisationServiceException | IndexingServiceException e) {
        ctx.setRollbackOnly();
        LOGGER.log(Level.SEVERE, "unexpected error while deleting collection", e);
        throw new CoreServiceException(
                "unable to delete collection into workspace [" + wskey + "] at path [" + path + "]", e);
    }
}