Google Website Translator Gadget

viernes, 24 de febrero de 2012

struts2, eclipse i les CSS stylesheet

Si detectes que les CSS stylesheet no s'apliquen en el teu struts2 fes el següent:

<link href="${pageContext.request.contextPath}/AppPublic/MyCSS.css" type="text/css" rel="Stylesheet">

sábado, 18 de febrero de 2012

LDAP Active Directory Attributes

Microsoft Active Directory
Microsoft Active Directory
Una manera ràpida de consultar la infinita llista de atributs existents al Active Directory LDAP de Microsoft:

http://msdn.microsoft.com/en-us/library/ms675090(VS.85).aspx


Encara que potser si estàs programant en Java deu ser perquè vols ser el màxim standard possible i no hauràs arribat a aquest blog....




Enllaços relacionats:


JNDI Queries complexes amb Searchcontrols

Una de les opcions més interesants es la possibilitat de crear cerques complexes amb l'ús de Searchcontrols

String query_filter = "(|(cn=*"+pCanonicalName+"*) (sAMAccountName=*"+pCanonicalName+"*))";

Cal recordar que l'operador va abans dels operands.

Operadors:
SymbolDescription
&conjunction (i.e.,and -- all in list must be true)
| disjunction (i.e.,or -- one or more alternatives must be true)
!negation (i.e.,not -- the item being negated must not be true)
=equality (according to the matching rule of the attribute)
~= approximate equality (according to the matching rule of the attribute)
>=greater than (according to the matching rule of the attribute)
<=less than (according to the matching rule of the attribute)
=*presence (i.e., the entry must have the attribute but its value is irrelevant)
* wildcard (indicates zero or more characters can occur in that position); used when specifying attribute values to match
\escape (for escaping '*', '(', or ')' when they occur inside an attribute value)



Sources:
http://docs.oracle.com/javase/tutorial/jndi/ops/index.html
http://docs.oracle.com/javase/tutorial/jndi/ops/filter.html

miércoles, 15 de febrero de 2012

7-zip encrypted command line

7-zip  (http://www.7-zip.org/) es una eina de compressió open source, que a més permet l'ús de command-line i encriptació... es a dir... tot avantages.


C:\Program Files\7-Zip\7z.exe a target7-zip.7p  sourcefloder\*
-pPASSWORD


Aquesta comanda s'ha verificat amb la darrera versió 9.20.


martes, 14 de febrero de 2012

LDAP objectClass and objectCategory

Microsoft Active Directory
Microsoft Active Directory
Quan busques la manera de identificar la classe de un objecte LDAP Active Directory ens trobem 2 variables:
  • objectClass
  • objectCategory
Exemples:




He trobat la següent informació a Microsoft:
objectClass
Each instance of an object class has a multi-valued objectClass property that identifies the class of which the object is an instance, as well as all structural or abstract superclasses from which that class is derived.
Thus, the objectClass property of a user object would identify the top, person, organizationalPerson, and user classes.
The objectClass property does not include auxiliary classes in the list. The system sets the objectClass value when the object instance is created and it cannot be changed.
Important  The objectClass attribute is not indexed (Nota: A la pàgina origen - a baix - hi ha un comentari que diu que si indexa des de Windows 2008).

objectCategory
Each instance of an object class also has an objectCategory property, which is a single-valued property that contains the distinguished name of either the class of which the object is an instance or one of its superclasses.
When an object is created, the system sets its objectCategory property to the value specified by the defaultObjectCategory property of its object class. An object's objectCategory property cannot be changed.

To locate objects of a given class, use the objectCategory attribute, which is single-valued and indexed.
For most classes, the defaultObjectCategory is the distinguished name of the class's classSchema object. For example, the defaultObjectCategory for the organizationalUnit class is "CN=Organizational-Unit,CN=Schema,CN=Configuration,<DC=forestroot>". However, some classes refer to another class as their defaultObjectCategory. This allows a query to readily find groups of related objects, even if they are of differing classes. For example, the user, person, organizationalPerson, and contact classes all identify the person class in their defaultObjectCategory properties. This allows search filters like (objectCategory=person) to locate instances of all these classes with a single query. Queries for people are very common, so this is a simple optimization.

From:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms677612(v=vs.85).aspx

Enllaços relacionats:

Javadoc tags


Encara que sempre s'acaba copiant les capceleres de la documentació no està de més tenir la llista de tags i recordar l'ordre de aparició:


Tag & Parameter
Usage
Applies to
@author name
Describes an author.
Class, Interface, Enum
@version version
Provides software version entry. Max one per Class or Interface.
Class, Interface, Enum
@since since-text
Describes when this functionality has first existed.
Class, Interface, Enum, Field, Method
@see reference
Provides a link to other element of documentation.
Class, Interface, Enum, Field, Method
@param name description
Describes a method parameter.
Method
@return description
Describes the return value.
Method
@exception classname description
@throws classname description
Describes an exception that may be thrown from this method.
Method
@deprecated description
Describes an outdated method.
Method
{@inheritDoc}
Copies the description from the overridden method.
Overriding Method
{@link reference}
Link to other symbol.
Class, Interface, Enum, Field, Method
{@value}
Return the value of a static field.
Static Field


però si vols la informació original pots escardar a:
http://www.oracle.com/technetwork/java/javase/documentation/index-137868.html
http://en.wikipedia.org/wiki/Javadoc

lunes, 13 de febrero de 2012

Excel 2007 automatic filled formulas

De vegades i de manera aparenment misteriosa Excel 2007 decideix copiar les formules....
Ja has probat a desactivar "Extend data range formats and formulas" sense éxit.


Proba a aplicar:


i  desactivar "Fill formulas in tables to create calculated columns"



domingo, 12 de febrero de 2012

El misteriós error java.lang.ClassNotFoundException: com.sun.jndi.ldap.LdapcontextADFactory

Al món del IS et trobes de tant en tant un error al que li dones voltes i fas "googling" sense cap mena de resultat....
Errors que no hi eren abans...
Errors inexplicables en SW que sempre ha funcionat bé...
 i aquest era un d'aquests casos.

Fins que t'adones que el misterios missatge:
java.lang.ClassNotFoundException

No es més que la causa de un Find/Replace erròni...

Tot torna feliçment a la normalitat :-)
: com.sun.jndi.ldap.LdapcontextADFactory

lunes, 6 de febrero de 2012

Java7: NamingEnumeration

Una cosa repelent de les NamingEnumeration es el fet que cada accés fa moure la llista...
Així que si s'executa una cosa com:

NamingEnumeration list = ctx.list("ou=People");
while (list.hasMore())
{System.out.println(list.next());
NameClassPair nc = (NameClassPair)list.next();
System.out.println(nc);
}
Perdràs la meitat de la llista, ja que l'accés la fa moure.
Es per això que es fa una instància a un objecte abans (NameClassPair nc = (NameClassPair)list.next();)  de fer la impressió (System.out.println(nc);).


From:
http://docs.oracle.com/javase/tutorial/jndi/ops/list.html

domingo, 5 de febrero de 2012

Java 7: Collections i SortSet

Java logo
java.com
Perquè he arribat aquí?
Intentant trobar una forma millor per a enmagatezmar objectes ordenats dins d'un programa... i fallar espectacularment amb un aclaridor Exception in thread "main" java.lang.NullPointerException
Això em va fer posar a tornar a estudiar Collection i trobar aventatges addicionals a la versió Java7:
  • Set Interface Bulk Operations: Com s1.addAll(s2) — transforms s1 into the union of s1 and s2.
  • HashSet, which stores its elements in a hash table, is the best-performing implementation;

Collection are used to store, retrieve, manipulate, and communicate aggregate data. Typically, they represent data items that form a natural group, such as a poker hand (a collection of cards), a mail folder (a collection of letters), or a telephone directory (a mapping of names to phone numbers).



The Set Interface
A Set is a Collection that cannot contain duplicate elements. The Set interface contains only methods inherited from Collection and adds the restriction that duplicate elements are prohibited. The Java platform contains three general-purpose Set implementations:
HashSet, which stores its elements in a hash table, is the best-performing implementation; however it makes no guarantees concerning the order of iteration.
 TreeSet, which stores its elements in a red-black tree, orders its elements based on their values; it is substantially slower than HashSet.
 LinkedHashSet, which is implemented as a hash table with a linked list running through it, orders its elements based on the order in which they were inserted into the set (insertion-order). LinkedHashSet spares its clients from the unspecified, generally chaotic ordering provided by HashSet at a cost that is only slightly higher.

Notes importants!!!
Les Collection s'han d'instanciar, però has de tenir en comte també les seves implementacions.
Així per exemple, per a implementar una Collection genèrica, pots agafar el HashSet:
Collection<Type> noDups = new HashSet<Type>(c);
o per a una llista has d'escollir entre ArrayList o LinkedList
List<Type> list3 = new ArrayList<Type>();

Enllaços relacionats:

http://docs.oracle.com/javase/8/docs/technotes/guides/collections/overview.html
http://docs.oracle.com/javase/tutorial/collections/index.html
http://docs.oracle.com/javase/tutorial/collections/interfaces/set.html
http://docs.oracle.com/javase/7/docs/api/java/util/HashSet.html

Java 7: Formatting text, numbers and dates

Java logo
java.com
Quan estas programant, i sobretot debuggant, es molt interessant poder utilitzar formats al imprimir errors i missatges.
Aixi, pots substituir System.out.println( per System.out.format(

i aplicar els següents modificadors:

nIndependent platform New Line
dA decimal integer.
fA float.
nA new line character appropriate to the platform running the application. You should always use %n, rather than \n.
tBA date & time conversion—locale-specific full name of month.
td, teA date & time conversion—2-digit day of month. td has leading zeroes as needed, te does not.
ty, tYA date & time conversion—ty = 2-digit year, tY = 4-digit year.
tlA date & time conversion—hour in 12-hour clock.
tMA date & time conversion—minutes in 2 digits, with leading zeroes as necessary.
tpA date & time conversion—locale-specific am/pm (lower case).
tmA date & time conversion—months in 2 digits, with leading zeroes as necessary.
tDA date & time conversion—date as %tm%td%ty
 08Eight characters in width, with leading zeroes as necessary.
  +Includes sign, whether positive or negative.
  ,Includes locale-specific grouping characters.
 -Includes Left-justified.
  .3Three places after decimal point.
  10.3Ten characters in width, right justified, with three places after decimal point.

From:  http://docs.oracle.com/javase/tutorial/java/data/numberformat.html

Backup Libraries: free generator of Barcode Labels

With the following on-line service http://tapelabels.librelogiciel.com/ you could generate your own Tape Labels.
Even the Disc to Disc or BackUp to Disc (http://en.wikipedia.org/wiki/Disk-to-disk) is, for several reasons, the emerging backup tool, most of the environments are using datatapes to store the backup information.

A common problem is to ensure the unique ID for each datatape, specially interesting during merging companies, reusing datatapes (cost savings nowadays is a key concept), etc...


2013:el servei es ara de pagament. Hi ha linearchaos.com que sembla que encara es gratuït.

Java: Declaring an object


Java logo
docs.oracle.com
From:
http://docs.oracle.com/javase/tutorial/java/javaOO/objectcreation.html





Declaring a Variable to Refer to an Object
Previously, you learned that to declare a variable, you write:
type name;

This notifies the compiler that you will use name to refer to data whose type is type.
With a primitive variable, this declaration also reserves the proper amount of memory for the variable.

However:
Point originOne;

If you declare originOne like this, its value will be undetermined until an object is actually created and assigned to it.
Simply declaring a reference variable does not create an object.
For that, you need to use the new operator, as described in the next section.
You must assign an object to originOne before you use it in your code. Otherwise, you will get a compiler error.

A variable in this state, which currently references no object, can be illustrated as follows (the variable name, originOne, plus a reference pointing to nothing):




Instantiating a Class
The new operator instantiates a class by allocating memory for a new object and returning a reference to that memory. The new operator also invokes the object constructor.


--------------------------------------------------------------------------------
Note : The phrase "instantiating a class" means the same thing as "creating an object." When you create an object, you are creating an "instance" of a class, therefore "instantiating" a class.
--------------------------------------------------------------------------------

The new operator requires a single, postfix argument: a call to a constructor. The name of the constructor provides the name of the class to instantiate.

The new operator returns a reference to the object it created. This reference is usually assigned to a variable of the appropriate type, like:

Point originOne = new Point(23, 94);