Thursday, March 1, 2012

JavaScript closure learn

function verifyUpdate(thumbUri, loopName, functionObject){
   
    return (function(){
       
                $.writeln ("verifyUpdate:"+thumbUri);
                var thumbnail = new Thumbnail(thumbUri);
                var status = thumbnail.AdobeDriveExtension.common.statusText;
                if( status == "Up-To-Date"){
                        $.writeln ("verifyUpdate successfully:"+thumbUri);
                        //functionObject();
                         loopWait(functionObject);
                    }
       
                else
                {
                    loop(loopName);
                 }
        }
    );
 }
function checkoutFile(thumbUri,loopName, functionObject){
      return (function(){
            $.writeln ("checkoutFile");
            thumb = new Thumbnail(thumbUri);
            app.document.select(thumb);
            app.document.chooseMenuItem ("CheckOutTools");
            //functionObject();
             loopWait(functionObject);
        }
    );
 }
function verifyCheckedout(thumbUri, loopName,functionObject){
   
    return (function(){
       
                $.writeln ("verifyCheckedout:"+thumbUri);
                var thumbnail = new Thumbnail(thumbUri);
                var status = thumbnail.AdobeDriveExtension.common.statusText;

                if( status == "Checked out by me"){
                         $.writeln ("verifyCheckedout successfully");
                        //functionObject();                  
                        loopWait(functionObject);
                    }
                else
                {
                    loop(loopName);
                 }
        }
    );
 }
function a()
{
    $.writeln ("END");
 }
var loopFunction="verifyUpdateF()";

function loopWait(loopName){
    $.writeln ("loopWait:"+loopName);
    app.scheduleTask(loopName, 3, false);
}

function loop(loopName){
    $.writeln ("loop:"+loopName);
    app.scheduleTask(loopName, 3, false);
}

Monday, February 20, 2012

Use full script to post local folder to cq server

#!/bin/bash

#configure the user and server info
#############################################################
user="admin"
password="admin"
addr="adtest-pc2:4502"
#############################################################
#check argument
if [ "$#" -ne 2 ];then
        echo "this tool need following arguments:
1.valid upload folder or file name on this machine
2.folder name on the server.tool can create folder name on serverif folder name don't exist"
        exit
fi
if [ ! -d "$1" ] && [ ! -f "$1" ];then
        echo "$1 is not valid folder or file,please input valid upload folder or file name"
        exit
fi


sourcefolder=$1
targetproject=$2
url="http://"$addr"/content/dam/"

#create target folder
actualurl=$url""$targetproject
echo $actualurl
actualurl=${actualurl// /%20}
curl -u $user:$password -F jcr:primaryType=sling:Folder $actualurl


#tmp file
tmpfile="pqtmp.txt"
# create folder on server
len=${#sourcefolder};

find  "$sourcefolder" -type d > $tmpfile
count=`wc -l < $tmpfile`
count=`expr $count - 1`
echo "-----------total folder number is $count ----------------"
current=0
while IFS= read -r file
        do
c=${#file}
if [ "$c" -gt "$len" ]; then
current=`expr $current + 1`
echo "-----------total folder number is $count , current is  $current ----------------"
name=${file:len}
echo  "source is $name"
targetfile=$targetproject""$name
echo "target is $targetfile"
actualurl=$url""$targetfile
actualurl=${actualurl// /%20}
echo $actualurl
curl -u $user:$password -F jcr:primaryType=sling:Folder $actualurl
else
echo "root folder"
fi
        done < $tmpfile

#create file on server

find  "$sourcefolder" -type f > $tmpfile
count=`wc -l < $tmpfile`
current=0
echo "-----------total file number is $count -----------------"

while IFS= read -r file
        do
c=${#file}
current=`expr $current + 1`
        echo "-----------total folder number is $count , current is  $current ----------------"
name=${file:len}
if [ "$c" -eq "$len" ];then
name=`basename $file`
targetfile=$targetproject/""$name
echo "target is $targetfile"
else
echo  "source is $name"
                targetfile=$targetproject""$name
fi
actualurl=$url""$targetfile
actualurl=${actualurl// /%20}
echo $actualurl
                curl -u $user:$password -T "$file"  $actualurl


done < $tmpfile

rm -f $tmpfile

Tuesday, November 22, 2011

Useful Curl

1. FTP
curl -u adobenet\\bjsstqe:Bvt_1109  --ftp-pasv ftp://sjstore.corp.adobe.com/builds01/adobedrive/3.0.1/Patcher/win32/mul/20111121.3.0.1.98/AdobeDrive-3.0.1-mul-AdobeUpdate.zip -# > AdobeDrive-3.0.1-mul-AdobeUpdate.zip


2. Http

curl -u admin:admin http://adtest-pc:4502/var/dam/testcom -F jcr:primaryType=nt:folder

curl -u admin:admin -T 5M.JPG http://adtest-pc:4502/var/dam/test/t/

Wednesday, October 19, 2011

How to connect HSql DB

How to connect HSql DB:
1), java -cp hsqldb.jar org.hsqldb.util.SqlTool --rcFile r.rc adrive
2), java -cp hsqldb.jar org.hsqldb.util.DatabaseManagerSwing

// in the file r.rc ,
urlid adrive
url jdbc:hsqldb:file:C:\Program Files\Common Files\Adobe\CS5ServiceManager\plugins\org.hsqldb_1.8.0.8\update\database\adrive-db;
username sa
password

Wednesday, September 28, 2011

CPPUNIT- TestFixture


TestFixture Class Reference
[Writing test fixture]

Wraps a test case with setUp and tearDown methods. #include <TestFixture.h>

Inheritance diagram for TestFixture:




Public Member Functions

virtual ~TestFixture ()
virtual void setUp ()
Set up context before running a test. 
virtual void tearDown ()
Clean up after the test run. 


Detailed Description

Wraps a test case with setUp and tearDown methods.A TestFixture is used to provide a common environment for a set of test cases.
To define a test fixture, do the following:
  • implement a subclass of TestCase
  • the fixture is defined by instance variables
  • initialize the fixture state by overriding setUp (i.e. construct the instance variables of the fixture)
  • clean-up after a test by overriding tearDown.
Each test runs in its own fixture so there can be no side effects among test runs. Here is an example:

class MathTest : public CppUnit::TestFixture { protected: int m_value1, m_value2; public: MathTest() {} void setUp () { m_value1 = 2; m_value2 = 3; } }
For each test implement a method which interacts with the fixture. Verify the expected results with assertions specified by calling CPPUNIT_ASSERT on the expression you want to test:

public: void testAdd () { int result = m_value1 + m_value2; CPPUNIT_ASSERT( result == 5 ); }
Once the methods are defined you can run them. To do this, use a TestCaller.

CppUnit::Test *test = new CppUnit::TestCaller<MathTest>( "testAdd", &MathTest::testAdd ); test->run();
The tests to be run can be collected into a TestSuite.

public: static CppUnit::TestSuite *MathTest::suite () { CppUnit::TestSuite *suiteOfTests = new CppUnit::TestSuite; suiteOfTests->addTest(new CppUnit::TestCaller<MathTest>( "testAdd", &MathTest::testAdd)); suiteOfTests->addTest(new CppUnit::TestCaller<MathTest>( "testDivideByZero", &MathTest::testDivideByZero)); return suiteOfTests; }
A set of macros have been created for convenience. They are located in HelperMacros.h.

See also:
TestResult, TestSuite, TestCaller,CPPUNIT_TEST_SUB_SUITE, CPPUNIT_TEST, CPPUNIT_TEST_SUITE_END, CPPUNIT_TEST_SUITE_REGISTRATION, CPPUNIT_TEST_EXCEPTION, CPPUNIT_TEST_FAIL.


Constructor & Destructor Documentation


virtual TestFixture::~TestFixture(  ) [inline, virtual]


Member Function Documentation


virtual void TestFixture::setUp(  ) [inline, virtual]
Set up context before running a test.

Reimplemented in TestCaseDecorator, and TestCaller< Fixture >.


virtual void TestFixture::tearDown(  ) [inline, virtual]
Clean up after the test run.

Reimplemented in TestCaseDecorator, and TestCaller< Fixture >.


The documentation for this class was generated from the following file:

Function


Syntax

LPTSTR WINAPI GetCommandLine(void);

Parameters

This function has no parameters.

Return value

The return value is a pointer to the command-line string for the current process.

_putenv_s, _wputenv_s 

Visual Studio 2005

Create, modify, or remove environment variables. These are versions of _putenv, _wputenv with security enhancements as described in Security Enhancements in the CRT.
The _putenv_s function adds new environment variables or modifies the values of existing environment variables. Environment variables define the environment in which a process executes (for example, the default search path for libraries to be linked with a program). _wputenv_s is a wide-character version of _putenv_s; the envstring argument to _wputenv_s is a wide-character string.

About hpp


What's the Difference Between .H and .HPP

  1. .hpp, .h, etc. is a loose convention for C++ header files, .hpp is a loose convention for C++ template implementation, and .h is pretty strong convention for c files.

  2. You can use .hh and .cc on UNIX and Linux programmers, different from .cpp and .h. files .hh files can helps emacs distinguish between C and C++ syntax highlighting. .cc extension looks good together with .hh, and it's shorter than .cpp.

  3. .hpp .h to differentiate between the two languages when building mixed-language products. For example, a class definition might go in an .hpp (implementation in .cpp), whereas a .h file would define only functions supported by C. To do this separation it is important to know the difference between the languages - to this end I pass *.c through gcc and *.cpp through g++.